Getting color image from point grey camera

Hi all,

I am using the PtGrey Blackfly camera on Windows and am able to get a greyscale image into OF using the PtGrey SDK (with a little help from the ofxFireFlyMv addon). My problem is that I cannot seem to get a colour output from the camera.

To grab the image I am doing the following:

// Retrieve an image
err = cam.RetrieveBuffer( &rawImage );
if (err != PGRERROR_OK){
    PrintError( err );

// Create a converted image
Image convertedImage;

// Convert the raw image to RGB8 format
err = rawImage.Convert(PIXEL_FORMAT_RGB8, &convertedImage);
if (err != PGRERROR_OK)

bIsFrameNew = true;

// copy into pixels
for( int i = 0; i < height; i++ ) {
	memcpy(pixels + (i*width), convertedImage.GetData() + (i*convertedImage.GetStride()), width);

Now I need to copy ‘pixels’ to an ofImage. If I allocate the ofImage as OF_IMAGE_GRAYSCALE (and convert it above to PIXEL_FORMAT_MONO8) it works fine. But as soon as I try to allocate the ofImage to OF_IMAGE_COLOR the app crashes with memcpy.asm complaining. To set the ofImage I am doing the following:

camImage.setFromPixels(pixels, camWidth, camHeight, OF_IMAGE_GRAYSCALE); //OF_IMAGE_COLOR crashes

Has anyone else run into this issue?


Hey - i got your other thread message. I haven’t used that addon, but the best thing to do is capture in raw8 or rgb (PIXEL_FORMAT_RAW8 / PIXEL_FORMAT_RGB) instead of mono. You need to make sure the external FlyCapture app is set to the correct mode and saved, and you need to match that in whatever addon your using (ofxFireFlyMv). Then you don’t need to do the expensive conversions yourself. You just create an RGB ofTexture and load the PGR image data.

// setup preferences
Mode fmt7Mode = MODE_0;
PixelFormat fmt7PixFmt = PIXEL_FORMAT_RGB; // or PIXEL_FORMAT_RAW8

// capture
Image rawImage;
texture.loadData(rawImage.GetData(), camWidth, camHeight, GL_RGB);

If you are capturing in raw8 (which is the fastest capture) you need a shader to convert the raw8 bayer image to rgb.

Good luck.

Thanks! It turns out my problem was actually that I was not assigning enough pixels to deal with colour!

I also found that the camera will only work if my PixelFormat is RAW8, I then convert it to RGB and assign the pixels but anyway it’s working now.


For anyone else wanting to integrate the fly capture sdk in VS - this was helpful: