Webcam capture

BlitzMax Forums/BlitzMax Programming/Webcam capture

William Drescher(Posted 2008) [#1]
I know this has been posted before but I would like to know exactly how to capture the image and put it on a Graphics screen instead of the usual capture area thats created.


Derron(Posted 2008) [#2]
If you use the "Escapi.dll" and the blitzmax-examples within the archive you can found in the forums here, you will have a Tpixmap filled with the current webcamdata.

You decide yourself if you draw it or compute something out of the pixeldata.

inside the blitzmax example look for:
' A PixMap for captured data...

Global pix:TPixmap = CreatePixmap (width, height, PF_BGRA8888)



And yes it works, some months ago i made some tests with the library (snapshot a starting picture and calculate differences between this picture and the actual data you receive from the webcam, storing some informations, filtering some distortions like fingers or ears ;D and then compute things like "movement" of arms or your head for moving a ball etc).

PS: don't forget to copy the pixmap because working on the real data could end in corruption:

Function RealPixmapCopy(src:TPixmap, dest:TPixmap)
	Local srcPixelPointer:Int Ptr = Int Ptr(src.PixelPtr(0,0))
    Local srcPixelPointerBackup:Int Ptr = srcPixelPointer
    Local destPixelPointer:Int Ptr = Int Ptr(dest.PixelPtr(0,0))
    Local destPixelPointerBackup:Int Ptr = destPixelPointer
	For Local my_x:Int=0 To ((src.width)*(src.height))
		 destPixelPointer[0] = srcPixelPointer[0]
	     srcPixelPointer:+1
	     destPixelPointer:+1
	     If srcPixelPointer = srcPixelPointer+(src.pitch Shr 2)
	         srcPixelPointerBackup = srcPixelPointer
	     EndIf
	     If destPixelPointer = destPixelPointer+(dest.pitch Shr 2)
	         destPixelPointerBackup =destPixelPointer
	     EndIf
	Next        
End Function


bye MB


Digital Anime(Posted 2008) [#3]
The Escapi.dll works great indeed with different webcams.

Keep in mind that the dll will see all video capture devices and in my case it had some problems with a video capture device on the graphics card (It was seen as device 0 and the webcam as device 1 in that case). The dll is able to get the device name so it's easy to create some kind of config for that.


plash(Posted 2008) [#4]
Reference: http://www.blitzbasic.com/Community/posts.php?topic=66505


William Drescher(Posted 2008) [#5]
Hey, thanks for the help. I really couldn't find anything at all on this when I looked through the forums. I have really been trying to do this for quite a while.