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

Feature Request: per_xxx_function could return bool value to indicate abort #330

Open
Hermholtz opened this issue Sep 2, 2019 · 3 comments

Comments

@Hermholtz
Copy link

per_frame_function callbacks and others from the family could return a boolean value to indicate to ImageAI that detection should be aborted. My scenario is the following: I'm using detectObjectsFromVideo function to detect objects in webcam. I'm passing per_frame_function to process detected objects and show info to the user. If the user decides to close the window, the detectObjectsFromVideo function should terminate gracefully, but the program should be allowed to continue to do other tasks.

So I propose to have something like this:

def forFrame(frame_number, output_array, output_count, returned_frame):

    process_frame()
    display_frame()
    # ...

    if window_is_closed:
        return True    # <--- this means 'finish detection'

If the return statement will be omitted in the per_xxx_function, the return value will be None thus allowing detection to continue. That will provide backward compatibility.

@cagnulein
Copy link
Contributor

i need this too, @OlafenwaMoses what do you think? If you agree i could do a pull request

@cagnulein
Copy link
Contributor

@chojrak11 is what you had in mind?

@Hermholtz
Copy link
Author

Wow that looks awesome, just please add a bit of documentation to the docstring of the function and I think it should be accepted :)

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

2 participants