Seite 1 von 2

Webcam

Verfasst: 27.03.2006 19:15
von pjanfred
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)?

Verfasst: 27.03.2006 19:19
von roherter
http://www.purearea.net/pb/download/userlibs/Avicap.zip

Ist aber für 3.94 ,muste mal testen ich habe damit noch nicht gearbeitet!

Verfasst: 27.03.2006 20:16
von pjanfred
Danke aber wenn noch jemad ne andere Möglichkeit kennt dan were ich ihm dafü dankbar, denn es gibt nur Fehler. :bounce:

Verfasst: 27.03.2006 20:40
von super_castle
in pur 3.94 erstellt und mit der "avicap32.dll" im systemwindowsverzeichnis.
die capture.pb lädt die inc.pb und ab geht die post.
mit dem button schnapp kannste dann ein standbild rechts neben dem videobild darstellen.

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


Verfasst: 28.03.2006 13:21
von pjanfred
Danke hört sich gut aber woher kriege ich die Datei inc.pb
*Ich weis ich ich bin schlecht*

Verfasst: 28.03.2006 13:30
von DrShrek
Sieh im Code genau nach...inc.pb geht los ab: "inc.pb"

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 

Danke

Verfasst: 28.03.2006 13:36
von pjanfred
Danke, könnt ihr mir erkären wie man die Aktuallisirungsgeschwindigkeit vergrößert. Und wie man das Foto Speichert.

Verfasst: 30.03.2006 17:37
von Falko

Code: Alles auswählen

SendMessage_(hRobby, #WM_CAP_EDIT_COPY   ,0,0); kopiert Bild ins Clipboard
Danach kannste mit PB und aus der Hilfe der Clipboard-Funktionen dein Bild speichern.

MfG Falko

Verfasst: 30.03.2006 17:52
von pjanfred
Super Danke

Verfasst: 31.03.2006 19:01
von myself
gibts auch eine möglichkeit ohne Avicap32.dll?