Algorithm for matching position and size of two rectangles
<p>I'm looking for a algorithm that computes the following: I have an image with a predefined area (the green one on the attached image). The user draws the red rectangle and the algorithm should compute whether the red rectangle matches approximately the green one. For example the position of the red rectangle on the attached picture would be ok.</p>

<p>What is a good way to compute this? Is there any best practice algorithm?</p>

<p>My idea is to compute the middle of the red rectangle and then to determine whether the middle is inside the green rectangle. In addition, I would calculate if the length and height match approximately the length and height of the green one (25% more or less). </p>

<p>Is this a good idea? Any other suggestion?</p>

<p><a href="https://i.stack.imgur.com/LVYVR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LVYVR.png" alt="enter image description here"></a></p>