BlinkID / blinkid-in-browser

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

How can I find when detection is failed on camera popup #18

Closed Shubhamp777 closed 3 years ago

Shubhamp777 commented 4 years ago

Hi ,

I need to get a call back when camera get detection failed on screen.

Could someone suggest me something please?

Thanks, SP

vjekoart commented 4 years ago

Hi @Shubhamp777,

Before instance of recognizer runner is created, one can register various MetadataCallbacks. One of the callbacks provided is onDetectionFailed. This callback is called when all recognizers in RecognizerRunner have failed to detect anything on the image.

This callback is used in provided examples. It's possible to see how the callback is used in Scan from camera example.

Sincerely, Vjekoslav

Shubhamp777 commented 4 years ago

Oh, Okay :)

Thanks a lot for your valuable reply.

Regards, Shubham

Shubhamp777 commented 4 years ago

Hi vjekoart,

I applied your suggestion in my code. But I also want to know , If detection is completely failed during the scan. then what it returns any callback for the same. Could you please let me know this also?

Suppose If scanning of any document doesn't exctract the data. This case It should also return a call back/ It does?

Thanks, SP

vjekoart commented 4 years ago

Hi @Shubhamp777,

Callback onDetectionFailed is one mechanism to get notified when nothing will be extracted. Another mechanism is to check if results are empty. This should be done when extraction is finished, and when there is no need to keep camera on anymore.

Based on the Scan from camera example, once the results have been retrieved with const processResult = await videoRecognizer.recognize();, it's useful to check if results are empty, or if there is some data available.

To check if results are empty, simple if condition will do:

if ( processResult !== BlinkIDSDK.RecognizerResultState.Empty )
{
    // Do something with results
}
else
{
    // Notify user that data cannot be extracted
}

Hope this helps.

Sincerely, Vjekoslav

vjekoart commented 4 years ago

Hi @Shubhamp777,

Have you managed to implement desired behaviour in case of failed detection and/or empty results?

Sincerely, Vjekoslav