ok so, I added a Z=0 to the object points. then solvePnP is happy.
if that was the issue, you should have seen a violated assertion like so:
cv2.error: OpenCV(4.5.2-dev) P:\opencv\modules\calib3d\src\solvepnp.cpp:826: error: (-215:Assertion failed) ( (npoints >= 4) || (npoints == 3 && flags == SOLVEPNP_ITERATIVE && useExtrinsicGuess) || (npoints >= 3 && flags == SOLVEPNP_SQPNP) ) && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) in function 'cv::solvePnPGeneric'
if that was the issue and you didn’t see that assertion message, something is messed up in your setup.
here’s the code I used:
objp = np.float32([0,0,0, 384,0,0, 384,216,0, 0,216,0]).reshape((-1, 1, 3))
imp = np.float32([253,34, 584,152, 692,316, 121,280]).reshape((-1, 1, 2))
K = np.float32([[260.257998425127, 0, 386.6963736491591], [0, 260.1583925187085, 234.7746525148251], [0,0,1]])
dc = np.float32([-0.2666308246430311, 0.06474699227144737, 0.0003621024764932747, -0.000726010205813438, -0.006384634912197317])
(rv, rvec, tvec) = cv.solvePnP(objectPoints=objp, imagePoints=imp, cameraMatrix=K, distCoeffs=dc)
# rv
True
# rvec
array([[-0.48069],
[-0.39676],
[-0.01492]])
# tvec
array([[ -95.71424],
[-145.90773],
[ 129.29055]])
results seem somewhat sensitive to the exact distortion coefficients. oh well. at least it doesn’t just return nothing.