Click here to Skip to main content
15,917,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Visual Basic 2010. Trying to reliably capture webcam images. It works some times - but about 50% of the time it pops up and asks for the video source. Even after this popup it only works sporatically.

Platform Windows 7 32bit, Vusial Basic 2010

Here is a sample of my code - taken from the examples posted on the web.

VB
Private Sub OpenForm()
       Try

           Dim iHeight As Integer = Privew.Height
           Dim iWidth As Integer = Privew.Width

           '
           ' Open Preview window in picturebox
           '
           hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, _
               480, Privew.Handle.ToInt32, 0)

           '
           ' Connect to device
           '
           If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
               '
               'Set the preview scale
               '
               SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)

               '
               'Set the preview rate in milliseconds
               '
               SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)

               '
               'Start previewing the image from the camera
               '
               SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)

               '
               ' Resize window to fit in picturebox
               '
               SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, Privew.Width, Privew.Height, _
                       SWP_NOMOVE Or SWP_NOZORDER)
           End If
       Catch ex As Exception

       End Try



It only works occasionally - many times asking me for the 'Video Source' before it may or maynot show the image.

if any one know help me
Thanx in Advance
Posted
Updated 21-Jan-17 16:01pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900