本文整理汇总了C++中Point2f::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2f::set方法的具体用法?C++ Point2f::set怎么用?C++ Point2f::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2f
的用法示例。
在下文中一共展示了Point2f::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _optimize
double ImageTracker::_optimize(TMath::TMatrixd& deltaRotation, TMath::TVectord& deltaTranslation, int level)
{
using namespace TMath;
ConstImage<uchar> secondImage = m_secondFrameImagePyramid[level];
float scale = 1.0f / (float)(1 << level);
double A_raw[21];
TVectord B(6);
B.setZero();
int i, j, k, t;
for (i = 0; i < 21; ++i)
A_raw[i] = 0.0;
Point2i p;
Point2i pos_i;
Point2f pos;
Point2f subpix;
float w_tl, w_tr, w_bl, w_br;
float dt, wdt, weight;
TVectord v;
double error = 0.0;
for (std::size_t f = 0; f < m_featuresInfo.size(); ++f) {
FeatureInfo& featureInfo = m_featuresInfo[f];
if (!featureInfo.visible)
continue;
v = deltaRotation * featureInfo.localPosition + deltaTranslation;
if (v(2) <= std::numeric_limits<float>::epsilon()) {
featureInfo.visible = false;
continue;
}
pos = m_secondCamera->project(Point2d(v(0) / v(2), v(1) / v(2))).cast<float>() * scale;
pos_i.set((int)std::floor(pos.x), (int)std::floor(pos.y));
if ((pos_i.x < begin.x) || (pos_i.y < begin.y) ||
(pos_i.x > end.x) || (pos_i.y > end.y)) {
featureInfo.visible = false;
continue;
}
subpix.set((float)(pos.x - pos_i.x), (float)(pos.y - pos_i.y));
w_tl = (1.0f - subpix.x) * (1.0f - subpix.y);
w_tr = subpix.x * (1.0f - subpix.y);
w_bl = (1.0f - subpix.x) * subpix.y;
w_br = subpix.x * subpix.y;
const uchar* imageStr = secondImage.pointer(pos_i.x, pos_i.y - m_cursorSize.y);
const uchar* imageStrNext = &imageStr[secondImage.width()];
k = 0;
const float* pixels_cache = featureInfo.pixels_cache;
const double* jacobian_cache = featureInfo.jacobian_cache;
for (p.y = - m_cursorSize.y; p.y <= m_cursorSize.y; ++p.y) {
for (p.x = - m_cursorSize.x; p.x <= m_cursorSize.x; ++p.x, ++k) {
dt = (imageStr[p.x] * w_tl +
imageStr[p.x + 1] * w_tr +
imageStrNext[p.x] * w_bl +
imageStrNext[p.x + 1] * w_br) - *pixels_cache;
weight = m_gaussian[k] * TukeyRobustCost::weight(dt * dt, m_sigmaSquared);
wdt = dt * weight;
error += wdt * dt;
t = 0;
for (i = 0; i < 6; ++i) {
for (j = 0; j <= i; ++j) {
A_raw[t] += jacobian_cache[i] * jacobian_cache[j] * weight;//J * J.transposed() * w
++t;
}
B(i) += jacobian_cache[i] * wdt; // J * w
}
++pixels_cache;
jacobian_cache = &jacobian_cache[6];
}
imageStr = imageStrNext;
imageStrNext = &imageStrNext[secondImage.width()];
}
++m_countTrackedFeatures;
}
if (m_countTrackedFeatures == 0)
return std::numeric_limits<double>::max();
TMatrixd A(6, 6);
t = 0;
for (i = 0; i < 6; ++i) {
for (j = 0; j < i; ++j) {
A(i, j) = A(j, i) = A_raw[t];
//.........这里部分代码省略.........