DoubangoTelecom / ultimateMRZ-SDK

Machine-readable zone/travel document (MRZ / MRTD) detector and recognizer using deep learning
https://www.doubango.org/webapps/mrz/
Other
174 stars 49 forks source link

Will this work for image rotated to 90 degrees ? Will it suppport rotated images also. Please let me know if there are any custom configurations to be done to support rotated images. #43

Closed koko9712 closed 3 years ago

DoubangoTelecom commented 3 years ago

If the picture is taken using a smartphone on Portrait mode it'll be 90° rotated ("rotated images") and this information is embedded in the EXIF meta-data. It's up to you to extract this information and provide it to the process function.

Check process function at https://www.doubango.org/SDKs/mrz/docs/cpp-api.html#_CPPv4N14ultimateMrzSdk15UltMrzSdkEngine7processEK21ULTMRZ_SDK_IMAGE_TYPEPKvK6size_tK6size_tK6size_tKi, the last parameter is the EXIF orientation info.

To extract the EXIF orientation info from a JPEG image:

If for any reason you don't have the EXIF meta-data then, try the picture with "orientation=0" and if no MRZ is found then use "orientation=6" and try again. We don't recommend this hack as there is no reason for an image to be 90° rotated without embedding this information in the meta-data. See https://www.impulseadventure.com/photo/exif-orientation.html

So, to make it clear: If your picture is 90° rotated and there is no meta-data to indicate it then, you're in fault and it's not a limitation. For example, you can try the Android sample and you'll notice that it works when the mobile device is rotated at 90, 180 or 270 degrees thanks to the EXIF meta-data information.

"rotated images" is not a feature or something expected to be supported by our SDK. If you're rotating the document at 90° then, up to you to set the right EXIF orientation or call the process function twice as explained above. Please also note that "rotated images" can be 90° rotated or 270° rotated which means the EXIT orientation value could be 6 or 8 for these images.