Questo sito utilizza cookies, anche di terze parti, per mostrare pubblicità e servizi in linea con il tuo account. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - [VB.NET] Webcam, Origine video
Forum - C# / VB.NET - [VB.NET] Webcam, Origine video

Avatar
NR2 (Normal User)
Newbie


Messaggi: 18
Iscritto: 26/06/2010

Segnala al moderatore
Postato alle 16:09
Giovedì, 16/08/2012
Salve a tutti.
Ho trovato questo codice su internet per avere un immagine dalla webcam
Codice sorgente - presumibilmente VB.NET

  1. Const WM_CAP As Short = &H400S
  2.     Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
  3.     Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
  4.     Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
  5.     Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
  6.     Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
  7.     Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
  8.     Const WS_CHILD As Integer = &H40000000
  9.     Const WS_VISIBLE As Integer = &H10000000
  10.     Const SWP_NOMOVE As Short = &H2S
  11.     Const SWP_NOSIZE As Short = 1
  12.     Const SWP_NOZORDER As Short = &H4S
  13.     Const HWND_BOTTOM As Short = 1
  14.     Dim iDevice As Integer = 0
  15.     Dim hHwnd As Integer
  16.     Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Object) As Integer
  17.     Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
  18.     Declare Function DestroyWindow Lib "user32" (ByVal hndw As Integer) As Boolean
  19.     Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Short, ByVal hWndParent As Integer, ByVal nID As Integer) As Integer
  20.     Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, ByVal cbVer As Integer) As Boolean
  21.  
  22.  
  23.     Private Sub OpenPreviewWindow()
  24.         Dim iHeight As Integer = PictureBox1.Height
  25.         Dim iWidth As Integer = PictureBox1.Width
  26.         hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, PictureBox1.Handle.ToInt32, 0)
  27.         If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
  28.             SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
  29.             SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
  30.             SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
  31.             SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, PictureBox1.Width, PictureBox1.Height, SWP_NOMOVE Or SWP_NOZORDER)
  32.         Else
  33.             DestroyWindow(hHwnd)
  34.         End If
  35.     End Sub
  36.  
  37.  
  38.     Private Sub ClosePreviewWindow()
  39.         SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0)
  40.         DestroyWindow(hHwnd)
  41.     End Sub


Mi servirebbe per salvare immagini dalle webcam..
Il problema è che dopo la prima volta che riesco a salvare un immagine mi appare una finestra intitolata "Origine video" (Immagine finestra allegata).
Siccome che dopo 3-4 volte che la chiudo, l'applicazione continua a funzionare, volevo sapere se conoscete un modo per non farla aprire...


NR2 ha allegato un file: Origine video.png (22527 bytes)
Clicca qui per guardare l'immagine

Ultima modifica effettuata da NR2 il 16/08/2012 alle 16:11
PM Quote