Discussion:
Accessing capture device for built in webcam
(too old to reply)
Steve
2008-04-28 22:31:48 UTC
Permalink
Hi All

I have a VB.net 2005 windows forms application which uses webcam to take
photos of staff members etc for use within the application

All works fine if an external webcam is used

The problem I have is when clients have a laptop with built in webcam

The first time I connect to the capture drivers all works well. If I try to
take a 2nd photo I get the message Capture device does not exist

Any ideas

Regards
Steve
Mathias Wührmann
2008-04-28 22:56:24 UTC
Permalink
Hi Steve,
Post by Steve
The first time I connect to the capture drivers all works well. If I
try to take a 2nd photo I get the message Capture device does not
exist
be sure to free up all the resources and references. Sounds like the
capture driver is still blocked from the first attempt.

Regards,

Mathias Wuehrmann
adrian lewis
2011-11-28 12:40:55 UTC
Permalink
Hi Steve

Did you ever get a solution for this? I have exactly the same problem in that a webcam plugged into the USB port works fine, but the built-in webcam works only once reliably. Occasionally it will work agaian after several retries, but it's very unreliable compared to the 100% reliable external device.

Thanks for any help

Ade
Post by Steve
Hi All
I have a VB.net 2005 windows forms application which uses webcam to take
photos of staff members etc for use within the application
All works fine if an external webcam is used
The problem I have is when clients have a laptop with built in webcam
The first time I connect to the capture drivers all works well. If I try to
take a 2nd photo I get the message Capture device does not exist
Any ideas
Regards
Steve
Post by Mathias Wührmann
Hi Steve,
be sure to free up all the resources and references. Sounds like the
capture driver is still blocked from the first attempt.
Regards,
Mathias Wuehrmann
adrian lewis
2011-12-01 11:47:49 UTC
Permalink
OK I fixed this!

In case anyone stumbles across this looking for a solution ... it seems that there are a few of us having trouble with the built-in webcam (as opposed to externally connected usb webcam).

I noticed that the CAP_DRIVER_CONNECT message returned very quickly with an error, sometimes causing the "select video input device" dialog to appear, but that after several retries it *would* eventually connect. So instead of the single connect attempt shown in all the code examples, I tried looping with a timer, and it now works 100% reliably. Code as below (not elegant, but hey, it works)

Dim connectAttempts as Integer = 0
While Not CBool(SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, 0, Nothing))
connectAttempts += 1
If connectAttempts > 10 Then
DestroyWindow(hHwnd)
Me.Cursor = Cursors.Default
Return False
End If
Threading.Thread.Sleep(1000)
End While
.
. carry on as usual with CAP_SET_PREVIEWRATE etc
.

Hope this helps someone as I was stuck on this for days!

Ade

Loading...