Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Microsoft LifeCam HD mjpeg capture

I have a Microsoft LifeCam HD-5000 webcams. According to AMCap, the camera outputs a MJPEG stream at 30fps at 720p. I want to capture each JPEG frame in a small application without doing any preview or decompression/transcoding to minimize CPU utilization to the minimum possible.

I'm a C# developer, but I'm new to DirectShow. Is there a simple way to capture the MJPEG stream frame by frame as its output from the camera in C#/.NET without decompressing it?

like image 238
IraqiGeek Avatar asked Nov 14 '22 07:11

IraqiGeek


1 Answers

First of all, you might not need to use DirectShow to access your camera. Check out the OpenCV project, which has .net bindings available at opencvdotnet.

If you'd like to go the DirectShow route, then you'll need the .NET bindings, available at the directshownet project. I believe your best bet will be to create a filter graph that contains your webcam as a source filter, and a sample grabber as your destination filter. Documentation for the sample grabber is on MSDN. This will give you access to the raw data. You can also request a particular data format and use the DirectShow intelligent connect to fill in the filter graph with the right conversion filters.

That being said, I definitely recommend OpenCV over DirectShow. DirectShow is very general purpose, and probably does more than you need it to do. OpenCV can be used to quickly access your camera. Perhaps check out this stackoverflow question Webcam Usage in C# for some more information and answers.

like image 82
Giawa Avatar answered Dec 15 '22 00:12

Giawa