Quantcast
Channel: Visual Basic Tips and Tricks
Viewing all articles
Browse latest Browse all 2212

webcam e avicap32.dll

$
0
0
Ciao a tutti,

qualcuno di voi gestisce le webcam ??
Mi hanno chiesto di aggiungere questa funzione su di un vecchio programma VB6 per acquisire una immagine da webcam, ho cercato su internet e praticamente ho trovato sempre lo stesso codice sorgente (sia in VB6 sia in VB.NET) ed ecco qui di seguito il cuore della funzione che attiva la telecamera, ma purtroppo sui miei PC portatili funziona perfettamente (sia con Windows 10 sia con windows 8.1) ma quando lo invio ad un paio di clienti mi dicono che appare solo la schermata nera, la telecamera accende il led (quindi qualcosa funziona), ma che il preview non si vede.
Qualcuno sa qualcosa a riguardo ??


Il problema potrebbe essere nella riga seguente ??
SendMessage hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0&

In questo modo ho settato la telecamera con 15 FPS, devo impostarla diversamente ??

Grazie mille
Sergio

Public Sub OpenPreviewWindow(DeviceIndex As Long, picCapture As PictureBox)
    
    iDevice = DeviceIndex
    
    ' Open Preview window in picturebox (  640, 480 )
    hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, picCapture.hwnd, 0)

If hHwnd = 0 Then
    MsgBox "hHwnd = 0 !!", vbCritical
End If

    ' Connect to device
    If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
   
        'Set the preview scale
        SendMessage hHwnd, WM_CAP_SET_SCALE, -1, 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, -1, 0&

        ' Resize window to fit in picturebox
        SetWindowPos hHwnd, HWND_BOTTOM, 0, 0, picCapture.ScaleWidth, picCapture.ScaleHeight, SWP_NOMOVE Or SWP_NOZORDER
      
    Else
        ' Error connecting to device close window
        DestroyWindow hHwnd

     End If

End Sub


Viewing all articles
Browse latest Browse all 2212

Trending Articles


HOY PANGIT, MAGBAYAD KA!


Henry el monstruo feliz para colorear e imprimir


Dama y vagabundo para pintar


Girasoles para colorear


Good Morning Quotes


RE: Mutton Pies (jameskoiman)


Hagibis (1946) by Francisco V. Coching


Ka riam ka beit bad ka por riam


Vimeo Create - Video Maker & Editor 1.6.0 by Vimeo Inc


Vimeo 3.42.1 by Vimeo Inc