Rotating back points from a rotated image in OpenCV

前端 未结 4 892
攒了一身酷
攒了一身酷 2020-12-17 16:43

I’m having troubles with rotation. What I want to do is this:

  • Rotate an image
  • Detect features on the rotated image (points)
  • Rotate back the p
4条回答
  •  [愿得一人]
    2020-12-17 17:12

    • You need to rotate your points accorning to center point of your image.
    • Here x and y are your points which you want to rotate, imageCenter_x aand _y is center point of your image.
    • Below is my code.

      angle = angle * (M_PI / 180);  
      float axis_x = x - imageCenter_x;  
      float axis_y = y - imageCenter_y;       
      
      x = axis_x * cos(angle) + axis_y * sin(angle);   
      y = (-axis_x) * sin(angle) + axis_y * cos(angle);
      
      x = x + imageCenter_x;  
      y = y + imageCenter_y;
      

提交回复
热议问题