## 3 The Proposed Method
### Perspective Distortion  
For perspective undistorted QR Codes (only shifted, scaled, rotated, or sheared) it is sufficient to have only 3 points to set-up the affine transformation from a square to destination parallelogram. However, for perspective (projective) distorted QR Codes 4 points are required to set-up perspective transformation from a square to destination quadrilateral [21]. Some authors (for example [7; 22]) search for Alignment Pattern to obtain 4 th point. However, version 1 QR Codes does not have Alignment Pattern, so we have decided not to rely on Alignment Patterns. Figure 11: Quiet Zones. Figure 12: Bounding Box. Instead of that we use an iterative approach to find the opposite sides to P\({}_{2}\)-P\({}_{1}\) and P\({}_{2}\)-P\({}_{3}\), which aligns to QR Code borders. 1. We start from initial estimate of P\({}_{4}\) as an intersection of the line L\({}_{1}\) and L\({}_{3}\), where L\({}_{1}\) is parallel to P\({}_{2}\)-P\({}_{3}\) and L\({}_{3}\) is parallel to P\({}_{2}\)-P\({}_{1}\) (Figure 13a). 2. We count the number of pixels which are common to the line L\({}_{3}\) and the QR Code for each third of the line L\({}_{3}\) (Figure 13a). 3. We shift the line L\({}_{3}\) by width of one module away from the QR Code and again we count the number of pixels which are common to the shifted line L\({}_{3^{\prime}}\) and the QR Code. The module width is estimated as \(MW\) (from Equation (6)) (Figure 13b). 4. We compare overlaps of the line L\({}_{3}\) from the step 2 and 3, and 1. If L\({}_{3}\) was whole in the QR Code and the shifted L\({}_{3^{\prime}}\) is out of the QR Code, then initial estimation of P\({}_{4}\) is good and we end. 2. If L3 was whole in the QR Code and 3 rd third of the shifted L\({}_{3^{\prime}}\) is again in the QR Code, then we continue by step 5. 3. If 3 rd third of L\({}_{3}\) was in quiet zone and 2 nd and 3 rd third of the shifted L\({}_{3^{\prime}}\) is in the quiet zone or if 2 nd third of L\({}_{3}\) was in the quiet zone and 1 st and 2 nd third of the shifted L\({}_{3^{\prime}}\) is in the quiet zone then we continue by step 6. 5. We start to move P\({}_{4}\) end of line segment P\({}_{3}\)-P\({}_{4}\) away from the QR Code until 3 rd third of L\({}_{3}\) touches the quiet zone (Figure 13c). 6. We start to move P\({}_{4}\) end of line segment P\({}_{3}\)-P\({}_{4}\) towards the QR Code until 3 rd third of L\({}_{3}\) touches the QR Code. 7. We apply the same procedure also to the line L\({}_{1}\) like for the line L\({}_{3}\). 8. The intersection of the shifted lines L\({}_{1}\) and L\({}_{3}\) is a new P\({}_{4}\) position. Once the position of 4 th point, P\({}_{4}\), is obtained, perspective transformation from the source square representing the ideal QR Code to destination quadrilateral representing the real QR Code in the image can be set-up (Figure 14). Figure 13: Perspective distortion: (**a**) initial estimate of the point P\({}_{4}\) and lines L\({}_{1}\), L\({}_{3}\); (**b**) first shift of the line L\({}_{3^{\prime}}\) (**c**) second shift of the line L\({}_{3}\). Using equations [21]:  
\(u=\frac{ax+by+c}{gx+hy+1}\), \(v=\frac{dx+cy+f}{gx+hy+1}\), where the transformation coefficients can be calculated from the coordinates of the points \(\mathrm{P_{1}}(u_{1},v_{1})\), \(\mathrm{P_{2}}(u_{2},v_{2})\), \(\mathrm{P_{3}}(u_{3},v_{3})\), \(\mathrm{P_{4}}(u_{4},v_{4})\) as  
\[a =(u_{3}-u_{2})/A+gu_{3},\;b=(u_{1}-u_{2})/A+hu_{1},\;c=u_{2}\] \[d =(v_{3}-v_{2})/A+gv_{3},\;e=(v_{1}-v_{2})/A+hv_{1},\;f=v_{2}\] \[g =\left| \begin{array}{cc}du_{3}&du_{2}\\ dv_{3}&dv_{2}\\ \hline du_{1}&du_{2}\\ dv_{1}&dv_{2}\end{array} \right|\), \(h=\left| \begin{array}{cc}du_{1}&du_{3}\\ dv_{1}&dv_{3}\\ \hline du_{1}&du_{2}\\ dv_{1}&dv_{2}\end{array}