1. romain flechner
  2. RaspberryCam

Wiki

Clone wiki

RaspberryCam / Home

RaspberryCam

RaspberryCam is a Mono/.NET assembly providing access to cameras plugged in your Raspberry Pi.

It is an initiative of the Raspberry# Community, aimed at providing tools and information concerning use of Raspberry Pi boards with Mono/.NET framework. Parts of this work are based on v4l C library and some fswebcam source code functions

First use

This program is based on v4l API and some fswebcam source headers. With RapberryCam, you can take pictures and videos from a webcam pluged in your Raspberry pi. For the moment, the video stream is not a MPEG stream, but just a succession of compressed frames. In the futur version, a real MPEG format should be implemented.

Install .so file

Before trying it in Mono, please copy C sources files on your Rapsberry pi and type:

$sudo make
$sudo make install

Or just copy Lib/RapberryCam.so in /Lib.

Run ServerExample on your Rapsberry pi

mono RaspberryCam.ServerExample.exe

And run RaspberryCam.VideoViewer.exe on your PC

Take a simple picture from C# code

var cameras = Cameras.DeclareDevice()
	.Named("Camera 1").WithDevicePath("/dev/video0")
	.Memorize();

cameras.Get("Camera 1").SavePicture(new PictureSize(640, 480), "Test1.jpg", 20);

//Or

cameras.Default.SavePicture(new PictureSize(640, 480), "Test2.jpg", 20);

//Best practices: cameras should be a single instance in your program

Host a video and pictures server in your application

var videoServer = new TcpVideoServer(8080, cameras);
Console.WriteLine("Server strating ...");
videoServer.Start();
Console.WriteLine("Server strated.");

Download pictures from your Raspberry pi

var videoClient = new TcpVideoClient(serverHostIp, serverPort);
videoClient.StartVideoStreaming(new PictureSize(imageWidth/2, imageHeight/2)); //Open hardware
var data = videoClient.GetVideoFrame(compressionRate); //data contains a simple jpeg frame
videoClient.StopVideoStreaming(); //Close Hardware

Updated