Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture from webcam in Linux using Mono?

How can I capture a frame from a video-4-linux device (e.g.: /dev/video0) using Mono and C#? OS is Angstrom Linux running on BeagleBoard.

like image 637
Cihan Keser Avatar asked Feb 26 '23 09:02

Cihan Keser


2 Answers

I have done v4l2 capture using C. This is probably the only language I would chose to do it in as well. There are a lot of low level calls you need to make into the driver. You need to map kernel memory into your app and copy buffers. You also have to set a ton of configuration for the device. If you need to I would consider writing a C library and using Platform Invoke. Another alternative is to write two programs and send the data over to your C# app via some sort of IPC.

like image 87
Nate Avatar answered Mar 06 '23 20:03

Nate


You can use Emgu CV for this, it specifically advertises that it can be compiled using Mono.

Main Site: http://www.emgu.com/wiki/index.php/Main_Page
Compiling in Mono: http://www.emgu.com/wiki/index.php/Compiling_with_Monodevelop
Sample Code for Capturing Webcam Video: http://www.emgu.com/wiki/index.php/Camera_Capture_in_7_lines_of_code

like image 31
Peter Avatar answered Mar 06 '23 19:03

Peter