How do I get the 3D and 2D points of an object to use solvePnPRansac()?

I’m trying to track a ball using opencv java and I’m wanting to use solvePnPRansac in my calcuations to find distance and angle to it. Problem is that while I have the distortion coefficents and the camera matrix I don’t know how to get the 2d and 3d points? I know how to get contours and moments, is that what I want?

yea that’s the problem. unsolvable / not feasible, i’d think
(still, have a look here)

you probably also don’t want the pose of the ball (that is: it’s rotational angles), more like the distance / angle to the camera

so you can determine the balls position / size in 2d, and knowing f from the camera matrix, you can triangulate the distance in 3d

I think you maybe right, I didn’t realize the points are mostly determined beforehand. Do you know of any good resources for the triangulation method?