Hi guys,
i'm having a nightmare with an application that is supposed to take a picture with a webcam. There is a 'Start Webcam' button on the form to open the camera to take a picture. Its event is OpenCamera() below:
Private Sub OpenCamera()
Dim iHeight As Integer = picCapture.Height
Dim iWidth As Integer = picCapture.Width
hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, _
480, picCapture.Handle.ToInt32, 0)
If SendMessage(hHwnd, CAP_DRIVER_CONNECT, iDevice, 0) Then
SendMessage(hHwnd, CAP_SET_SCALE, True, 0)
SendMessage(hHwnd, CAP_SET_PREVIEWRATE, 66, 0)
SendMessage(hHwnd, CAP_SET_PREVIEW, True, 0)
SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, picCapture.Width, picCapture.Height, _
SWP_NOMOVE Or SWP_NOZORDER)
Else
DestroyWindow(hHwnd)
End If
End Sub
Then, the form_closing event has the following:
SendMessage(hHwnd, CAP_DRIVER_DISCONNECT, iDevice, 0)
Clipboard.Clear()
DestroyWindow(hHwnd)
This works fine only the first time the form is loaded. Any subsequent time requires pulling out the USB camera and reattaching it.
I've been on this for two weeks now with no solution. Please can anyone help me out here?
Thanx.