### Contour perspective warp

I want to automate a ~~process, ~~process where text is recognized from a specific card ~~type.~~type:

I will first explain what I dit so far. First I converted the image to a grayscale one:

Then I applied `Canny`

:

By the result of this, it was easy to find the largest contour:

So far so good. The problem is: I have a shape here which fits in rectangle. However, the perspective is not top-down. Which implies that it is not possible to use `boundingRect`

. Basically I'm in need of an algorithm to find the orientation of this contour.

I have no idea how to do this. Is there something I am missing? How would you do this?