I am trying to use SolvePnP to render 3D objects on top of Aruco markers in Android, and this is how I am using it:
solvePnP(marker.getObjPoints(), cornersPoints2f, marker.getCameraMatrix(), (MatOfDouble) marker.getDistortionCoeff(), rvec, tvec);
marker.getObjPoints are the object points returned by cv::estimatePoseSingleMarkers()
cornersPoints2f is a MatOfPoint2f object (Java equivalent of std::vector)
marker.getCameraMatrix() is the Intrinsic/camera matrix obtained at first through calibration but then stored on disk.
marker.getDistortionCoeff() is the vector of distortion coefficients.
rvec and tvec are the output vectors for SolvePnP.
What my issue is:
SolvePnP fails at run-time because an assert fails. The assert fails because it keeps checking if
cornersPoints2f is 3-channel or 4-channel, and it’s neither. I don’t know why, but
cornersPoints2f is always 2-Channel. Not something I can change. When the markers are detected, it is just set to 2-Channel and I don’t know what I can do about it.
Here’s the assert in-case you are interested.
What can I do about this? as far as I know, I can’t render objects at all without the SolvePnP step. And I currently can’t make it work. Any ideas as to what I can do?