A little progress

Well I managed to get the quickcam displaying the full resolution image using opencv. It turns out that it was capturing at 640×480 the whole time, it just wasn’t displaying the whole image. A bit of tweaking to the capture properties and everything started working correctly. Specifically I needed to add these lines:

cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);

I was also having a little bit of trouble getting at the raw image data from C# as you access it like this using C:

pix = ((uchar*)(img->imageData + img->widthStep*y))[x];

I ended up writing a function that looks like this (where imageData is an IntPtr):

/// This method is used to get the value of a single pixel from the
/// underlying C
private unsafe byte GetPixel(int x, int y)
// the image data is in one long contiguous array so we need to
// skip y rows of widthstep
values before adding our x value to
// index to the right x point in the right row.

return (byte)(((byte*)this.Image.imageData) + this.Image.widthStep * y)[x];

Hey… it works 🙂

One thought on “A little progress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s