alliedvision / VimbaPython

Old Allied Vision Vimba Python API. The successor to this API is VmbPy
BSD 2-Clause "Simplified" License
93 stars 40 forks source link

image display slow #34

Closed skywo1f closed 3 years ago

skywo1f commented 3 years ago

I am trying to use a 1800u500c camera with an Xavier AGX using python. When I launch asynchronous_grab_opencv.py, it gives me a giant image which runs slowly (5fps?). I thought it was running slow because the Xavier was trying to display an image with such high resolution. So I resized the image to 640x480. Unfortunately the fps is still relatively slow. This makes me think that either the camera is capturing frames slowly, or the information is taking a long time to get back through the usb. Any ideas on how to speed this up?

I also tried the settings: cam.BinningHorizontal = 4 cam.BinningVertical = 4 cam.Height = 480 cam.Width = 640 which it seemed to accept, but did not change anything.

NiklasKroeger-AlliedVision commented 3 years ago

Are you only experiencing this slow acquisition with the asynchronous_grab_opencv.py example or is the acquisition also slow with the simpler asynchronous_grab.py example? In this more minimal example no image data is displayed and instead a simple print statement is executed for every received frames.

Possible reasons for slow image acquisition with USB cameras might be:

What values are you getting for the DeviceLinkSpeed and the DeviceLinkThroughputLimit features? As mentioned on the product page for the 1800 U-500c in order to achieve the maximum framerate of ~68fps you need a bandwidth of >=375MByte/s. This is quite a lot and if other USB devices with significant bandwidth requirements are used on the same bus, this might well be your problem.

I would encourage you to also contact our support via the form on our website. The problem you are describing does seem like a more general USB/camera problem and less of a development issue regarding VimbaPython for which the Github issue tracker is intended. Our support team has more experience in troubleshooting such general problems and might be able to provide better help in this case than I can. If you do contact them feel free to also reference this Github issue.

NiklasKroeger-AlliedVision commented 3 years ago

I also tried the settings: cam.BinningHorizontal = 4 cam.BinningVertical = 4 cam.Height = 480 cam.Width = 640 which it seemed to accept, but did not change anything.

I just noticed that your approach to setting the camera features seems wrong. With the code as you provided it above you are overwriting the class member cam.Height with an integer of value 480. You are not actually setting the camera feature. To actually change the camera feature you would need to use the .set(<value>) method like so:

with cam:
    cam.Height.set(480)

Reading the feature values works accordingly with the .get() method.

with cam:
    height_value = cam.Height.get()

You can see some examples on how the features are accessed for example in how the ExposureAuto feature is activated in the asynchronous_grab_opencv.py example. Seeing this just now I realize that this might also be the reason why you are experiencing such slow image acquisition. If the environment in which you are attempting to take pictures is not very well lit, the exposure time will increase until the image has an acceptable brightness because the asynchronous_grab_opencv.py example turns on the auto exposure feature. This might very well lead to exposure times in the range of ~200ms which would explain the 5fps you are seeing. You could try to set the ExposureAuto feature to Off and instead manually set the ExposureTime feature to a smaller value.

skywo1f commented 3 years ago

thanks! cam.ExposureTime.set(4000) seems to have done the trick. I am now up at 15 fps which is good enough for me. Every once in a while I get .5 second lag spikes but I think I can live with that for now.