First off, I know the title sounds as n00b as can be but I truly hope that my problem is that I am doing something incredibly n00b and that THAT is the only reason why I am struggling so much... Allow me to explain the situation
Here is what I want to do:
1. View my WebCam stream inside of Unity (Using WebCamTexture or AForge, don't care as long as I can get to the next point....)
2. Detect the shutter was pressed and then save a screenshot
That's it.
So I look at the included demo and it looks easy as can be. I run the demo and it works perfectly. The only improvement I could ask for is a better camera so the image looks better. It just works and it works great so I am excited. So I import the AForge dlls into Unity and I import the System.Windows.Forms and System.Drawing DLLs into Unity so it can stop complaining about that... and now I am ready to get started. So to start I copy paste the code from that demo that works so perfectly and... sorry, no devices found. The end. I can go no further.
Unity has said explicitly that the System.Windows.Forms DLL is NOT supported so I thought that must be it... AForge is simply not compatible with Unity... and yet I read on here that others are using it with Unity so then it means the problem must be me... If I take the working code and copy paste it into my project and it doesn't work then surely I must be doing something wrong... but what?
Can someone please point out my mistake(s) for me... please?
Here is what I am trying to do and where I am failing hard:
- Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AForge.Video;
using AForge.Video.DirectShow;
using System.Runtime.InteropServices;
public class AudioManagerTest : MonoBehaviour {
private FilterInfoCollection videoDevices;
private VideoCaptureDevice videoDevice;
private VideoCapabilities[] videoCapabilities;
private VideoCapabilities[] snapshotCapabilities;
AForge.Controls.VideoSourcePlayer videoSourcePlayer;
public List<string> DevicesCombo { get; private set; }
public List<string> VideoResolutionsCombo { get; private set; }
public List<string> SnapshotResolutionsCombo { get; private set; }
public bool IsConnected { get; set; }
public bool CanTakeScreenShot { get { return IsConnected && (snapshotCapabilities.Length != 0); } }
public int SelectedVideoResolution { get; set; }
public int SelectedCaptureResolution { get; set; }
// Use this for initialization
void Start () {
DevicesCombo = new List<string>();
VideoResolutionsCombo = new List<string>();
SnapshotResolutionsCombo = new List<string>();
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (videoDevices.Count != 0)
{
// add all devices to combo
foreach (FilterInfo device in videoDevices)
{
DevicesCombo.Add(device.Name);
}
videoSourcePlayer = new AForge.Controls.VideoSourcePlayer();
Debug.LogError("Found " +videoDevices.Count);
}
else
{
DevicesCombo.Add("No DirectShow devices found");
Debug.LogError("None found");
}
}
I am always receiving "None found".
Why?
Thanks in advance