video capture in blitz ?

Blitz3D Forums/Blitz3D Programming/video capture in blitz ?

Does anybody know how to preview a capture source in Blitz ? I want to connect a common camera to my PCTV capture card and display the input on the background of a 3d application.

does this help?

http://www.blitzbasic.com/Community/posts.php?topic=61763

Yes, it was very helpful. Thanks a lot!
After a few tries, I got this code to run with my webcam. I can't capture onto an image, but it opens an extra window and displays the capture preview on it. In case someone wants to run this, you need the .decls as described at the end of the program:
;-----------------------------------------------------------------------------------------------------
;											Avicap32.dll test
;-----------------------------------------------------------------------------------------------------

Const WM_USER = 1024
Const WS_CHILD = $40000000
Const WS_VISIBLE = $10000000

Const WM_CAP_START = WM_USER
Const WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5
Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
Const WM_CAP_SET_OVERLAY = WM_CAP_START + 51
Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50
Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52
Const WM_CAP_SET_SCALE = WM_CAP_START + 53


;-----------------------------------------------------------------------------------------------------
;													Main Program
;-----------------------------------------------------------------------------------------------------

	Graphics3D 	320, 240, 0, 2
	SetBuffer 	BackBuffer()
	
	;create window
	hWnd		= MakeWindow("capture")
	
	;convert window to capture window
	hWndC		= capCreateCaptureWindow("cap", WS_CHILD + WS_VISIBLE, 0, 0, 320, 240, hWnd, 1)
	
	;connect to capturedriver
	ApiSendMessage 	hWndC, WM_CAP_DRIVER_CONNECT, 0, 0
	;set capturedriver properties
	ApiSendMessage 	hWndC, WM_CAP_SET_SCALE, True, 0
	ApiSendMessage 	hWndC, WM_CAP_SET_PREVIEW, True, 0
	ApiSendMessage 	hWndC, WM_CAP_SET_PREVIEWRATE, 24, 0
	
	Api_SetFocus	SystemProperty$("AppHwnd")
	
;-----------------------------------------------------------------------------------------------------
;													Main Loop
;-----------------------------------------------------------------------------------------------------

While Not KeyHit(1)

 	Cls
 	Text 0, 0, "Please use ESC to end program.."
	Flip
	
Wend

	;disconnect to capturedriver
	ApiSendMessage 	hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0

	;destory child window
	Api_DestroyWindow	hwnd

End




;-------------------------------------------------------------------------------------------------------
;												MakeWindow()
;-------------------------------------------------------------------------------------------------------
;creates a basic window
Function MakeWindow%(name$)

	;create empty bank b
	b = CreateBank(4)
	
	;create child window
	window = api_CreateWindowEx(0, GetBlitzClassName$(), name$, $10000000, 0, 0, 320, 240, 0, 0, 0, b)
	
	;free bank b
	FreeBank b
	
	;show child window	
	api_ShowWindow	window, 1
	
	;return new window handle
	Return window

End Function


;-------------------------------------------------------------------------------------------------------
;										    GetBlitzClassName$()
;-------------------------------------------------------------------------------------------------------
;get blitz class name
Function GetBlitzClassName$()

	;get blitz window handle
	Local hwnd = SystemProperty$("AppHwnd")
	
	;create empty bank p
	p = CreateBank(255)
	
	;get class name via API
	s = api_GetClassName(hwnd, p, 255)
	
	;convert bank to string
	d$ = ""
	For i = 0 To 254
		;read char
		ok = PeekByte(p, i)
		;if char is empty, exit loop
		If ok = 0 Then Exit
		;add to "d$"
		d$ = d$ + Chr$(ok)
	Next
	
	;release bank p	
	FreeBank p
	
	Return d$
	
End Function


;-----------------------------------------------------------------------------------------------------
;insert these files into the \userlibs directory of Blitz
;ie in "C:\PROGRAM FILES\BLITZ3D\USERLIBS"
;-----------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------
;avicap32.decls
;------------------------------------------------------------------------------------------------------
;.lib "Avicap32.dll"
;capCreateCaptureWindow%(lpszWindowName$,dwStyle%,x%,y%,nWidth%,nHeight%,hWnd%,nID%):"capCreateCaptureWindowA"
;------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------
;user32.decls
;------------------------------------------------------------------------------------------------------
;.lib "user32.dll"
;
;apiSendMessage%(hwnd%, wMsg%, wParam%, lParam%) : "SendMessageA"
;api_SetFocus% (hwnd%) : "SetFocus"
;api_DestroyWindow% (hwnd%) : "DestroyWindow"
;api_CreateWindowEx% (dwExStyle%, lpClassName$, lpWindowName$, dwStyle%, x%, y%, nWidth%, nHeight%, hWndParent%, hMenu%, hInstance%, lpParam*) : "CreateWindowExA"
;api_ShowWindow% (hwnd%, nCmdShow%) : "ShowWindow"
;api_GetClassName% (hwnd%, lpClassName*, nMaxCount%) : "GetClassNameA"
;------------------------------------------------------------------------------------------------------

If you want to grab a frame to blitz, use:
Const WM_CAP_EDIT_COPY = WM_CAP_START + 30
ApiSendMessage hWndC, WM_CAP_EDIT_COPY, 0, 0
And use MarkCW's PasteFromClipBoard function.