Closed terbed closed 6 years ago
Hi @terbed,
The conversion into a multibyte RGB format is supported, but not easily available at the moment:
a) the image format converter can be set up to use a RGB16packed format
you have to decide if you want your 12bit data lsb or msb aligned in the 16bit image
converter = pylon.ImageFormatConverter()
# converting to opencv bgr format
converter.OutputPixelFormat = pylon.PixelType_RGB16packed
converter.OutputBitAlignment = pylon.OutputBitAlignment_LsbAligned
As the Image type has no working automatic conversion between uint16 type and a numpy array you have to do it by hand:
image = converter.Convert(grabResult)
img = np.ndarray(buffer=image.GetBuffer(),shape= image.GetHeight(),image.GetWidth(),3),dtype=np.uint16)
This should solve your direct issue of working with 12bit color data.
hi @thiesmoeller,
First of all thank you for your reply! It works in this way indeed:
# converting to opencv bgr format
converter.OutputPixelFormat = pylon.PixelType_RGB16packed
converter.OutputBitAlignment = pylon.OutputBitAlignment_LsbAligned
bgr_img = frame = np.ndarray(shape=(img_height, img_width, 3), dtype=np.uint16)
.
.
.
image = converter.Convert(grabResult)
frame = np.ndarray(buffer=image.GetBuffer(), shape=(image.GetHeight(), image.GetWidth(), 3), dtype=np.uint16)
bgr_img[:, :, 0] = frame[:, :, 2]
bgr_img[:, :, 1] = frame[:, :, 1]
bgr_img[:, :, 2] = frame[:, :, 0]
cv2.namedWindow('Video', cv2.WINDOW_AUTOSIZE)
cv2.imshow('Video', bgr_img*15)
Dear All,
I have a basler camera (acA1600-20uc) which supports the following PixelFormats:
BGR 8 BGRA 8 Bayer 12 Bayer 8 Mono 8 RGB 8
I want to process the captured images with opencv, so I convert the image with the converter. The only format the converter accepts is
PixelType_BGR8packed
otherwise I get this error: Traceback (most recent call last):For my work it is important to get 12bit depth image. Is it possible somehow? I attach the modified sample code below: