First port here, don't hesitate in correcting me if I forgot to specify something essential in this post.
I have a little problem with some calculations I made, and I'm unable to solve this alone.
I'm using Optical Character Recognition (OCR) with Python to read some street signs. Most of the street signs are read correctly, but some of them are rotated, and so the OCR image frame and the street sign frame don't align with each other.
Image with the two rectangles - the black one being the OCR image frame, and the red one being the street sign
The width and height of the red rectangle (a, b) are in millimeters, and the width and height of the black rectangle (x, y) are in pixels.
Is there any way to know what which coordinates (in pixels) of the black rectangle, the red rectangle's vertexes touch? Is it actually even feasible?
Thank you for your help!
If we call the small piece of the long side $w$ and the small piece of the vertical side $z$ we have $$(x-w)^2+z^2=a^2\\(y-z)^2+w^2=b^2$$ and we are searching for $w,z$ if we know all the other variables. $$x^2-2xw+w^2+z^2=a^2\\ y^2-2yz+z^2+w^2=b^2\\ x^2-y^2+2yz-2wx=a^2-b^2\\ w=\frac{x^2-y^2+2yz-a^2+b^2}{2x}$$ Plug this into one of the equations and you have a quadratic in $z$