genicam / harvesters

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

getImage() timeout after third image acquisition #365

Open gKoinig opened 1 year ago

gKoinig commented 1 year ago

I have created a ImageAcquirer Object and am getting Images from the camera. But after the third acquisition I am getting a TimeOut Error and have to start the camera again. Is there a way to solve this by, f.e. change the trigger to manual?

MathijsNL commented 1 year ago

What kind of device are you using? Could you try to grab the image in the following way:

for x in range (0,20):
    ia.start()
    with ia.fetch() as buffer:
        pass
    print(f'Grabbing image {x} / 20')
    ia.stop()

Could you also try to change the BandwidthReserve setting?

ia.remote_device.node_map.BandwidthReserve.value = 90 # default is 10 I guess?

What device are you using to grab the images? On lower end devices bandwith sometimes is a problem (or with wrong cables / switches)

aphilip442 commented 1 month ago

I ran into the same issue using:

ia.start()
for _ in range(4):
    buffer = ia.fetch()
    component = buffer.payload.components[0]
    np_array = np.copy(component.data.reshape(component.height, component.width))
ia.stop()

The solution is to use a context manager, like indicated by MathijsNL:

ia.start()
for _ in range(4):
    with ia.fetch() as buffer:
        component = buffer.payload.components[0]
        np_array = np.copy(component.data.reshape(component.height, component.width))
ia.stop()

It should probably raise an error when using fetch without the context manager.