Afternoon, All.

The attached exe is a proggy that displays an image from a webcam onto a rotating square.
F1 -> F4 are used to select devices 1 -> 4.
Just try one until an image appears.

This is still under testing. Please let me know what problems come up, or if it actually works on your 'puter.

Posted on 2003-05-22 07:25:28 by Scronty
I take it that you use DirectX? I get a Dll error d3d8.dll not found ... just FYI

About to download the SDK though ;)

I've been meaning to do that for a while
Posted on 2003-05-22 07:27:39 by gorshing
There is a cool rotating gray square - I prefer the blue one. :)

My web cam light doesn't come on.
Posted on 2003-05-22 07:29:23 by bitRAKE
Afternoon, gorshing.

"Fasm: DX8.1 Webcam Viewer" means that it requires DX8.1 installed as a minimum:grin: .

Posted on 2003-05-22 07:30:00 by Scronty
hehe /me kicks himself
Posted on 2003-05-22 07:30:46 by gorshing
Afternoon, bitRAKE.

It starts with the grey square (texture == 0).
Only when you press F1/F2/F3/F4 will the proggy try to connect to that device and save a bmp. Then it loads the bmp in as the texture.
My web cam light doesn't come on.

ummm... weird.
The two webcams I've got only have one light on them....and that's to indicate it's switched on.

Posted on 2003-05-22 07:33:46 by Scronty
No picture is saved or displayed.
(Yeah, I hit the F'n keys. :) )
Posted on 2003-05-22 07:56:18 by bitRAKE
Afternoon, bitRAKE.

This is the proc that's called whenever ya hit a F'n key:

; Name: GrabNewWebCamImage
; Desc: Starts the webcam, stores an image, and loads it in as the texture
proc GrabNewWebCamImage,hWnd,connectionNum

cmp [hWndCap1], 0
jne @f

mov [bOKtorender], FALSE

mov [dwFrameNum], 0
invoke SendMessage, [hWndCap1], WM_CAP_DRIVER_DISCONNECT, 0, 0
invoke SendMessage, [hWndCap1], WM_CAP_DRIVER_CONNECT, [connectionNum], 0
invoke SendMessage, [hWndCap1], WM_CAP_SET_PREVIEWRATE, 1, 0
invoke SendMessage, [hWndCap1], WM_CAP_SET_SCALE, TRUE, 0
invoke SendMessage, [hWndCap1], WM_CAP_SET_PREVIEW, TRUE, 0

invoke SendMessage, [hWndCap1], WM_CAP_GRAB_FRAME, 0, 0
invoke SendMessage, [hWndCap1], WM_CAP_FILE_SAVEDIB, 0, szImage

; Destroy the Texture if it exists
cmp [pTexture.handle], NULL
je @f
comcall pTexture,Release
mov [pTexture.handle],0

stdcall D3DXCreateTextureFromFile, [pd3dDevice.handle], szImage, pTexture
cmp eax, D3D_OK
jnz @f
mov [pTexture.handle],0


invoke SendMessage, [hWndCap1], WM_CAP_DRIVER_DISCONNECT, 0, 0

mov [bOKtorender], TRUE

xor eax, eax


As you can imagine, "connectionNum" is 1,2,3 or 4 depending upon which F'n key you hit.

You'd be able to create a little proggy which saves a bmp by using all the code on the lines "WM_CAP_blahblah". To change it back to Masm syntax, just drop the [] surrounding variables, and add "ADDR" before "szImage".

Even if the image doesn't appear on the rotating square, it should still be saving a BMP. It should only remain greyish if the device isn't attached to the PC. If it's attached, but not functioning correctly, then the image will be black.

Have those other webcam examples I've made worked on your 'puter?

Posted on 2003-05-22 17:12:47 by Scronty