foxanna / mrz_parser

Parse MRZ (Machine Readable Zone) from identity documents.
https://pub.dev/packages/mrz_parser
MIT License
15 stars 11 forks source link

pick image from gallery #12

Closed ritzqureshi closed 1 month ago

ritzqureshi commented 1 month ago

is:issue is:open when we use image from assets folder it works fine but when we pick image from gallery it shows an error 'Invalid MRZ parser input. If you think this is a mistake, please file an issue https://github.com/olexale/mrz_parser/issues'

olexale commented 1 month ago

any sample project that reproduces the problem?

ritzqureshi commented 1 month ago

i have created my own in flutter and iam using like this
//Gallery image picked usiing image pciker static Future<Uint8List?> imagePicker() async { try { final XFile? image = await picker.pickImage(source: ImageSource.gallery); if (image != null) { return await image.readAsBytes(); // Return the image as bytes } else { print('No image selected.'); return null; } } catch (e) { print('Error picking image: $e'); return null; } } //-----selected from gallery --- final galleryImageBytes = await ImageHelper.imagePicker(); //---Asset image---- final ByteData imageData = await rootBundle.load('assets/images/7.png'); final Uint8List imageBytes = imageData.buffer.asUint8List(); //-----Both Image are same..... final request = AnnotateImageRequest() ..image = (Image()..contentAsBytes = imageBytes) ..features = [ (Feature() ..type = 'TEXT_DETECTION' ..maxResults = 10) ];

olexale commented 1 month ago

I'm not sure I understand the case. So, here you loaded an image from the gallery, then used some AnnotateImageRequest() and requested a 'TEXT_DETECTION' from it. Is the output a list of strings?

That's how you may use the mrz_parser package:

  final mrz = [
    'P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<',
    'L898902C36UTO7408122F1204159ZE184226B<<<<<10',
  ];
  final result = MRZParser.tryParse(mrz);

The mrz is a list of strings you get from somewhere.

ritzqureshi commented 1 month ago

can you please help me out ,Now mrz give me only limited data from that string is there any other way to get complete data , now mrz only fetch data from this pattern final mrz = [ 'P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<', 'L898902C36UTO7408122F1204159ZE184226B<<<<<10', ]; although we need to extract full data in key value pair from passport .... here is the string 'वीजा / VISA भारत गणराज्य / REPUBLIC OF INDIA टाईप / Type P कोड / Code IND राष्ट्रीयता / Nationality भारतीय / INDIAN पासपोर्ट न. / Passport No. Y3109867 Qureshi उपनाम / Surname QURESHI दिया गया नाम / Given Name(s) RIZWAN जन्मतिथि / Date of Birth 02/05/1995 जन्म स्थान / Place of Birthd लिंग / Sex M MEERUT, UTTAR PRADESH जारी करने का स्थान / Place of Issue DELHI जारी करने की तिथि / Date of Issue 6/03/2022 समाप्ति की तिथि / Date of Expiry 05/03/2032 P<INDQURESHI<<RIZWAN<<<<<<<<<<<<<<<<<<<<<<<< Y3109867<4IND9707081M34060941069704190024<78' i want to get everything as key value pair

olexale commented 1 month ago

give me only limited data from that string

What makes you think that the data is limited?

ritzqureshi commented 1 month ago

data is limited because we cannot get Date of Issue, Place of Issue and Place of Birth can you help me to get these field also?

olexale commented 1 month ago

This information is not encoded in MRZ, you may read about the format here https://en.wikipedia.org/wiki/Machine-readable_passport.