title: How to detect a pattern (such as a QR code) on a scanned paper so that it can be correctly rotated/scaled/identified?
body: <p>I have PDF files or JPG images that I need to print (these are formulars that will be filled in by hand), and I need that:</p>
  
  <ul>
  <li><p>after scan, the image should be rotated / scaled perfectly with Python, so that I can access to certain parts of the formular with x, y coordinates</p></li>
  <li><p>the scanned images should be recognized with a number ID.</p></li>
  </ul>
  
  <p><strong>What kind of pattern should I add on the formular paper, so that a Python library (which one?) will be able to crop it / rotate it / identify it with an ID?</strong></p>
  
  <p>I was thinking about adding a QR-code (containin a number ID) on top left of paper, and a QR-code on bottom right of the paper, or maybe also <a href="https://fr.wikipedia.org/wiki/Hirondelle_(imprimerie)" rel="noreferrer">"hirondelles"</a> symbols:</p>
  
  <p><img src="https://i.stack.imgur.com/ecBiC.jpg" width="100" /> <img src="https://i.stack.imgur.com/wgvQo.jpg" width="200" /></p>
  
  <p>The QR code would be generated with <a href="https://pypi.org/project/qrcode/" rel="noreferrer">qrcode</a> library:</p>
  
  <pre><code>import qrcode
  img = qrcode.make('ID1138934')
  </code></pre>
  
  <p>and added on top the PDF with <a href="https://stackoverflow.com/a/31707039/1422096">this method</a>.</p>
  
  <hr>
  
  <p>Note: </p>
  
  <ul>
  <li><p>I've read the question <a href="https://stackoverflow.com/questions/27233351/how-to-decode-a-qr-code-image-in-preferably-pure-python">How to decode a QR-code image in (preferably pure) Python?</a>, but this does not detect the QR-code on a scanned paper; it only takes a PNG containing the QR-code only as input.</p></li>
  <li><p><a href="https://i.stack.imgur.com/Xiw4H.jpg" rel="noreferrer">Here is a JPG</a>, example of scanned document:</p></li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/Xiw4H.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Xiw4H.jpg" alt="enter image description here"></a></p>