Skip to content

christianbator/mosaic

Repository files navigation

Mosaic Logo

An open source computer vision library in Mojo

Language Badge GitHub License Badge CodeQL

OverviewInstallationExamples

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

  • Magic (the Mojo environment and package manager)

Using the magic cli

magic add mosaic

After installation

The mojoproject.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
magic run build

Running an example

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

cd examples
magic 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

Releases

No releases published