Ask Your Question
1

Point Grey USB3 camera pixel color format

asked 2015-10-31 00:48:42 -0600

I have a PointGrey BlackFly USB3 2MP camera that reads as three 8-bit channels in Python's Numpy array of shape (rows, cols, 3). However, each cell (pixel) has the same value, so I end up with a gray-scale image-like by default. The size of the image is correct, though.

I tried several conversions of color, but Bayer cannot go from 3 channels to anything else. Does anyone know which property to set for this VideoCapture object or any other suggestion? I'm not sure which Video Data Output it's using, perhaps it's 24-bit digital data it's giving 24-bits per pixel as (8,8,8), but maybe not.

How to find out the video format within OpenCV? If I ask for my_capture_device.get(cv2.CAP_PVAPI_PIXELFORMAT_RGB24) it says 15.0, my_capture_device.get(cv2.get(CAP_PVAPI_PIXELFORMAT_BAYER16), I get 480.0, and my_capture_device.get(cv2.get(CAP_PVAPI_PIXELFORMAT_BAYER8) I get 640.0. Any other PIXELFORMAT option gives -1.

I don't understand what these values mean. Please, help if you know how to set the color space for these PointGrey cameras. I know that OpenCV is wrapping around libdc1394 to interface the camera since PointGray doesn't provide drivers for OS X.

Thanks in advance!

edit retag flag offensive close merge delete

Comments

1

@Eduardo: the problem is that these documents don't apply to the use of OpenCV alone (without grabbing the images from the FlyCapture API). I'm grabbing the images directly from OpenCV's back-end to libdc1394 in Mac OS X.

opencvslave gravatar imageopencvslave ( 2015-11-11 14:11:02 -0600 )edit

It does not work directly from OpenCV. You will need the FlyCapture API ...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-19 07:53:41 -0600 )edit

I got my BlackFly USB 3 camera working in OpenCV after reinstalling (upgrading) libusb via homebrew, and then rebuilding libdc1394 from source (The color conversion in the answer below changes a little for the BlackFly, specifically the conversion is cv2.COLOR_BAYER_BG2BGR).

opencvslave gravatar imageopencvslave ( 2015-11-19 12:23:22 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-11-18 12:04:25 -0600

updated 2015-11-20 12:29:41 -0600

In OS X El Capitan, using OpenCV 3.0 and Python:

  1. Read the frame,

    success, frame_raw = self.capture.read()
    
  2. Then, convert the frame_raw into color using the Bayer color-scheme like this:

    For a USB 2.0 Chameleon device:

    frame_bgr = cv2.cvtColor(frame_raw, cv2.COLOR_BAYER_GR2BGR)
    

    This conversion also works for grabbing frames directly using pydc1394 in Python because the raw pixel matrix is just a Numpy array which OpenCV also uses to represent images.

    However, for a USB 3.0 BlackFly camera, the conversion in my case is as follows:

    frame_bgr = cv2.cvtColor(frame_raw[...,0], cv2.COLOR_BAYER_BG2BGR)
    
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-10-31 00:48:42 -0600

Seen: 4,327 times

Last updated: Nov 20 '15