Video Capture From Webcam

Hi, i was wondering if there is a way to capture images from a webcam with juce?

I have some Mac code that works with Juce, but it’s very early stages…

Suport for capture devices is very platform specific.
In Windows i don’t think there is another way then using DirectShow.
So Juce would be dependant of DirectShow, and i don’t think that Jules wants this.
I found a simple and easy library that works fine for us.
http://muonics.net/school/spring05/videoInput/
You don’t even have to install the DirectX Sdk, you can link directy to this library.

wow, this is just what I was looking for, much appreciated. Do you have any sample code to show juce integration, are u able to show the video stream inside the juce app? How do u convert the captured frames to juce image format?(Is it fast?) Cheers gekkie100!

i had no problems at all getting it to run in a Juce based app.
You can get a pointer to the pixels of a newly captured frame and just copy it directly into a Juce Image.
Something along these lines, capturedPixels would be the pointer to the captured frame.

	Image frameImage(Image::RGB, captureWidth, captureHeight, false); 

	uint8* framePixelData;

    int lineStride, pixelStride;	
	framePixelData = frameImage.lockPixelDataReadWrite(0, 0, frameImage.getWidth(), frameImage.getHeight(), lineStride, pixelStride);
	memcpy(framePixelData, capturedPixels, width*height*3);
	
	framePixelData = 0;

works nicely, thanks again!