Revision history [back]

solvePnpRansac GPU assertion failed

I'm trying to use the gpu version of solvePnPRansac to estimate the pose of the camera, but I get the following error:

OpenCV Error: Assertion failed (object.rows == 1 && object.cols > 0 && object.type() == CV_32FC3) in cv::gpu::solvePnPRansac, file C:\opencv\sources\modules\gpu\src\calib3d.cpp, line 218

If I run my code using the solvePnP or cpu-based solvePnPRansac, everything works fine.

I took a look into the code of calib3d.cpp at line 218 and the problem seems to be related to the first parameter of the function (that should be the list of the reference points).

It seems that the format that I use to send the reference point to the function is wrong, but I didn't figure out which one is correct.

Here is my code:

// Reference Points and Detected Points for Pose Estimation
std::vector<cv::Point3f> refMarkerPoint;
std::vector<cv::Point2f> markerPoints;

...

cv::Mat rvec = cv::Mat::zeros(1, 3, CV_32F);
cv::Mat tvec = cv::Mat::zeros(1, 3, CV_32F);
cv::Mat rotation = cv::Mat::zeros(1, 3, CV_32F);
cv::Mat tvec2 = cv::Mat::zeros(1, 3, CV_32F);
Vec3d eulerAngles;

...

if (cx_right != 0 && cx_left != 0 && markerPoints.size() > 0)
{
marker_detected = 1;
//solvePnPRansac(refMarkerPoint, markerPoints, cameraMatrix, distCoeffs, rvec, tvec, false, 20, 4, 20, noArray(), CV_ITERATIVE); // CV_EPNP, CV_P3P
//solvePnP(Mat(refMarkerPoint), Mat(markerPoints), cameraMatrix, distCoeffs, rvec, tvec);
gpu::solvePnPRansac(Mat(refMarkerPoint), Mat(markerPoints), cameraMatrix, distCoeffs, rvec, tvec);

cv::Rodrigues(rvec, rotation);

...
}


Do you have any suggestions?