<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sivakumar Mahalingam</title>
    <description>The latest articles on DEV Community by Sivakumar Mahalingam (@sivakumar_mahalingam).</description>
    <link>https://dev.to/sivakumar_mahalingam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2629008%2Fa52df063-1ec6-4ea4-b7ff-5fd291b213c7.png</url>
      <title>DEV Community: Sivakumar Mahalingam</title>
      <link>https://dev.to/sivakumar_mahalingam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sivakumar_mahalingam"/>
    <language>en</language>
    <item>
      <title>Introducing FastMRZ – Effortless MRZ Extraction Made Simple</title>
      <dc:creator>Sivakumar Mahalingam</dc:creator>
      <pubDate>Tue, 31 Dec 2024 15:20:58 +0000</pubDate>
      <link>https://dev.to/sivakumar_mahalingam/introducing-fastmrz-effortless-mrz-extraction-made-simple-3ikd</link>
      <guid>https://dev.to/sivakumar_mahalingam/introducing-fastmrz-effortless-mrz-extraction-made-simple-3ikd</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;In today's world, where speed is everything, sensitive document processing has to be automated. Be it passport, visa, or ID card, extraction of MRZ data with accuracy and speed is very significant for developing reliable applications. This is where &lt;code&gt;fastmrz&lt;/code&gt; comes into play as a lightweight and efficient Python package in making this MRZ data extraction from document images much easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/sivakumar-mahalingam/fastmrz" rel="noopener noreferrer"&gt;FastMRZ Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PyPI:&lt;/strong&gt; &lt;a href="https://pypi.org/project/fastmrz" rel="noopener noreferrer"&gt;FastMRZ Python Package&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is FastMRZ?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;FastMRZ&lt;/code&gt; is a Python package that uses computer vision techniques to extract MRZ information from images of documents. It provides an easy-to-use implementation that enables the extraction of MRZ, making it easier for developers who build systems for FinTech, security, and identity verification.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use FastMRZ?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Ease of Use:&lt;/strong&gt; With a simple API, fastmrz gets you up and running in no time and does not require a steep learning curve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Speed:&lt;/strong&gt; Optimized for performance, it processes images fast enough to ensure the least latency in your applications. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Accuracy:&lt;/strong&gt; It is designed to reliably detect and extract MRZ data, even from challenging image conditions. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Lightweight:&lt;/strong&gt; It is built to keep dependencies at a minimum, hence easily integrable into any project. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Open Source:&lt;/strong&gt; It is free and open-source, hence the community contributes and improves the package.&lt;/p&gt;

&lt;p&gt;Also this python package,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Supports various document formats (passports, visas, ID cards).&lt;/li&gt;
&lt;li&gt;Compatible with a wide range of image resolutions and formats.&lt;/li&gt;
&lt;li&gt;Robust against skewed or distorted images.&lt;/li&gt;
&lt;li&gt;Pythonic API for seamless integration.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Features
&lt;/h2&gt;

&lt;p&gt;FastMRZ is unique in many ways with the combination of powerful features:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Intelligent MRZ Detection:&lt;/strong&gt; The library applies sophisticated contour detection methods in order to find the exact position of the MRZ area within document images to accurately extract even if document orientation is not perfect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Custom ONNX Models:&lt;/strong&gt; We have integrated our very own, custom-trained ONNX models for improved recognition accuracy by availing the powers of machine learning while maintaining rapid speeds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Built-in Validation:&lt;/strong&gt; It features comprehensive checksum logic that will verify the extracted data, helping to catch any potential recognition errors or document tampering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Flexible Output Formats:&lt;/strong&gt; Whether it's structured JSON for easy integration with other systems or even raw text for simple processing, FastMRZ has you covered.&lt;/p&gt;

&lt;h2&gt;
  
  
  Under the Hood
&lt;/h2&gt;

&lt;p&gt;FastMRZ is built on a very robust technical foundation, using several leading technologies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OpenCV&lt;/strong&gt; for image processing and MRZ region detection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tesseract OCR&lt;/strong&gt; for text recognition, with custom-trained data for MRZ-specific characters&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NumPy&lt;/strong&gt; for efficient numerical operations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ONNX&lt;/strong&gt; to run optimized machine learning models.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;You can install fastmrz via pip:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;fastmrz  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to Use fastmrz
&lt;/h3&gt;

&lt;p&gt;Here’s a quick example to get started:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastmrz&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastMRZ&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;fast_mrz&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastMRZ&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;passport_mrz&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fast_mrz&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_mrz&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;../data/passport_uk.jpg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;JSON:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;passport_mrz&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;passport_mrz&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fast_mrz&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_mrz&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;../data/passport_uk.jpg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TEXT:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;passport_mrz&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mrz_type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TD3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;document_type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;P&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;country_code&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GBR&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;surname&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PUDARSAN&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;given_name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HENERT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;document_number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;707797979&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;nationality&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GBR&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;date_of_birth&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1995-05-20&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sex&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;M&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;date_of_expiry&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2017-04-22&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SUCCESS&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="n"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;GBRPUDARSAN&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;HENERT&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;
&lt;span class="mi"&gt;7077979792&lt;/span&gt;&lt;span class="n"&gt;GBR9505209M1704224&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Understanding MRZ Types
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;FastMRZ&lt;/code&gt; supports various MRZ formats, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TD-1 format&lt;/strong&gt; (3 lines, 30 characters each) commonly used in ID cards&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TD-2 format&lt;/strong&gt; (2 lines, 36 characters each) found in some visas and older IDs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TD-3 format&lt;/strong&gt; (2 lines, 44 characters each) used in international passports&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The library automatically detects the format and processes it accordingly, making it versatile for different document types.&lt;/p&gt;

&lt;h2&gt;
  
  
  Applications
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Identity Verification:&lt;/strong&gt; Automate ID validation processes in security and travel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FinTech:&lt;/strong&gt; Enhance KYC processes with seamless document verification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Travel and Immigration:&lt;/strong&gt; Streamline data capture for passports and visas.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Government Applications:&lt;/strong&gt; Assist in border control and other regulatory activities.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;FastMRZ&lt;/code&gt; enables more accessibility and efficiency of document processing. Be it the implementation of a border control system, working on identity verification software, or any document processing application-the MRZ extraction definitely will be done with confidence by using the power of FastMRZ.&lt;/p&gt;

&lt;p&gt;You can fork the project on GitHub and star it, if you find it useful. Your stars help drive the continued development of this open-source tool.&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>opensource</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
