Benutzer mit den meisten Antworten
WebCam-Capture

Frage
-
Hallo zusammen,
Wpf-Anwendung in VB.NET
ich lade in meiner Anwendung das Live-Bild der WebCam in eine PictureBox. Problem dabei ist, dass,...
a) das Live-Bild nicht in der kompletten PictureBox zu sehen ist
und
b) dass ich Das Live Bild nicht Speichern kann. Es wird zwar etwas gespeichert aber nur weiß....
Kann mir hier jemand weiter helfen wie ich diese Probleme löse?
Mfg Robert
Imports System.Windows.Forms Public Class Testfenster Public videoHandle As IntPtr Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Const EM_LINEFROMCHAR As Integer = &HC9 Const EM_LINEINDEX As Integer = &HBB Private Declare Auto Function capCreateCaptureWindow 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 Integer, ByVal hWndParent As IntPtr, ByVal nID As Integer) As IntPtr Private Const WS_CHILD As Integer = &H40000000 Private Const WS_VISIBLE As Integer = &H10000000 Private Const WM_USER As Short = &H400S Private Const WM_CAP_START As Short = &H400S Private Const WM_CAP_EDIT_COPY As Integer = (WM_CAP_START + 30) Private Const WM_CAP_DRIVER_CONNECT As Integer = (WM_CAP_START + 10) Private Const WM_CAP_SET_PREVIEWRATE As Integer = (WM_CAP_START + 52) Private Const WM_CAP_SET_OVERLAY As Integer = (WM_CAP_START + 51) Private Const WM_CAP_SET_PREVIEW As Integer = (WM_CAP_START + 50) Private Const WM_CAP_DRIVER_DISCONNECT As Integer = (WM_CAP_START + 11) Public Function CreateCaptureWindow(ByRef hWndParent As IntPtr, Optional ByRef x As Integer = 0, Optional ByRef y As Integer = 0, Optional ByRef nWidth As Integer = 320, Optional ByRef nHeight As Integer = 240, Optional ByRef nCameraID As Integer = 0) As IntPtr Dim previewHandle As IntPtr previewHandle = capCreateCaptureWindow("Video", WS_CHILD + WS_VISIBLE, x, y, nWidth, nHeight, hWndParent, 1) SendMessage(previewHandle, WM_CAP_DRIVER_CONNECT, nCameraID, 0) SendMessage(previewHandle, WM_CAP_SET_PREVIEWRATE, 30, 0) SendMessage(previewHandle, WM_CAP_SET_OVERLAY, 1, 0) SendMessage(previewHandle, WM_CAP_SET_PREVIEW, 1, 0) Return previewHandle End Function Public Function CapturePicture(ByRef nCaptureHandle As IntPtr) As System.Drawing.Image My.Computer.Clipboard.Clear() SendMessage(nCaptureHandle, WM_CAP_EDIT_COPY, 0, 0) Return My.Computer.Clipboard.GetImage End Function Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load videoHandle = Me.CreateCaptureWindow(Me.PictureBox1.Handle, , , 320, 240) PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Close() End Sub PrivateSub Button_Click(ByVal sender as system.Object, byval e as System.EventArgs) Handles Button.Click Dim FotoSave as Bitmap(1600, 1200) PictureBox.FrawToBitmap(FotoSave, New rectangle(0, 0, FotoSave.Wifth, FotoSave.Height)) FotoSave.Save("Pfad") End Sub
Antworten
-
Habe es geschafft....
- Als Antwort markiert Ionut DumaModerator Montag, 24. Februar 2014 12:56
Alle Antworten
-
Habe einen der Fehler nun beseitigt. Allerdings fehlt mir noch immer die Speicherfunktion. Da komme ich nicht wirklich weiter.... Entweder wird mir das Foto komplett schwarz gespeichert, bei einer anderen Variante komplett weiß.
Bitte um Hilfe!!!!
-
Habe es geschafft....
- Als Antwort markiert Ionut DumaModerator Montag, 24. Februar 2014 12:56