Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenFaceOffline.exe crashes when trying to open webcam #506

Open
SilentSin opened this issue Jul 3, 2018 · 8 comments
Open

OpenFaceOffline.exe crashes when trying to open webcam #506

SilentSin opened this issue Jul 3, 2018 · 8 comments

Comments

@SilentSin
Copy link

I just downloaded the latest executables (OpenFace_2.0.3_win_x64.zip) from https://github.com/TadasBaltrusaitis/OpenFace/releases and it works fine with a video file but I can't get it to work with a webcam. When I go to File/Open Webcam it opens another window that says "Loading Webcams" then crashes after a few seconds.

Compiling it from source and running inside VS in Debug mode gives the following exception:

System.ArgumentException: 'Value does not fall within the expected range.'

In OpenCVWrappers.h at line 230

The line is return gcnew WriteableBitmap(Width, Height, 72, 72, Format, nullptr);

Width and Height are 0 and Format is Gray8

I'm using Windows 10 with an Intel RealSense D435 camera in case it matters.

@SilentSin
Copy link
Author

If I try File/Open Webcam without the webcam plugged in, it shows a "No cameras detected" dialog box.

Then if I do it again, it shows the same dialog ... then crashes (It shows the Windows dialog "OpenFaceOffline has stopped working") with the following exception:

System.InvalidOperationException: 'Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.'

In MainWindow.xaml.cs as line 875.

The line is cam_sec.Visibility = System.Windows.Visibility.Visible;

@TadasBaltrusaitis
Copy link
Owner

For the first part of the issue:

  • Is the RealSense camera a depth camera or does it also have an RGB module? OpenFace works with visible light (RGB) cameras only, I haven't tested it with a RealSense camera before.
  • The second issue sounds like a bug, I will try reproducing it and fixing it, thanks for reporting it

@SilentSin
Copy link
Author

The RealSense camera has both depth and RGB. When I list the webcam devices in Unity they each show up as a separate device.

I seem to have fixed it by going to CameraSelection.xaml.cs line 63 and adding:

if (s.Item4.Width == 0 || s.Item4.Height == 0)
    continue;

to the start of the foreach loop so it skips over the depth camera which I'm assuming was failing to give its width and height for whatever reason.

Should I still be incrementing the i variable to match the device index? I can't tell if this would screw up when there are more webcams after the skipped one.

@TadasBaltrusaitis
Copy link
Owner

Thanks for the update, I will investigate this further with a multi-camera setup.

@PhilGauthier
Copy link

Hi,
I got the same issue off the demos program crashing when searching for webcams. From a video file it works. At first i had several built-in, I disabled them to have a single one, and tryed several webcams models (Logitech, Microsoft). I tried deleting the generated camera_list.xml also to make sure he was searching one and it looks suspicious :
<?xml version="1.0"?> <opencv_storage> <cameras> <_><name>"NewTek NDI Video"</name> <resolutions> <_><res>"320x240"</res></_> <_><res>"640x480"</res></_> <_><res>"-1x-1"</res></_></resolutions></_> <_><name>"Microsoft LifeCam VX-5000"</name> <resolutions> <_><res>"1920x1080"</res></_> <_><res>"-1x-1"</res></_></resolutions></_></cameras> </opencv_storage>
I'm on windows 10 and OpenFace_2.2.0_win_x64.

@TadasBaltrusaitis
Copy link
Owner

Thanks, interestingly it seems to be listing negative values for resolutions. Annoyingly, I can't seem to reproduce the issue my end, but the negative values might provide a hint of what's going wrong.

@PhilGauthier
Copy link

If I do gui/OpenFaceOffline/UI_items/CameraSelection.xaml.cs:43

// Finding the cameras here
if (cams == null)
{
	String root = AppDomain.CurrentDomain.BaseDirectory;
	//cams = CameraInterop.Capture.GetCameras(root);
	List<Tuple<int, String, List<Tuple<int, int>>, OpenCVWrappers.RawImage>> camsTmp;
	camsTmp = UtilitiesOF.SequenceReader.GetCameras(root);
	cams = new List<Tuple<int, String, List<Tuple<int, int>>, OpenCVWrappers.RawImage>>();
	foreach (var s in camsTmp)
	{                   
		if ( s.Item4.Width > 0 && s.Item4.Height > 0)
			cams.Add(s);
	}
} 

It works

@TadasBaltrusaitis
Copy link
Owner

Thanks for the fix, I'll include it in the next version

PhilGauthier added a commit to isir/OpenFace that referenced this issue Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants