genicam / harvesters

Image Acquisition Library for GenICam-based Machine Vision System
Apache License 2.0
502 stars 86 forks source link

Sporadic Error - "Buffer is currently not delivered!" #274

Closed marvher closed 2 years ago

marvher commented 2 years ago

Hello,

I have an IDS Camera IDS GV-5260CP with Genicam. I was able to successfully write this script here. However, now sporadically an error occurs when I want to take a photo (execute the shoot_image function).

AccessDeniedException: GenTL exception: Requested operation is not allowed. (Message from the source: Buffer is currently not delivered!) (ID: -1005)

I wonder if the error is on behalf of Harvesters (@kazunarikudo), because I don't have an error with the IDS library...

Could someone help me here? Is it possible that I still have to do some steps regarding the buffer?

Thanks a lot!

class CameraController:
    def __init__(self, PATH_GENICAM_CTI, exposure_time: int = 20000):
        self.h = Harvester()
        self.h.add_file(PATH_GENICAM_CTI)
        self.h.update()

        self.ia = self.h.create_image_acquirer(0)
        self.ia.remote_device.node_map.ExposureTime.set_value(float(exposure_time))
        self.ia.start_acquisition()

    def shoot_image(self):
        with self.ia.fetch_buffer() as buffer:
            component = buffer.payload.components[0]
            data_format = component.data_format
            content = component.data.reshape(component.height, component.width).copy()
            content_bgr = cv2.cvtColor(content, cv2.COLOR_BAYER_RG2BGR)
            return content_bgr

    def close_connection(self):
        self.ia.destroy()
        self.h.reset()
error
kazunarikudo commented 2 years ago

@marvher Hi, I am sorry for having kept you waiting. I guess I'm trying to update the chunk data even though the buffer itself is not complete. I will try to check the code and provide the fix as soon as possible. Thanks, Kazunari.

kazunarikudo commented 2 years ago

I have just merged a branch into the master: You will never have any buffer that is incomplete hence you should not face the exception above anymore. On the other hand, please note that there is a case where the fetch_buffer method call ends up with a time-out due to incomplete buffers that float under your feet. If the fetch attempt ends up with a time-out then the method throws the genicam.gentl.TimeoutException. If you need a valid buffer anyway, please catch the exception and call the fetch_buffer method again until you get a valid buffer.

marvher commented 2 years ago

Hello @kazunarikudo, no problem, thanks for your answer and explanation! In fact, I have now done exactly the same as you suggested :) Thanks a lot for that!

Cheers!

kazunarikudo commented 2 years ago

@marvher Hi, thank you for the update. Keep happy coding!