Solve PnP - Precission

I’m working on a project to detect an object in a picture and further make different measurements on that object. For that I need to know where my camera is located. My camera is on a fixed location. So I only need to calculate that position once. Also I can make sure that I know the translation vector and also the yaw of my camera.

I just need to calculate pitch and roll. For this I’m currently using Solvepnp. So it’s the following code:

_, rvec, tvec, inliers = cv2.solvePnPRansac(objectPoints, imagePoints, mtx, distCoeffs,1, cv2.SOLVEPNP_EPNP)
Rt = cv2.Rodrigues(rvec)[0]
R = np.transpose(Rt)

As the result I get:
r=4.931548525789813, p=3.384411149422294, ya=179.73325314324563

I’m using 12 points which are located on a plane in the image (so actually z=0 for every coordinate). It’s not possible to use more points. The result is not precise enough, so I can’t make sure my measurement later has the precision I need.

I need to make my algorithm more precise. As im pretty new in coding and especially computer vision, I may miss some experience. So my question is:

Is there a way to make it more precise? Is there another method because I have a fixed translation?

Thanks for any help :slight_smile: