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.
3 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.

- 5,237
- 7
- 42
- 52
-
@Nate hi nate is there any possiblity to share your code. i amtrying to do sth similar – Flood Gravemind Dec 30 '14 at 03:49
-
@FloodGravemind sorry it's been so long I no longer have access to that code. – Nate Dec 31 '14 at 19:56
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

- 9,643
- 6
- 61
- 108
I am not familiar with Mono or C# on linux, but you may have to write an interface module that exposes the diver API, or a reasonable abstraction. I think you then might be able to import the module in the C# code. It looks like Mono does support the DLLImport.

- 5,777
- 7
- 30
- 36