# How to calculate parameters for perspective transformation matrix

1. Find a photo that does not get recognized by alpr
2. Open it in gimp
3. Use Perspective tool
4. Find the best transformation that makes the license plate an ideal reectangle by trying to move as little points as possible
5. Take a note of coordinates of each of the points you moved (where they were before and after). Gather change for all four corners, like so:

0,0 → 0,0
0,3024 → -296,1292
4040,3024 → 4024,3316
4040,0 → 4040,0

6. Put those coordinates into the command:

```
node ./lib/calculate-perspective-coefficients.js demo.jpg 0 0 0 0    0 3024 -206 1292    4040 3024 4024 3316    4040 0 4040 0
```

It will output the forward and backward coefficients for the matrix transform.
