From: Alexey Spizhevoy Date: Wed, 2 Mar 2011 08:04:08 +0000 (+0000) Subject: refactored gpu::solvePnpRansac a bit X-Git-Tag: accepted/2.0/20130307.220821~3441 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74c398e6b71f8124f3ec5891674250d59ed20971;p=profile%2Fivi%2Fopencv.git refactored gpu::solvePnpRansac a bit --- diff --git a/modules/gpu/src/calib3d.cpp b/modules/gpu/src/calib3d.cpp index 6898713..5fdc373 100644 --- a/modules/gpu/src/calib3d.cpp +++ b/modules/gpu/src/calib3d.cpp @@ -276,23 +276,24 @@ void cv::gpu::solvePnpRansac(const Mat& object, const Mat& image, const Mat& cam int num_inliers = static_cast(best_score); // Extract the best hypothesis data + Mat rot_mat = rot_matrices.colRange(best_idx.x * 9, (best_idx.x + 1) * 9).reshape(0, 3); Rodrigues(rot_mat, rvec); rvec = rvec.reshape(0, 1); + tvec = transl_vectors.colRange(best_idx.x * 3, (best_idx.x + 1) * 3).clone(); tvec = tvec.reshape(0, 1); // Build vector of inlier indices if (params.inliers != NULL) { - params.inliers->resize(num_inliers); + params.inliers->clear(); + params.inliers->reserve(num_inliers); - Point3f p; - Point3f p_transf; + Point3f p, p_transf; Point2f p_proj; const float* rot = rot_mat.ptr(); const float* transl = tvec.ptr(); - int inlier_id = 0; for (int i = 0; i < num_points; ++i) { @@ -305,7 +306,7 @@ void cv::gpu::solvePnpRansac(const Mat& object, const Mat& image, const Mat& cam p_proj.x = p_transf.x / p_transf.z; p_proj.y = p_transf.y / p_transf.z; if (norm(p_proj - image_normalized.at(0, i)) < params.max_dist) - (*params.inliers)[inlier_id++] = i; + params.inliers->push_back(i); } } }