Issues with software trigger and 12 bits mono image

Hi,

I’m trying to acquire 12 bits mono images via a software triggering over a VC-25M10G-M41I0 camera. I am able to acquire a single image, even though the ring buffer does not increase, but this image is also an 8bits mono image instead of the required 12 bits.

So:

  • Why does the stream.statistics[cvb.StreamInfo.NumBuffersPending] not increase after a trigger_software.execute()?
  • Why is the image still in a 8 bits format instead of the 12 bits?

I am posting a part of my code below:

with cvb.DeviceFactory.open(cvb.install_path()+"Drivers\GenICam.vin"
    ) as device:
#device = cvb.DeviceFactory.open(cvb.install_path()+"Drivers\GenICam.vin")   
    dev_node_map = device.node_maps["Device"]

    pixel_node = dev_node_map["PixelFormat"]
    pixel_node.value = "Mono12"
    print("pixeltype set to: " + str(pixel_node.value))
    
    trigger_mode = dev_node_map["TriggerMode"]
    trigger_source = dev_node_map["TriggerSource"]
    trigger_mode.value = "On"
    trigger_source.value = "Software"
    trigger_software = dev_node_map["TriggerSoftware"]
    print("Trigger: ",str(trigger_mode),str(trigger_source) )
    
    stream = device.stream()
    ringBufferCount = stream.ring_buffer.count
    print('Size ring buffer', ringBufferCount)
    device.stream().start()
    
    images_in_buffer = stream.statistics[cvb.StreamInfo.NumBuffersPending]
    print('Number of images in buffer: ', int(images_in_buffer))
    trigger_software.execute()
    
    
    print('trigger done: ', trigger_software.is_done)
    trigger_software.execute()
    
    images_in_buffer = stream.statistics[cvb.StreamInfo.NumBuffersPending]
    print('Number of images in buffer: ', int(images_in_buffer))
    trigger_software.execute()
    
    for i in range(2):
        print("i:",i)
        image, status = stream.wait_for(5000)
        images_in_buffer = stream.statistics[cvb.StreamInfo.NumBuffersPending]
        print('Number of images in buffer: ', int(images_in_buffer))
        print("status1: ", status, cvb.WaitStatus.Ok)
    
        if status == cvb.WaitStatus.Ok:
            print("Acquired image: ")
            image_array = cvb.as_array(image.clone(), copy=True)
            print("max value: ", np.amax(image_array))
            plt.subplot(1, 4, i+1)
            plt.imshow(image_array[0:5000,0:5000], cmap='hot', interpolation='nearest')
        else:
            #raise RuntimeError( "timeout during wait"
            #    if status == cvb.WaitStatus.Timeout else
            #        "acquisition aborted")
            print('error')
        
    images_in_buffer = stream.statistics[cvb.StreamInfo.NumBuffersPending]
    print('Number of images in buffer: ', images_in_buffer)

This leads to the following result:

pixeltype set to: Mono12
Trigger:  On Software
Size ring buffer 3
Number of images in buffer:  0
trigger done:  True
Number of images in buffer:  0
i: 0
Number of images in buffer:  0
status1:  0 0
Acquired image: 
max value:  96
i: 1
Number of images in buffer:  0
status1:  0 0
Acquired image: 
max value:  255
Number of images in buffer:  0

Hi! @dave

First of all, I would like to reference a forum post by me ( https://forum.commonvisionblox.com/t/how-to-update-driver-memory-after-changing-camera-parameters/1526 ) which demonstrates how to update the memory allocated by the driver. You need to do this because you are changing parameters that directly concern the memory for an image, otherwise, it could lead to not being able to correctly interpret the new image data.

To answer your second question, you would need to set the parameter in the token before opening the device:

token.SetParameter("PixelFormat", "3")  #'3' means 'Mono16Bit'

normally it is set to “5” which means Auto Detect.

To solve your first question we would need to do some investigation. Could you please tell us your OS and CVB Version?

Regards
Silas

Hi Silas,

Thanks for your response. I am running Windows 10 x64 with CVB version 13.04.005.

I do not see how to update this setting, since all the variables report that they do not have a SetParameter option. Furthermore, the camera does report that it is set to the 12 bits mode, as shown in the results in my previous post. If I check the settings in the GenICam browser I also see the Mono12 bits being reported.

Btw, is there somewhere I can find the documents about functions such as the SetParameter or node_maps?

Hi @dave,

It is correct that you do not have the SetParameter function. We oversaw that you do not make a Discover before and load the GenICam.vin Driver directly. Sorry for the misunderstanding.

Therefore, you do not have a token with which you can set the parameters within the code.
Then you need to configure this parameter over the configured devices within the GenICam Browser.

These are the possible PixelFormat settings for the CVB Image ( From the GenICam User Guide:

0 = Raw image what ever the device delivers
1 = Mono 8Bit
2 = RGB 8Bit
3 = Mono 16Bit
4 = RGB 16Bit
5 = Auto Detect (default) eg converts high bit to 8 bit see chapter Color Formats and Pixeldepth
option 2: For a bayer color camera the driver would do an 2x2 RGB conversion

These are referenced as CVB Color Format within the GenICam Browser.

Why is this needed. As Silas said by default the GenICam.vin Driver is configured with PixelFormat=5 which is Auto Detect.
AutoDetect converts the incoming images to a format which is supported by normal Display. This means Mono 8Bit or RGB 8Bit. In your case Mono 8Bit.
To be able to access the 12 Bit images the camera delivers you need to set the Conversion to Mono 16Bit (PixelFormat=3).

Then the image is converted (unpacked) from Mono 12Bit which is in most of the cases Mono12Packed to 16Bit. Then you can access the images without unpacking the 12Bit data yourself.

1 Like

Hi Sebastian,

Thanks! This fixed the issue! And for some reason this also fixed the issue related to the # of images in the buffer not becoming larger than 0.