NET captures camera video in a way and contrast (how to capture camera videos via. NET)

Source: Internet
Author: User

Wang Xianrong
Objective
As the Windows operating system evolves, the API interface for capturing video is evolving, and Microsoft offers three-generation interfaces for VFW, DirectShow, and Mediafoundation. The VFW has long been replaced by DirectShow, and the latest mediafoundation is supported by Windows Vista and Windows 7. Unfortunately, these interfaces are based on COM technology and are flexible and are not easy to use directly in. Net.
. NET Encapsulation
Foreigners have a lot of live Lei Feng, they dedicate a lot of open source projects, Directshow.net is the package of DirectShow, and Mediafoundation.net is the package of mediafoundation. They can all be found on the http://sourceforge.net. The class libraries after the two packages are basically one by one corresponding to the original COM, and can be used for video capture, but it's not easy to use.
With constant Google search, I think the following class libraries encapsulate video captures well: Directx.capture, OpenCv, EMGUCV, and Aforge.
Directx.capture
Directx.capture is a project published on CodeProject, it is easy to capture video and audio, preview in Windows, and save the results to a file. Examples of using directx.capture are as follows:

Directx.capture

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.
OpenCv
OpenCV The video capture part of VFW and DirectShow is well encapsulated, it is easy to get the content of a frame, and the result can be saved to the video file. Examples of using OpenCV are as follows:

OpenCv

However, OPENCV does not encapsulate the audio capture, which is not possible if you need to record audio at the same time.
It is worth noting that the encapsulation of DirectShow has been implemented since OPENCV 1.1, which is inconsistent with the view that many people on the Web OpenCV using VFW for video capture inefficiency. See the Appendix to this article for an argument about OpenCV using DirectShow.
Emgucv
EMGUCV is the OPENCV in. NET package, inherits the OpenCV fast advantage, and it is more useful. The sample code for using EMGUCV is as follows:

EmgucvCapture Capture = new capture (Param.deviceInfo.Index);
while (! Stop
{
Pbcapture.image = capture. Queryframe (). Bitmap;
lock (lockobject)
{
Stop = stopcapture;
}
}
Capture. Dispose ();

Aforge
Aforge is a pure. NET open source image processing Class library, its video capture class is also based on DirectShow, but more useful, more features, from the use and help look more like Microsoft's class library.

AforgeCaptureaforge= new captureaforge.newframe += new Newframeeventhandler (captureaforge_newframe);
Captureaforge.start ();
// ...
Captureaforge.signaltostop ();
private void Captureaforge_newframe (object sender, Newframeeventargs EventArgs)
{
Pbcapture.image =} /span>

Contrast
After introducing them, let's compare them. They are all based on DirectShow, so the performance is almost the same. In fact, I personally think that the hardware and driver support used by the camera has a greater impact on performance. My webcam does not have a dedicated driver under Windows 7 and can only use the default driver provided by Microsoft, which is a little worse than WindowsXP.
It is noteworthy that there are several main points:
(1) Only the Directx.capture realizes the capture of the audio;
(2) Only directx.capture can not obtain a single frame image;
(3) The free version of EMGUCV is based on commercial license, while the license of other class libraries is very loose;
(4) Aforge examples and help are better, and more features.

NET captures camera video in a way and contrast (how to capture camera videos via. net) (GO)

Related Article

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.