jacobbo / WebEye

WebEye is a collection of .NET controls.
190 stars 132 forks source link

Not able to start camera when window is loaded #2

Closed redaz808 closed 9 years ago

redaz808 commented 9 years ago

When I start automatically the webcamdevice when the screen is loaded , I get an exception. If I use the same code to start the camera only when I click the button, it works!

    private void InitializeComboBox()
    {
        comboBox.ItemsSource = webCameraControl.GetVideoCaptureDevices();

        if (comboBox.Items.Count > 0)
        {
            comboBox.SelectedItem = comboBox.Items[0];

            var cameraId = (WebCameraId)comboBox.SelectedItem;
            List<WebCameraId> cameras = new List<WebCameraId>(webCameraControl.GetVideoCaptureDevices());
            webCameraControl.StartCapture(cameras[0]);
        }    
    }

When the code jumps to InitializeCaptureGraph, the program crashes and I get an error "Failed to add a video capture filter" Any idea how I can make it work?

Thanks,

jacobbo commented 9 years ago

Hi there,

Are you sure your screen is completely loaded? The thing is that the control requires a created window in order to start a video stream.

Regards, Alexander

On Monday, September 14, 2015, redaz808 notifications@github.com wrote:

When I start automatically the webcamdevice when the screen is loaded , I get an exception. If I use the same code to start the camera only when I click the button, it works!

private void InitializeComboBox()
{
    comboBox.ItemsSource = webCameraControl.GetVideoCaptureDevices();

    if (comboBox.Items.Count > 0)
    {
        comboBox.SelectedItem = comboBox.Items[0];

        var cameraId = (WebCameraId)comboBox.SelectedItem;
        List<WebCameraId> cameras = new List<WebCameraId>(webCameraControl.GetVideoCaptureDevices());
        webCameraControl.StartCapture(cameras[0]);
    }
}

When the code jumps to InitializeCaptureGraph, the program crashes and I get an error "Failed to add a video capture filter" Any idea how I can make it work?

Thanks,

— Reply to this email directly or view it on GitHub https://github.com/jacobbo/WebEye/issues/2.

redaz808 commented 9 years ago

Thank you for the prompt reply!!

You are right and now it works on the loaded event.

Thank you!!