Publié : sam. 25/déc./2004 14:36
j'ai trouvé ce code sur le forum anglais ... mais ça marche toujours pas chez moi
Code : Tout sélectionner
Procedure VideoStreamCallback (lwnd.l, lpVHdr.l)
LoadSound(1,"c:\program files\purebasic\No touch\lazer.wav")
iCamVideoStreamCallback(lwnd.l,lpVHdr.l)
iCamGetMotion()
ImageID=iCamGetWebcamImageID()
;MotionZones return #true or #false
Pushed=iCamCheckMotionZone(@CheckZone)
Pushed2=iCamCheckMotionZone(@NewZone(0))
; Draw the webcam image
StartDrawing(ScreenOutput())
DrawImage(ImageID,0,0,800,600)
StopDrawing()
FlipBuffers()
ClearScreen(0,0,0)
EndProcedure
If iCamInitLibrary()
; This address will contain 1 when users hits Escape to exit
iCamSetDisconnectAddress(@Quit.b)
; Use CPU intensive mode
iCamCPUMode(1)
; Init capture and open select driver window
If iCamInitCapture(0)
; Gets the width and height of webcam image
; and set Screen design To resize Check Zones automaticly
iCamGetCapSize(@CapSize)
GameDesignWidth=176 : GameDesignHeight=144
GamePlayWidth=CapSize\Width*Zoom : GamePlayHeight=CapSize\Height*Zoom
iCamScreenDesign(GameDesignWidth,GameDesignHeight)
If OpenWindow(1,100,100,CapSize\Width*Zoom,CapSize\Height*Zoom,0,"iCamPlay zone check example")
OpenWindowedScreen(WindowID(),0,0,CapSize\Width*Zoom,CapSize\Height*Zoom,0,0,0)
; Enable mirror mode
iCamSetMirror(#True)
;
; Set motion detection options
MotionDetection\MotionState=#True
MotionDetection\MotionTrackingValue=50
MotionDetection\MotionLimited=#False
iCamSetMotionDetection(@MotionDetection)
; Set motion divisor
iCamMotionDivisor(2)
LoadGraphics();Graphics.pb
; Set video stream callback procedure address
iCamSetCallbackAddress(@VideoStreamCallback())
Repeat
Event= WaitWindowEvent()
Until Quit=1
; Set callback address as NULL
iCamSetCallbackAddress(#NULL)
; Close capture driver
iCamClose()
CloseWindow(0)
EndIf
EndIf
EndIf