Skip to content
Unofficial C# API for the Raspberry Pi camera. Supports Mono 4.x and .NET Standard 2.0
Branch: dev
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Few improvements to annotation. #83. Apr 8, 2019
tests/MMALSharp.Tests
.gitattributes
.gitignore Update README and gitignore Aug 11, 2018
LICENSE.txt
MMALSharp.sln Pass raw data to Bitmap. Nov 21, 2018
NuGet.config
README.md
StyleCop.Analyzers.ruleset
appveyor.yml

README.md

MMALSharp - C#/.NET API for the Raspberry Pi camera

Build status Join the chat at https://gitter.im/MMALSharp/Lobby

MMALSharp is an unofficial C# API for the Raspberry Pi camera. Under the hood, MMALSharp makes use of the native MMAL interface designed by Broadcom.

MMALSharp supports the following runtimes:

  1. Mono 4.x
  2. .NET Standard 2.0

Installation

MMALSharp NuGet package: NuGet version

PM> Install-Package MMALSharp

Basic Examples

Take a JPEG image using YUV420 encoding:

public void TakePicture()
{
    // Singleton initialized lazily. Reference once in your application.
    MMALCamera cam = MMALCamera.Instance;

    using (var imgCaptureHandler = new ImageStreamCaptureHandler("/home/pi/images/", "jpg"))        
    {            
        await cam.TakePicture(imgCaptureHandler, MMALEncoding.JPEG, MMALEncoding.I420);
    }
    
    // Cleanup disposes all unmanaged resources and unloads Broadcom library. To be called when no more processing is to be done
    // on the camera.
    cam.Cleanup();
}

Take a H.264 video using YUV420 encoding at 30 fps:

public void TakeVideo()
{
    // Singleton initialized lazily. Reference once in your application.
    MMALCamera cam = MMALCamera.Instance;

    using (var vidCaptureHandler = new VideoStreamCaptureHandler("/home/pi/videos/", "avi"))        
    {    
        var cts = new CancellationTokenSource(TimeSpan.FromMinutes(3));
                
        await cam.TakeVideo(vidCaptureHandler, cts.Token);
    }   

    // Cleanup disposes all unmanaged resources and unloads Broadcom library. To be called when no more processing is to be done
    // on the camera.
    cam.Cleanup();
}

Documentation

For full installation instructions for Mono 4.x and .NET Core, including configuration and examples - please visit the Wiki site.

License

MIT license

Copyright (c) 2016-2019 Ian Auty

Raspberry Pi is a trademark of the Raspberry Pi Foundation

Special thanks

Dave Jones @waveform80 - your Python header conversions have saved me numerous hours so far. Thank you very much.

Contributors

Daniel Lerch @daniel-lerch

You can’t perform that action at this time.