Quantcast
Viewing all articles
Browse latest Browse all 41027

Rotating target changes distances computed with solvePnP

I've been working on finding the distance to a target (of known real-world dimensions). The distance seems consistent enough when viewed from a forward-facing angle, but when I rotate the target (without translating it) the distance changes: ![image description](http://i.imgur.com/DviIbs3.gif) Here is the relevant code: vector objectPoints; objectPoints.push_back(Point3f(-1, -1, 0)); objectPoints.push_back(Point3f(-1, 1, 0)); objectPoints.push_back(Point3f(1, 1, 0)); objectPoints.push_back(Point3f(1, -1, 0)); Mat objectPointsMat(objectPoints); Mat rvec; Mat tvec; solvePnP(objectPointsMat, inputContour, cameraMatrix, distortionCoeffs, rvec, tvec); double tx = tvec.at(0, 0); double ty = tvec.at(1, 0); double tz = tvec.at(2, 0); double dist = std::sqrt(tx*tx + ty*ty + tz*tz); char *str; asprintf(&str, "DIST = %7.3f", dist); putText(original, str, Point(0, original.size().height), CV_FONT_HERSHEY_PLAIN, 3, Scalar(255, 255, 255), 3);

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>