1

I have a rotated bounding box for a face and I like to rotate the image to to deskew the bounding box. Each bounding box is defined by 4 vertices in a python list like [["x":12, "y":24] ... ]. I found some links describing such transformation but they all do this in C++ level opencv so I could not see what is going on between variables passing function to function.

I use opencv 2.4.12 on python but could not find a way to do so. Would you share some pointers to help me?

Community
  • 1
  • 1
erogol
  • 13,156
  • 33
  • 101
  • 155
  • are those 4 vertices a perfect (rotated) rectangle? 4 vertices can form an arbitrary quad. If you have a cv::RotatedRect instead, you know the angle and center directly and don't need to use the 4-vertices which make it more complicated. – Micka Jul 25 '16 at 09:44
  • These are just random vertices forming a rotated rectangle but in a python list as defined – erogol Jul 25 '16 at 09:56
  • for your pointlist you can use `rect = cv2.minAreaRect(cnt) # rect = ((center_x,center_y),(width,height),angle)` so you 'll know the center and the angle to rotate. Then you can create a homography and use warpAffine to rotate accordingly. – Micka Jul 25 '16 at 10:15

0 Answers0