From: PhilLab Date: Mon, 25 Aug 2014 15:06:17 +0000 (+0200) Subject: PnP solver: fixed element-wise access X-Git-Tag: submit/tizen_ivi/20141117.190038~2^2~148^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e95c33dd189e690614e5548fc084f2ac9b601532;p=profile%2Fivi%2Fopencv.git PnP solver: fixed element-wise access --- diff --git a/modules/calib3d/src/dls.h b/modules/calib3d/src/dls.h index 30321fc..d379844 100644 --- a/modules/calib3d/src/dls.h +++ b/modules/calib3d/src/dls.h @@ -24,9 +24,9 @@ private: { for(int i = 0; i < N; i++) { - p.at(0,i) = opoints.at(0,i).x; - p.at(1,i) = opoints.at(0,i).y; - p.at(2,i) = opoints.at(0,i).z; + p.at(0,i) = opoints.at(i).x; + p.at(1,i) = opoints.at(i).y; + p.at(2,i) = opoints.at(i).z; // compute mean of object points mn.at(0) += p.at(0,i); @@ -34,12 +34,12 @@ private: mn.at(2) += p.at(2,i); // make z into unit vectors from normalized pixel coords - double sr = std::pow(ipoints.at(0,i).x, 2) + - std::pow(ipoints.at(0,i).y, 2) + (double)1; + double sr = std::pow(ipoints.at(i).x, 2) + + std::pow(ipoints.at(i).y, 2) + (double)1; sr = std::sqrt(sr); - z.at(0,i) = ipoints.at(0,i).x / sr; - z.at(1,i) = ipoints.at(0,i).y / sr; + z.at(0,i) = ipoints.at(i).x / sr; + z.at(1,i) = ipoints.at(i).y / sr; z.at(2,i) = (double)1 / sr; } diff --git a/modules/calib3d/src/epnp.h b/modules/calib3d/src/epnp.h index dd42b01..2619f75 100644 --- a/modules/calib3d/src/epnp.h +++ b/modules/calib3d/src/epnp.h @@ -27,12 +27,12 @@ class epnp { { for(int i = 0; i < number_of_correspondences; i++) { - pws[3 * i ] = opoints.at(0,i).x; - pws[3 * i + 1] = opoints.at(0,i).y; - pws[3 * i + 2] = opoints.at(0,i).z; + pws[3 * i ] = opoints.at(i).x; + pws[3 * i + 1] = opoints.at(i).y; + pws[3 * i + 2] = opoints.at(i).z; - us[2 * i ] = ipoints.at(0,i).x*fu + uc; - us[2 * i + 1] = ipoints.at(0,i).y*fv + vc; + us[2 * i ] = ipoints.at(i).x*fu + uc; + us[2 * i + 1] = ipoints.at(i).y*fv + vc; } } double reprojection_error(const double R[3][3], const double t[3]); diff --git a/modules/calib3d/src/p3p.h b/modules/calib3d/src/p3p.h index 57f8d7d..00d99ae 100644 --- a/modules/calib3d/src/p3p.h +++ b/modules/calib3d/src/p3p.h @@ -37,11 +37,11 @@ class p3p points.resize(20); for(int i = 0; i < 4; i++) { - points[i*5] = ipoints.at(0,i).x*fx + cx; - points[i*5+1] = ipoints.at(0,i).y*fy + cy; - points[i*5+2] = opoints.at(0,i).x; - points[i*5+3] = opoints.at(0,i).y; - points[i*5+4] = opoints.at(0,i).z; + points[i*5] = ipoints.at(i).x*fx + cx; + points[i*5+1] = ipoints.at(i).y*fy + cy; + points[i*5+2] = opoints.at(i).x; + points[i*5+3] = opoints.at(i).y; + points[i*5+4] = opoints.at(i).z; } } void init_inverse_parameters();