Capturing a Webcam Image using VB.Net
Posted on 2011-02-21
I have VB.Net application that captures an image from a webcam. I have used the following code for a number years without an issue:
hWnd = capCreateCaptureWindowA("USB Camera", WS_VISIBLE Or WS_CHILD, 0, 0, 0, _
0, pbCtrl.Handle.ToInt32, 0)
If SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, CamSource, 0) Then
SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
Blar Blar Blar................
'--error connecting to video source---
However moving to Windows 7 .Net 3.5 when 'SendMessage' is issued to open the 'CamSource' the dialogue 'Capture Source' - 'Select a Video Device' - 'USB Camera' appears. What I ever do in response to this dialogue the webcam doesn't open.
I have resolved this issue in the past by upgrading the Bison drivers to the latest version (from the version that came with Win 7 32 bit). I installed Win 7 32 bit on the PC and the Bison drivers where installed by default.
The problem I now have is on a tablet - running Win 7 32 bit. The built in webcam uses the 'USBVideo.sys' driver.
I have tried to use the Bison drivers - but can't change the driver from 'USBVideo.sys' (I am not too sure that would solve the problem - I just know the Bison drivers work fine) i.e. I uninstall, disable, kill the webcam - but as soon as it is available to Win 7 - then USBVideo.sys drivers are installed.
I think the problem is that another process (I can't see what the process this could be) already has the webcam 'locked' i.e. it can't be shared.
So at this point in time I am stuffed! Thoughts and solutions much appreciated.