Access "webcams" that don't show up in device manager as imaging devices

0

I've got some code (Winforms, C#, .Net 4) that uses the Directshow.Net library. I've run into a problem 2 times now where a device has a "webcam" but it doesn't show up in Device Manager as an imaging device, but as something else. When that happens the DirectShow.Net either doesn't recognize it, or recognizes it enough to work with it some, but if I try and capture the video it blows up. This most recently happened on a Microsoft Surface Pro 4, running Windows 10. Anyone have any ideas about this? Why is it happening or how to get around it? Hardware interface isn't my specialty and this is my only product code that deals with a direct hardware interface.

Answers can be in VB or C# (or any other language).

Thanks

Edit: I believe the error is happening from this line of code (from the DirectShow.Net library), full function call further down:

hr = m_VidControl.SetMode(m_pinStill, VideoControlFlags.Trigger);

I'm having trouble nailing this down since I don't have access to develop on a device that has a webcam that isn't actually a webcam

The error returned is

System.Runtime.InteropServices.COMException (0x80070032): The request is not supported.
   at DirectShowLib.DsError.ThrowExceptionForHR(Int32 hr)

Full function code:

public IntPtr Click()

    {
        int hr;

        // get ready to wait for new image
        m_PictureReady.Reset();
        m_ipBuffer = Marshal.AllocCoTaskMem(Math.Abs(m_stride) * m_videoHeight);

        try
        {
            m_WantOne = true;

            // If we are using a still pin, ask for a picture
            if (m_VidControl != null)
            {
                // Tell the camera to send an image
                hr = m_VidControl.SetMode(m_pinStill, VideoControlFlags.Trigger);
                DsError.ThrowExceptionForHR(hr);
            }

            // Start waiting
            if (!m_PictureReady.WaitOne(9000, false))
            {
                throw new Exception("Timeout waiting to get picture");
            }
        }
        catch
        {
            Marshal.FreeCoTaskMem(m_ipBuffer);
            m_ipBuffer = IntPtr.Zero;
            throw;
        }

        // Got one
        return m_ipBuffer;
    }
c#
.net-4.0
webcam
hardware-interface
webcam-capture
asked on Stack Overflow Feb 19, 2016 by Benji • edited Feb 19, 2016 by Mad Physicist

1 Answer

0

Turns out the problem was really in a different section of my code. I had used an example from the DirectShow.Net page on connecting to webcams and it was looking for the still pin on a cam. None of the cams I had reported a still pin that functioned correctly so I commented that out. They would then go on and use the tee to do everything. These cams were reporting a still and a preview pin and I hadn't set things up right. I just removed the pins and use the tee for everything.

answered on Stack Overflow Feb 25, 2016 by Benji

User contributions licensed under CC BY-SA 3.0