diff --git a/modules/gpu/src/calib3d.cpp b/modules/gpu/src/calib3d.cpp index 5fdc3734a5..7530f372d2 100644 --- a/modules/gpu/src/calib3d.cpp +++ b/modules/gpu/src/calib3d.cpp @@ -301,13 +301,10 @@ void cv::gpu::solvePnpRansac(const Mat& object, const Mat& image, const Mat& cam p_transf.x = rot[0] * p.x + rot[1] * p.y + rot[2] * p.z + transl[0]; p_transf.y = rot[3] * p.x + rot[4] * p.y + rot[5] * p.z + transl[1]; p_transf.z = rot[6] * p.x + rot[7] * p.y + rot[8] * p.z + transl[2]; - if (p_transf.z > 0.f) - { - 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->push_back(i); - } + 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->push_back(i); } } } diff --git a/modules/gpu/src/cuda/calib3d.cu b/modules/gpu/src/cuda/calib3d.cu index a9b9588f3d..171fc8cb6b 100644 --- a/modules/gpu/src/cuda/calib3d.cu +++ b/modules/gpu/src/cuda/calib3d.cu @@ -143,14 +143,11 @@ namespace cv { namespace gpu rot_mat[0].x * p.x + rot_mat[0].y * p.y + rot_mat[0].z * p.z + transl_vec.x, rot_mat[1].x * p.x + rot_mat[1].y * p.y + rot_mat[1].z * p.z + transl_vec.y, rot_mat[2].x * p.x + rot_mat[2].y * p.y + rot_mat[2].z * p.z + transl_vec.z); - if (p.z > 0) - { - p.x /= p.z; - p.y /= p.z; - float2 image_p = image[i]; - if (sqr(p.x - image_p.x) + sqr(p.y - image_p.y) < dist_threshold) - ++num_inliers; - } + p.x /= p.z; + p.y /= p.z; + float2 image_p = image[i]; + if (sqr(p.x - image_p.x) + sqr(p.y - image_p.y) < dist_threshold) + ++num_inliers; } extern __shared__ float s_num_inliers[]; diff --git a/modules/gpu/test/test_calib3d.cpp b/modules/gpu/test/test_calib3d.cpp index d03b3d3be1..4ea6da1e8d 100644 --- a/modules/gpu/test/test_calib3d.cpp +++ b/modules/gpu/test/test_calib3d.cpp @@ -128,7 +128,10 @@ TEST(solvePnpRansac, accuracy) Mat rvec; Mat tvec; - solvePnpRansac(object, image, camera_mat, Mat(), rvec, tvec, SolvePnpRansacParams()); + SolvePnpRansacParams params; + vector inliers; + params.inliers = &inliers; + solvePnpRansac(object, image, camera_mat, Mat(), rvec, tvec, params); ASSERT_LE(norm(rvec - rvec_gold), 1e-3f); ASSERT_LE(norm(tvec - tvec_gold), 1e-3f);