I am building a machine for placing SMD elements. I'm almost finished, but I've got one problem.
The elements that I'm placing must be placed in a specific orientation. I want to show the picked element to a camera from its bottom, so that my program can find its corners, and determine how many degrees it has been rotated. Based on this, my program should correct the rotation, so that the element will be placed correctly.
All my attemps to detect the angle have failed. Do you have any ideas ?
Examples:
Here are two simplified illustrations of incorrectly oriented elements, as the camera might see them:
I want to get the angle by which I need to rotate the element to get it to the correct orientation, as shown below: