OpenCV: Calculate angle between camera and pixel

后端 未结 2 1008
悲哀的现实
悲哀的现实 2020-12-08 23:09

I\'d like to know how I can go about calculating the angle of some pixel in a photo relative to the webcam that I\'m using. I\'m new to this sort of thing and I\'m using a

2条回答
  •  死守一世寂寞
    2020-12-08 23:18

    Recipe:

    1 - Calibrate the camera, obtaining the camera matrix K and distortion parameters D. In OpenCV this is done as described in this tutorial.

    2 - Remove the nonlinear distortion from the pixel positions of interest. In OpenCV is done using the undistortPoints routine, without passing arguments R and P.

    3 - Back-project the pixels of interest into rays (unit vectors with the tail at the camera center) in camera 3D coordinates, by multiplying their pixel positions in homogeneous coordinates times the inverse of the camera matrix.

    4 - The angle you want is the angle between the above vectors and (0, 0, 1), the vector associated to the camera's focal axis.

提交回复
热议问题