Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to recover from RuntimeError when grabbing multiple images #21

Open
RichardLangFromNZ opened this issue Oct 14, 2016 · 4 comments

Comments

@RichardLangFromNZ
Copy link

Running Pylon libraries from within linux Mint 18 VM on Windows 7 VirtualBox host.

Occasionally get

"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."

thrown on camera.grab_image() call (due to delays/issues with VM network adapter bridge to host physical adapter I guess) however if the exception is caught, subsequent calls to grab_image() will complete successfully.

However if I try to grab multiple images using the grab_images() method, as follows

while True:
    try:
        for image in cam.grab_images(N):
            ...    
    except RuntimeError
        ...

once the above mentioned exception has occurred, all further calls to grab_images() fail with an un-commented RuntimeError.

@RichardLangFromNZ RichardLangFromNZ changed the title Failure to recover from RuntimeError when grabbing multiple errors Failure to recover from RuntimeError when grabbing multiple images Oct 14, 2016
@ZacDiggum
Copy link

I made a PR and added a stop_grabbing() function and infinite grabbing and put a StopGrabbing() statement into __del__(). On catching the exception you could try cam.__del__() and then re-initialize. Maybe that helps. BTW, thanks for the nogil trick. My threaded PyQt app runs a lot more stable now.

@mabl
Copy link
Owner

mabl commented Oct 14, 2016

I think it might be a good idea to check if the camera is still grabbing and stop it before restarting it. Also checking while still being in the iterator. I'll try this sooninsh, as I'm not in the lab and with the camera atm.

@RichardLangFromNZ
Copy link
Author

I've pulled down Zac's PR and had a play and a call to stop_grabbing() inside the exception handler fixes this issue.

Once #17 is merged I'll generate a another PR on top of it that wraps the grab_images() internals with an exception handler that calls stop_grabbing() before re-raising, to relieve clients of burden of knowing that they need to do this.

@RichardLangFromNZ
Copy link
Author

Fix in PR #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants