I attached my webcam to the USB port and found it working with XawTV which told me that the resolution of it is 320*240 at RGB24.
I also knew that somehow Video4Linux uses a Video device called /dev/video0 for my Webcam. With this information I started hacking, and believe it or not I had a blurred Image after 3 minutes, some tinkering brought me a clear image and after another 4 minutes I got moving images working.
Here is my rough, non optimized testprogram:
Code: Select all
OpenFile(1,"/dev/video0")
If OpenWindow(0, 100, 100, 300, 300, "PureBasic - Image")
CreateImage(0, 320, 240)
CreateGadgetList(WindowID(0))
ImageGadget(0, 10, 10, 200, 200, ImageID(0))
Repeat
Gosub Draw
SetGadgetState(0, ImageID(0))
EventID = WindowEvent()
Delay(1)
Until EventID = #PB_Event_CloseWindow
EndIf
End
Draw:
If StartDrawing(ImageOutput(0))
For x=1 To 240
For y=1 To 320
Plot(y,x,RGB(ReadByte(1),ReadByte(1),ReadByte(1)))
Next
Next
StopDrawing()
EndIf
Return


