本文整理汇总了C++中ofVec2f::lengthSquared方法的典型用法代码示例。如果您正苦于以下问题:C++ ofVec2f::lengthSquared方法的具体用法?C++ ofVec2f::lengthSquared怎么用?C++ ofVec2f::lengthSquared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofVec2f
的用法示例。
在下文中一共展示了ofVec2f::lengthSquared方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getEstimatedCameraPose
float Manager::getEstimatedCameraPose(cv::Size image_size,
cv::Mat& camera_matrix, cv::Mat& rvec,
cv::Mat& tvec, float force_fov, ofVec2f lens_offset_pix)
{
if (markers.size() <= 6) return -1;
markUpdated();
using namespace ofxCv;
using namespace cv;
vector<cv::Point3f> object_points;
vector<cv::Point2f> image_points;
for (int i = 0; i < markers.size(); i++)
{
Marker* o = markers[i].get();
object_points.push_back(toCv(o->object_pos));
image_points.push_back(toCv((ofVec2f)o->getPosition()));
}
cv::Mat dist_coeffs = cv::Mat::zeros(8, 1, CV_64F);
float fov = 60;
if (force_fov != 0) fov = force_fov;
float f = (image_size.height / 2) * tan(ofDegToRad(fov / 2.0));
camera_matrix = (cv::Mat_<double>(3, 3) << f, 0, image_size.width / 2 + lens_offset_pix.x, 0, f,
image_size.height / 2 + lens_offset_pix.y, 0, 0, 1);
float rms = 0;
if (force_fov == 0)
{
vector<cv::Mat> rvecs;
vector<cv::Mat> tvecs;
vector<vector<cv::Point3f> > object_points_arr(1);
vector<vector<cv::Point2f> > image_points_arr(1);
object_points_arr[0] = object_points;
image_points_arr[0] = image_points;
int flags = 0;
flags |= CV_CALIB_USE_INTRINSIC_GUESS;
flags |= CV_CALIB_FIX_ASPECT_RATIO;
flags |= CV_CALIB_ZERO_TANGENT_DIST;
flags |= (CV_CALIB_FIX_K1 | CV_CALIB_FIX_K2 | CV_CALIB_FIX_K3 |
CV_CALIB_FIX_K4 | CV_CALIB_FIX_K5 | CV_CALIB_FIX_K6 |
CV_CALIB_RATIONAL_MODEL);
if (lens_offset_pix.lengthSquared() > FLT_EPSILON) {
flags |= CV_CALIB_FIX_PRINCIPAL_POINT;
}
rms = cv::calibrateCamera(object_points_arr, image_points_arr, image_size,
camera_matrix, dist_coeffs, rvecs, tvecs,
flags);
rvec = rvecs[0];
tvec = tvecs[0];
}
else
{
cv::Mat rvecs;
cv::Mat tvecs;
cv::solvePnP(object_points, image_points, camera_matrix, dist_coeffs, rvecs, tvecs);
rms = 1;
rvec = rvecs;
tvec = tvecs;
}
return rms;
}