The way and contrast of capturing camera video in. NET (how to Capture Camera videos via. net)

Source: Internet
Author: User

As the Windows operating system evolves and the API interface for capturing video evolves, Microsoft offers the VFW, DirectShow and Mediafoundation interfaces. VFW has long been replaced by DirectShow, and the latest mediafoundation is supported by Windows Vista and Windows 7. Unfortunately, the above interfaces are based on COM technology and are very flexible and are not easy to use directly in. Net.

. NET Encapsulation

Foreigners have a lot of live Lei Feng, they dedicated a lot of open source projects, Directshow.net is the DirectShow encapsulation, and Mediafoundation.net is the mediafoundation encapsulation. They can all be found on the http://sourceforge.net. The class library after these two packages is basically a relationship with the original COM one by one, and can be used for video capture, but it's not easy to use.

Through constant Google searches, I think the following libraries are good for capturing video capture: Directx.capture, OpenCv, EMGUCV, and Aforge.

Directx.capture

Directx.capture is a project published on CodeProject that can easily capture video and audio, preview the window, and save the results to a file. Examples of using directx.capture are as follows:

Directx.capture

Capture capture = new Capture( Filters.VideoInputDevices [0],
                 Filters.AudioInputDevices[1]  );
capture.Filename = "C:\MyVideo.avi";
capture.Start();
//...
capture.Stop();

However, it does not provide a way to get the contents of a frame separately. If you just need to preview and save the video, it works fine.

OpenCv

OpenCV the VFW and DirectShow video capture part of the good encapsulation, can easily get the content of a frame, you can also save the results to the video file. Examples of using OpenCV are as follows:

OpenCv

IntPtr ptrCapture = CvInvoke.cvCreateCameraCapture (param.deviceInfo.Index);
       while (!stop)
       {
         IntPtr ptrImage = CvInvoke.cvQueryFrame (ptrCapture);
         lock (lockObject)
         {
           stop = stopCapture;
         }
       }
       CvInvoke.cvReleaseCapture(ref ptrCapture);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.