evermeer / PassportScanner

Scan the MRZ code of a passport and extract the firstname, lastname, passport number, nationality, date of birth, expiration date and personal numer.
BSD 3-Clause "New" or "Revised" License
457 stars 101 forks source link

Feature request: Disable camera filters in the preview #22

Closed punto2018 closed 5 years ago

punto2018 commented 5 years ago

Hi everybody, Currently the library show a manipulated video in the camera preview view. The image is black and white, several filters have been applied in order to facilitate the acquisition with the ocr. For some uses this is not acceptable, I'm trying to figure out if it is possible to restore the "standard camera preview" disabling all filters, re applying them in post processing when the frame is passed to the recognition engine.

Any suggestion in where to start? Thanks!

evermeer commented 5 years ago

I think thats easy to do by changing the line:

camera --> exposure  --> highlightShadow  --> saturation --> contrast --> adaptiveThreshold --> renderView

into

camera --> exposure  --> highlightShadow  --> saturation --> contrast --> adaptiveThreshold
camera --> renderView
evermeer commented 5 years ago

so you will live the filters in tact but don't send it to the renderview. instead you will set the camera directly to the renderview You will be missing some feedback about the quality of the lightning. maybe you should change the adaptiveThreshold to a fixed threshold

punto2018 commented 5 years ago

Thanks, for your reply. Using your code the resulting image is not sent to the OCR engine. I've changed it in: camera --> exposure --> highlightShadow --> saturation --> contrast --> adaptiveThreshold camera --> crop --> renderView and now it works but OCR is returning very bad results.

I've implemented a similar filter chain using the preprocessedImage method obtaining very good results. I would like to switch the post processing mode with a boolean property in order to meet the initial requisite: have the camera preview free from filters.

If you like I can push the code for the community pleasure.

VF

evermeer commented 5 years ago

Improvements are always welcome. It would be nice if you could create a pull request for this!

evermeer commented 5 years ago

This is now optional after PR merge and publish as version 4.0.0