Cihan Keser
Cihan Keser

Reputation: 3261

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.

Upvotes: 4

Views: 7621

Answers (3)

Peter
Peter

Reputation: 9712

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

Upvotes: 3

Nate
Nate

Reputation: 5407

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.

Upvotes: 5

simon
simon

Reputation: 5935

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.

(http://www.mono-project.com/Interop_with_Native_Libraries)

Upvotes: 0

Related Questions