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

Exception raised when grabbing fails and cropping is attempted #43

Open
timmarkhuff opened this issue Jul 2, 2024 · 0 comments
Open

Comments

@timmarkhuff
Copy link
Contributor

If grabbing fails for whatever reason, and if there are some post-processing operations to be applied (zoom or crop), an exception will be raised because the grabbed frame is None and None cannot be zoomed or cropped.

For example, if you run:

config = {
    'options': {
        'zoom': {
            'digital':
            2.0
        }
    }
}
grabber.apply_options(config)

grabber.grab()

It will raise something like:

    grabber.apply_options(config)
                    ^^^^^^^^^^^^^^
  File "/home/pi/parkmon/pm_env/lib/python3.11/site-packages/framegrab/grabber.py", line 331, in grab
    frame = self._digital_zoom(frame)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/parkmon/pm_env/lib/python3.11/site-packages/framegrab/grabber.py", line 407, in _digital_zoom
    top = (frame.shape[0] - frame.shape[0] / digital_zoom) / 2

The solution to this should be just to return None in this case, which is what would happen if grabbing failed and there was no zooming or cropping.

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

1 participant