How to convert raw buffer to raw to rgb manually?

I am getting raw buffer using the following code. I need to get the RGB image and IR image. How can I convert the raw buffer manually? Thanks in advance.

with cvb.DeviceFactory.open(
        mock_info.access_token, cvb.AcquisitionStack.GenTL) as device:   
    stream_RGB = device.stream(cvb.ImageStream, 0)
    stream_IR = device.stream(cvb.ImageStream, 1)
 
    stream_RGB.start()
    stream_IR.start()


    d = 0
    for i in itertools.count(start=1):
        
        image1, status_stream0, node_map_stream0 = stream_RGB.wait()
        image2, status_stream1, node_map_stream1 = stream_IR.wait() 

Hi @redhat,
A returned raw buffer could indicate that the Buffer may not meet the requirements for being converted. What camera are you using and which formats would you expect?
Regards

Thank you for your reply. I am using JAI camera and I would like to get RGB and IR images. I am getting IR images but I cant get RGB images using the code.

The camera has two strems, one is RGB and another one is IR. I need to get the both images from both channels.

Can you have a look at this post? Here a user converts the raw buffer to RGB10p32 which is the RGB format with 10 bit red, green and blue pixel components each, packed into 32 bit:
https://forum.commonvisionblox.com/t/acquiring-10-12-bit-rgb-images-from-a-jai-ap-3200t-pge/1430/8?u=usernv

You need to open your camera and access the node map for example with the GenICam Browser. There is an entry that states the color format used. Cross reference the format you want to stream with the GenICam pfnc format table linked above and adopt the values accordingly in the code from the linked post. That would be it. Otherwise you can either completely write the buffer manipulation from scratch or google for popular conversion methods for your specific raw buffer pfnc format. There are a lot of formats available in the list, but widely used are only 10 or so, so don’t worry :slight_smile:

1 Like