Sunday, January 27, 2008

My PGR Bumblebee2 "Hello World"

As I mentioned earlier, last September I was requested to hack together a demo version of our artificial vision system. One of the demo's requirements was to use PointGrey's Bumblebee2 stereo camera as the visual input device – which in turn required me to write code to access the camera, grab a stereo pair of photos and write it to disk.

The example projects provided with the camera's drivers and API library showed how to do all sorts of fancy stuff – but not one of them would focus on the basics of grabbing a pair of left-and-right images and writing them to disk. Of course, I was able eventually to see through all the extras and gather just enough code to do what I wanted; but that didn't change the fact that PointGrey's example set was flawed – that it should show how to do the basic stuff before illustrating the more advanced features.

This archive is my attempt to mend that flaw, should anyone ever need a basic example on grabbing photos from a Bumblebee2 camera – or any other camera acessible through the FlyCapture API. It contains the source code and makefile for a small application called BeeCap, which illustrates how to:
  1. Stablish an interface to the camera;

  2. For the Bumblebee2, select the left or right camera;

  3. Load a photo to a memory buffer;

  4. Write the contents of the buffer to a file.

The application has a known issue concerning the Bumblebee2: you cannot grab a stereo pair of buffers and then write them both to disk – if you do, you end up with two copies of the same photo, taken from the last selected camera. Saving the firt buffer before grabbing the next solved the issue, and I was short on time back when I was working on the camera interface, so I never really discovered what was going on; take figuring it out as an exercise if you like – and contact me if you do. ;)