Ciao a tutti, sto facendo un applicativo (framework 4) che si interfaccia con la webcam, e per fare questo uso la libreria avicap32.dll.
Sostanzialmente, questo è il codice che uso:
Se compilo il tutto mettendo come piattaforma AnyCPU, la cam si interfaccia e si vede, mentre se compilo mettendo x86, la cam si interfaccia (vedo il led di online) ma non si vede la trasmissione video (la picturebox rimane nera). Non ci sono messaggi di errore o altro...codice:Private Const WM_CAP As Short = &H400S Private Const WM_USER As Long = &H400 Private Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10 Private Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50 Private Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52 Private Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53 Private Const WS_CHILD As Integer = &H40000000 Private Const WS_VISIBLE As Integer = &H10000000 Private Const SWP_NOMOVE As Short = &H2S Private Const SWP_NOSIZE As Short = 1 Private Const SWP_NOZORDER As Short = &H4S Private Const HWND_BOTTOM As Short = 1 Public Sub StartCam() hWnd = capCreateCaptureWindowA("Webcam", WS_VISIBLE Or WS_CHILD, 0, 0, 320, 240, picWebCam.Handle.ToInt32, 0) If SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, 0, 0) Then SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0) SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 33, 0) SendMessage(hWnd, WM_CAP_SET_PREVIEW, 1, 0) SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 320, 240, SWP_NOMOVE Or SWP_NOZORDER) Else DestroyWindow(hWnd) End If End Sub
Secondo voi, da cosa potrebbe dipendere?

Rispondi quotando