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. ;)

4 comments:

  1. I'm starting to use this camera and was surprised that there was no demo to capture the stereo pics and save them to disk.
    I'll be trying this. Thanks.

    ReplyDelete
  2. Good luck, and let me know if you have any problems with the source. By the way, what are you using the Bumblebee2 for?

    ReplyDelete
  3. Just to worry you a little... By grabbing the 2 PAN images i.e. left then right how can you be sure that they are synchronised?

    I am using the BB2 too and the recommended method to capture the images as a synchronised pair is to capture a single interlaced image from the camera in RAW7 format, deinterlace that into the right and left hand images and then use a Bayer transform to resurrect the colour images.

    Have you managed to ensure synchronisation between the left and right image in some way?

    ReplyDelete
  4. Actually synchronization is a known issue with my code. There is a delay of a couple seconds between the first and second shot, so it is guaranteed the pictures are not synchronized.

    I didn't know you could take an interlaced shot from both cameras at once... Where did you learn that? Do you have a code sample showing how to do it?

    ReplyDelete