Webcam
Verfasst: 27.03.2006 19:15
Hallo hat jemand einen Code mit dem man eine Webcam ausuchen kann die man am PC angeschlossen hat und dann das derzeit Aktuelle Bild Anzeigen kann.(eventuel Film Foto drehen)?
Code: Alles auswählen
"capture.pb"
; PureBasic Visual Designer v3.92 build 1460
IncludeFile "inc.pb"
#WM_CAP_START = #WM_USER
#WM_CAP_SET_CALLBACK_ERROR = #WM_CAP_START + 2
#WM_CAP_SET_CALLBACK_STATUS = #WM_CAP_START + 3
#WM_CAP_SET_CALLBACK_YIELD = #WM_CAP_START + 4
#WM_CAP_SET_CALLBACK_FRAME = #WM_CAP_START + 5
#WM_CAP_SET_CALLBACK_VIDEOSTREAM = #WM_CAP_START + 6
#WM_CAP_SET_CALLBACK_WAVESTREAM = #WM_CAP_START + 7
#WM_CAP_DRIVER_CONNECT = #WM_CAP_START + 10
#WM_CAP_DRIVER_DISCONNECT = #WM_CAP_START + 11
#WM_CAP_DRIVER_GET_CAPS = #WM_CAP_START + 14
#WM_CAP_DLG_VIDEOFORMAT = #WM_CAP_START + 41
#WM_CAP_DLG_VIDEOSOURCE = #WM_CAP_START + 42
#WM_CAP_DLG_VIDEODISPLAY = #WM_CAP_START + 43
#WM_CAP_SET_PREVIEW = #WM_CAP_START + 50
#WM_CAP_SET_PREVIEWRATE = #WM_CAP_START + 52
#WM_CAP_GET_STATUS = #WM_CAP_START + 54
#WM_CAP_FILE_SAVEDIB = #WM_CAP_START + 25
#WM_CAP_SET_SCALE = #WM_CAP_START + 53
#WM_CAP_SET_CALLBACK_CAPCONTROL = #WM_CAP_START + 85
#WM_CAP_EDIT_COPY = #WM_CAP_START + 30
#WM_CAP_GRAB_FRAME = #WM_CAP_START+60
Open_Window_0()
OpenLibrary(0, "AVICAP32.DLL")
hRobby = CallFunction(0, "capCreateCaptureWindowA", "Test", #WS_VISIBLE + #WS_CHILD, 100, 10, 300, 280, hWnd, 0)
SendMessage_(hRobby, #WM_CAP_DRIVER_CONNECT, 0 , 0)
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindowID() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadgetID() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_EventGadget
If GadgetID = #Button_0
Link = GetClipboardData(#PB_ClipboardImage)
If Link <> 0
StartDrawing( WindowOutput() )
DrawImage(Link, 410,10,300, 240)
StopDrawing()
EndIf
EndIf
EndIf
SendMessage_(hRobby, #WM_CAP_GRAB_FRAME, 0 , 0)
SendMessage_(hRobby, #WM_CAP_EDIT_COPY, 0 , 0)
Delay(1)
Until Event = #PB_Event_CloseWindow ; End of the event loop
SendMessage_(hRobby, #WM_CAP_SET_PREVIEW, 0, 0)
SendMessage_(hRobby, #WM_CAP_DRIVER_DISCONNECT, "Test", 0)
CloseWindow(0)
CloseLibrary(0)
End
;
"inc.pb"
;- Window Constants
Global hWnd
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Button_0
EndEnumeration
Procedure Open_Window_0()
hWnd=OpenWindow(#Window_0, 0, 0, 800, 320, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Videocapture")
CreateImage(#Window_0, 710, 320)
If CreateGadgetList(WindowID())
ButtonGadget(#Button_0, 15, 35, 70, 25, "schnapp")
EndIf
EndProcedure
Code: Alles auswählen
;- Window Constants
Global hWnd
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Button_0
EndEnumeration
Procedure Open_Window_0()
hWnd=OpenWindow(#Window_0, 0, 0, 800, 320, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Videocapture")
CreateImage(#Window_0, 710, 320)
If CreateGadgetList(WindowID())
ButtonGadget(#Button_0, 15, 35, 70, 25, "schnapp")
EndIf
EndProcedure
Code: Alles auswählen
SendMessage_(hRobby, #WM_CAP_EDIT_COPY ,0,0); kopiert Bild ins Clipboard