mabl / PyPylon

An experimental python wrapper around the Basler Pylon 5 library
BSD 3-Clause "New" or "Revised" License
53 stars 34 forks source link

ZeroDivisionError: integer division or modulo by zero #6

Closed maxlklaxl closed 8 years ago

maxlklaxl commented 8 years ago

rarely this happens

Traceback (most recent call last):
  File "test1_pypy.py", line 28, in <module>
    for i, im in enumerate(cam.grap_images(1000)):
  File "PyPylon/cython/factory.pyx", line 226, in grap_images (cython/factory.cpp:4569)
ZeroDivisionError: integer division or modulo by zero
mabl commented 8 years ago

I guess this is related to #5. I should probably check the result of the image grep. However CGrabResult only exposes access to its internal CGrabResultData via CGrabResultData * operator->() - which is unfortunately not available inside cython...

I resort to casting to IImage (operator IImage & () const), which is less powerful, but also exposes the image data.

In any case, I've pushed another check which will raise a runtime error if the IImage claims to be not valid. I could not test it however, since I left the cam at the university.

mabl commented 8 years ago

Okay, so I "solved" the access problem with an almighty super beautiful macro... Neither looks nice nor scales nicely, but we finally might be able to get a true error message for your issue.

maxlklaxl commented 8 years ago

This solved it, no more errors ... I'll start a longer test run

mabl commented 8 years ago

I thought I only added debug checks :-D I would be surprised to see the actual error going away.

maxlklaxl commented 8 years ago

Sorry, that was to early ... crashed

Frames until crash: 8056
Traceback (most recent call last):
  File "test1_pypy.py", line 34, in <module>
    for i, im in enumerate(cam.grap_images(100000000)):
  File "PyPylon/cython/factory.pyx", line 226, in grap_images (cython/factory.cpp:4579)
RuntimeError: The buffer was incompletely grabbed. This can be caused by performance problems of the network hardware used, i.e. network adapter, switch, or ethernet cable. To fix this, try increasing the camera's Inter-Packet Delay in the Transport Layer category to reduce the required bandwidth, and adjust the camera's Packet Size setting to the highest supported frame size.
mabl commented 8 years ago

Yep, but at least now you know what is wrong. ;-)

maxlklaxl commented 8 years ago

So I guess it is because I have the camera on full framerate and a bas network card

also PylonViewerApp is unhappy, displaying corrupted frames and complaining

Type    Time    Source  Message
Error   2016-02-13 18:00:03.843 Basler acA640-120gm (21625707)  Image acquisition on "Basler acA640-120gm (21625707)" failed! Error: 0xe1000014 "The buffer was incompletely grabbed. This can be caused by performance problems of the network hardware used, i.e. network adapter, switch, or ethernet cable. To fix this, try increasing the camera's Inter-Packet Delay in the Transport Layer category to reduce the required bandwidth, and adjust the camera's Packet Size setting to the highest supported frame size." 
mabl commented 8 years ago

I guess that is it. I've seen quite an extensive documentation by Basler on Ethernet performance, ranging from using Intel Ethernet Cards to Jumbo Frames and tuning the MTU.

If you do not mind missing frames you can now catch the Exception in Python and just restart grepping images.