I successfully implemented the OpenCV square-detection example in my test application, but now need to filter the output, because it\'s quite messy - or is my code wrong?
What you need is a quadrangle instead of a rotated rectangle.
RotatedRect
will give you incorrect results. Also you will need a perspective projection.
Basicly what must been done is:
I implemented a class Quadrangle
which takes care of contour to quadrangle conversion and will also transform it over the right perspective.
See a working implementation here: Java OpenCV deskewing a contour