Packages

README

An open source computer vision library in Mojo

Language Badge GitHub License Badge CodeQL

Overview • Installation • Examples

Overview

Description

Mosaic is a cross-platform (macOS and linux) computer vision library for prototyping and production.

By transparently leveraging hardware acceleration and using the latest MLIR compiler technology, Mosaic is the first computer vision library built specifically for heterogenous compute: CPUs, GPUs, XPUs.

It unifies the computer vision workflow into one language that runs on any hardware.

Principles
  1. Easy to use
  2. Type-safe, memory-safe
  3. Performant
Features
  • Image representation
    • Image file encoding and decoding
    • Data type specification (at compile time)
    • Color space specification (at compile time)
  • Image processing
    • Filtering
    • Geometric transforms
    • Fourier transforms
  • Video capture (currently only macOS)
    • Stream connected cameras
  • Video processing (currently only macOS)
    • Filter live video using custom processors
  • Visualization (currently only macOS)
    • Native image and video rendering
  • Hardware acceleration
    • Parallelization and SIMD on CPUs
    • GPU acceleration when available

Installation

Prerequisites
  • Pixi (the Mojo environment and package manager)
Using the pixi cli
pixi add mosaic
After installation

The pixi.toml file should include the Modular community channel and the Mosaic dependency:

[project]
channels = ["https://repo.prefix.dev/modular-community"]

[dependencies]
mosaic = "*"

Examples

Prerequisites

Clone the repo and build Mosaic:

git clone git@github.com:christianbator/mosaic.git
cd mosaic
pixi run build
Running an example

Run an example file from the examples/ directory like so:

cd examples
pixi run mojo load_image.mojo
Load image
Save image Scale image
Resize image
Slice image
  • Slices the top half of an image
  • Image slices are mutable views into the underlying image data
  • Source: examples/slice_image.mojo
Rotate image
Flip image
Pad image
Convert type Convert color space
Convert color space as type Blur image
Detect edges
Unsharp mask
Picture in picture
Extract channel
Fourier transform
Inverse Fourier transform
High-pass filter
Video capture
Video processing

DETAILS

RUN (INSTALL MAX FIRST)

magic add mosaic

MAX VERSION COMPATIBILITY

max==25.3.0

CREATED BY

TAGS

computer vision
Submit your own package