BlinkID / blinkid-in-browser

BlinkID In-browser SDK for WebAssembly-enabled browsers.
https://microblink.com/blinkid
59 stars 30 forks source link

Missing teardown logic that doesn't cause the video to stop #52

Open sveres opened 3 years ago

sveres commented 3 years ago

Hey, I think there is no way to stop the video recognition without pausing the video feed.

If I VideoRecognizer.cancelRecognition(), it pauses the video feed. If I call VideoRecognizer.deleteRecognizer() without calling cancel firs, it will result in an unexpected error: "Uncaught (in promise): Recognizer runner is deleted. It cannot be used anymore!" I think that's because there is still a setTimeout alive that tries to call processImage().

If I am wrong and there is a way, could you point me to the right documentation/code piece, please?

vjekoart commented 3 years ago

Hi @sveres,

You're right. We don't have a teardown logic that doesn't cause the video to stop. I suppose this is something that will benefit your use case?

Also, there is no VideoRecognizer.deleteRecognizer() method. To make things more clear, could you clarify which method do you reference there?

Sincerely, Vjekoslav

sveres commented 3 years ago

hi @vjekoart

Yes, in our use case, the barcode recognition is optional and our barcode reading implementation cannot stop the video, otherwise it interferes with an other, parallel capturing method. Is there by any chance a workaround to use the VideoRecognizer without causing the video to pause at the end of the scanning?

You are right, there is no method like that, sorry about the confusion. What I meant is the delete() method. Which, In my understanding should be called after the cancellation, please correct me if I am wrong. https://github.com/BlinkID/blinkid-in-browser/blob/36373d0488f3bc4d7506b1aa334a4b4b74ccd3ff/src/MicroblinkSDK/DataStructures.ts#L82

vjekoart commented 3 years ago

Hi @sveres,

Thank you for the explanation. We'll look into this behaviour and extend the functionality from our side if we don't find an alternative solution.

Sincerely, Vjekoslav

sveres commented 3 years ago

Thank you as well, if there is anything else I can clarify, please just let me know.

sveres commented 3 years ago

Hi @vjekoart Do you have any update on this feature?

vjekoart commented 3 years ago

Hi @sveres,

We're currently not working on this feature. However, the task is defined and placed in the backlog, but we cannot tell the exact date when it's going to be implemented due to limited resources.

Sincerely, Vjekoslav

DoDoENT commented 2 years ago

Hi @sveres,

if you are using VideoRecognizer directly from your code, you can call pauseRecognition - this will pause the recognition loop (i.e. new frames won't be processed, even if there are still live processImage tasks queued from setTimeout), but the video feed will keep working (the camera will still be enabled). You can then resume the recognition by calling resumeRecognition.

If you also want to stop the video feed (i.e. "freeze" the video feed, without tearing down the camera), you can call pauseVideoFeed. However, after pausing the video feed, you will need to resume the recognition by calling either recognize or startRecognition (recognize is just simple wrapper around startRecognition that set the default onScanningDone callback that pauses the video feed before resolving the promise).

sveres commented 2 years ago

Thanks @DoDoENT, this is great news, we will check pauseRecognition out.