2 Webcam-Probleme

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

 

BadDeath

Betreff: 2 Webcam-Probleme

BeitragMo, Jul 14, 2008 17:18
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo!

Ich wollte mir einen 3D-Scanner basteln, dessen Idee ich mir von Youtube abgekuckt habe. Dazu benötigt man eine Webcam und - logischerweise - ein wenig Software. Allerdings scheitere ich irgendwie schon an Schritt 1, dem Aufnehmen der Fotos.... Embarassed

Nämlich nutze ich die AviCap32.dll mit einem modifiziertem Beispiel von super_castle hier aus dem Forum. Ich schaffe es das Livebild meiner Kamera anzuzeigen und vorher ein paar Einstellungen vorzunehmen, aber irgendwie nicht das Bild zu speichern.
Meines Wissens speichert man es mit "sendmessage(hwnd, WM_CAP_EDIT_COPY, 0, 0)" in die Zwischenablage um es dann wieder aufzurufen. Um es aus dem Clipboard wieder rauszuholen, nahm ich das HIER.

Damit man nun aber statt des Textes ein Bild bekommt, habe ich für format% "2" eingesetzt, wie ich es in einem VB-Forum fand.

Nun sagt Blitz aber immer "Image does not exists!" und hängt sich auf.... Obwohl im Debugger ein Handle für die Bildvariable TMP angezeigt wird!

Hier mal mein kompletter Code:
Code: [AUSKLAPPEN]
;Fenster-Konstanten
Const BnWindowClose = $F060    ; Close button
Const BnWindowRestore = $F120  ; Restore button
Const BnWindowMaximize = $F030 ; Maximize button
Const BnWindowMinimize = $F020 ; Minimize button
Const BnWindowMove = $F010     ; Move functionality
Const BnWindowSize = $F000     ; Resizing functionality

;Webcam-Konstanten
Const WS_CHILD = $40000000
Const WS_VISIBLE = $10000000
Const SWP_NOMOVE = $2
Const SWP_NOZORDER = $4
Const HWND_BOTTOM = 1
Const WM_USER = $400

Const WM_CAP_START = WM_USER
Const WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1
Const WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2
Const WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3
Const WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4
Const WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5
Const WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6
Const WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7
Const WM_CAP_GET_USER_DATA = WM_CAP_START + 8
Const WM_CAP_SET_USER_DATA = WM_CAP_START + 9

Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
Const WM_CAP_DRIVER_GET_NAME = WM_CAP_START + 12
Const WM_CAP_DRIVER_GET_VERSION = WM_CAP_START + 13
Const WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14

Const WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20
Const WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_START + 21
Const WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22
Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23
Const WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24
Const WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25

Const WM_CAP_EDIT_COPY = WM_CAP_START + 30

Const WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35
Const WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36

Const WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41
Const WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42
Const WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43
Const WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44
Const WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45
Const WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46

Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50
Const WM_CAP_SET_OVERLAY = WM_CAP_START + 51
Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52
Const WM_CAP_SET_SCALE = WM_CAP_START + 53
Const WM_CAP_GET_STATUS = WM_CAP_START + 54
Const WM_CAP_SET_SCROLL = WM_CAP_START + 55

Const WM_CAP_GRAB_FRAME = WM_CAP_START + 60
Const WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61

Const WM_CAP_SEQUENCE = WM_CAP_START + 62
Const WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 63
Const WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64
Const WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65
Const WM_CAP_SET_MCI_DEVICE = WM_CAP_START + 66
Const WM_CAP_GET_MCI_DEVICE = WM_CAP_START + 67
Const WM_CAP_STOP = WM_CAP_START + 68
Const WM_CAP_ABORT = WM_CAP_START + 69

Const WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70
Const WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71
Const WM_CAP_SINGLE_FRAME = WM_CAP_START + 72
Const WM_CAP_PAL_OPEN = WM_CAP_START + 80
Const WM_CAP_PAL_SAVE = WM_CAP_START + 81
Const WM_CAP_PAL_PASTE = WM_CAP_START + 82
Const WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83
Const WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84


Const cb_Bitmap = 2



;////////////////////////////////////////////////     \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Graphics 640,480,32,2
SetBuffer BackBuffer()
Timer = CreateTimer(60)
AppTitle "Milch-Scanner"
EnableMenuItem (GetSystemMenu (GetActiveWindow(), 0), BnWindowClose,1)

hwndHandle = findWindow_("Blitz Runtime Class", "Milch-Scanner")
hwnd=avi_cap_("Milch-Scanner", WS_CHILD + WS_VISIBLE, 0, 0, 640, 480, hwndHandle, 0)
sendmessage(hwnd, WM_CAP_DRIVER_CONNECT,   0, 0)
sendmessage(hwnd, WM_CAP_DLG_VIDEOSOURCE,  0, 0)
sendmessage(hwnd, WM_CAP_DLG_VIDEOFORMAT,  0, 0)

Cls

While Not KeyHit(1)
   Time = MilliSecs()
   sendmessage(hwnd,WM_CAP_GRAB_FRAME, 0 , 0)
   AppTitle "Milch-Scanner  Step 1  MS: " + Str$(MilliSecs() - Time)
   
   If KeyHit(3) Then
      Tmp = 0
      EmptyClipboard
      sendmessage(hwnd, WM_CAP_EDIT_COPY,  0, 0)
      OpenClipboard(hwnd)
      Tmp=GetClipboardData(cb_Bitmap)
      CloseClipboard()
      SaveImage Tmp, "C:\web.bmp"
   End If
   
   WaitTimer Timer
   Flip 0
Wend

AppTitle "Milch-Scanner"
sendmessage(hwnd, WM_CAP_SET_PREVIEW, "Milch-Scanner", 0)
sendmessage(hwnd, WM_CAP_DRIVER_DISCONNECT, "Milch-Scanner", 0)
sendmessage(hwnd, WM_CAP_SET_CALLBACK_ERROR, "Milch-Scanner", 0)
sendmessage(hwnd, WM_CAP_SET_CALLBACK_STATUS, "Milch-Scanner", 0)
sendmessage(hwnd, WM_CAP_SET_CALLBACK_Yield, "Milch-Scanner", 0)
sendmessage(hwnd, WM_CAP_SET_CALLBACK_Frame, "Milch-Scanner", 0)
sendmessage(hwnd, WM_CAP_SET_CALLBACK_VideoStream, "Milch-Scanner", 0)
sendmessage(hwnd, WM_CAP_SET_CALLBACK_WaveStream, "Milch-Scanner", 0)
sendmessage(hwnd, WM_CAP_SET_CALLBACK_CapControl, "Milch-Scanner", 0)
End


Das wäre das erste Problem. Das Zweite ist, dass nach dem Beenden des Programms immer die Meldung "...exe hat einen Fehler festgestellt." Für dieses Problem habe ich nachgeguckt und fand im selben VB-Forum, dass man das Gerät wieder freigeben muss, wozu ich auch die letzten 9 Zeilen anhing, doch das brachte auch nichts. Würde man das ganze mit einem Klick auf das X beenden wollen, würde sich das Programm aufhängen, weshalb ich diesen Button deaktivierte.

So, wurde nun etwas länger als gedacht, hoffentlich könnt ihr mir noch folgen... Würde mich freuen, wenn jemand Rat weiß, zumindest für das erste Problem.

PS: Hier noch schnell die DECLS:
Zitat:
.lib "avicap32.dll"
avi_cap_% ( t1$, w1%, w2%, w3%, w4%, w5%, w6%,w7%):"capCreateCaptureWindowA"


Zitat:
.lib "User32.dll"
GetCursorPos%( point* )
GetWindowRect%( hwnd%, rect* )
OpenClipboard%(hwnd%):"OpenClipboard"
CloseClipboard%():"CloseClipboard"
ExamineClipboard%(format%):"IsClipboardFormatAvailable"
EmptyClipboard%():"EmptyClipboard"
GetClipboardData%(format%):"GetClipboardData"
SetClipboardData%(format%,txt$):"SetClipboardData"
sendmessage%(w1%,w2%,w3%,w4%):"SendMessageA"
findwindow_% (t1$, t2$) : "FindWindowA"
....

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group