Hi,
I'm working on a game that needs to take picture with a webcam and then do some image analysis to determine the position of tokens.
For that I made a c# dll that use AForge library to detect webcam and do the analysis. It works when I try it on a c# application, but when I integrate the DLL in my game in Unity, it won't detect any webcam.
I built my dll and each dll of AForge in framework 3.5 x86.
Here the code that should find the webcam:
// Code update
// enumerate video devices
FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
// create video source
LogFile.Instance.Log("Count" + videoDevices.Count);
_findCamera = false;
for (int i = 0; i < videoDevices.Count; i++)
{
LogFile.Instance.Log(videoDevices[i].Name.Trim());
if (videoDevices[i].Name.Trim() == CAM_NAME/*true*/) // Set "true" for tests with other camera.
{
_videoSource = new VideoCaptureDevice(videoDevices[i].MonikerString);
_findCamera = true;
}
}
if (_findCamera == false)
{
return;
}
While running in Unity, the videoDevices.count is 0.
I found a post that says that it won’t work, but it was said in 2011. Directshow seemed not to be supported.I hope there is a way now. http://forum.unity3d.com/threads/76860-C-script
By the way, I have no error message. Just that the program can't find the webcam.
Thank you for your help.
↧