Set capture device EmguCV

后端 未结 2 1042
野趣味
野趣味 2021-01-03 08:44

I´m using class Capture from EmguCV to take images from a WebCam.

According to the documentation of the class (http://www.emgu.com/wiki/files/2.0.0.0/h

2条回答
  •  一向
    一向 (楼主)
    2021-01-03 09:13

    The capture object can be used to give static files as input using the following code

     Capture grabber = new Emgu.CV.Capture(@".\..\..\file.avi");//can be relative path or absolute path of the video file.
    

    For finding the list of connected web cams will need to import something like Direct Show (DirectShow.Net.dll) into the project and use the following code to retrieve the list of connected web cams .

        DsDevice[] _SystemCamereas = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
        Video_Device[] WebCams = new Video_Device[_SystemCamereas.Length];
            for (int i = 0; i < _SystemCamereas.Length; i++)
            {
                WebCams[i] = new Video_Device(i, _SystemCamereas[i].Name, _SystemCamereas[i].ClassID); //fill web cam array
                Camera_Selection.Items.Add(WebCams[i].ToString());
            }
    

    Check this link for the full code http://www.emgu.com/wiki/index.php?title=Camera_Capture

    This list can be populated into a combo box and each connected device can be chosen to retrieve the video input from the specific device.

    Example can be found here: http://fewtutorials.bravesites.com/entries/emgu-cv-c/level-2---use-multiple-cameras-in-one-application.

    For your last question the Default Camera always has the index of 0. So for initializing the Capture Object with default camera you will have to use the following code

    Capture grabber = new Emgu.CV.Capture(0);
    

提交回复
热议问题