30 #include <mrpt/otherlibs/do_opencv_includes.h> 42 #ifdef MRPT_OS_WINDOWS 56 const CImage&
img,
const CImage& patch_img,
size_t& x_max,
size_t& y_max,
57 double& max_val,
int x_search_ini,
int y_search_ini,
int x_search_size,
64 CvPoint min_point, max_point;
67 (x_search_ini < 0 || y_search_ini < 0 || x_search_size < 0 ||
82 const_cast<IplImage*>(
img.getAs<IplImage>()));
84 const_cast<IplImage*>(patch_img.
getAs<IplImage>()));
89 const int patch_w = patch_im.
getWidth();
94 x_search_size = im_w - patch_w;
95 y_search_size = im_h - patch_h;
99 if ((x_search_ini + x_search_size + patch_w) > im_w)
100 x_search_size -= (x_search_ini + x_search_size + patch_w) - im_w;
102 if ((y_search_ini + y_search_size + patch_h) > im_h)
103 y_search_size -= (y_search_ini + y_search_size + patch_h) - im_h;
105 ASSERT_((x_search_ini + x_search_size + patch_w) <= im_w)
106 ASSERT_((y_search_ini + y_search_size + patch_h) <= im_h)
108 IplImage* result = cvCreateImage(
109 cvSize(x_search_size + 1, y_search_size + 1), IPL_DEPTH_32F, 1);
111 CImage img_region_to_search;
121 img_region_to_search,
124 patch_w + x_search_size,
125 patch_h + y_search_size);
130 img_region_to_search.
getAs<IplImage>(), patch_im.
getAs<IplImage>(),
131 result, CV_TM_CCORR_NORMED);
134 cvMinMaxLoc(result, &mini, &max_val, &min_point, &max_point,
nullptr);
139 cvReleaseImage(&result);
142 THROW_EXCEPTION(
"The MRPT has been compiled with MRPT_HAS_OPENCV=0 !");
156 cvFlip(
img.getAs<IplImage>());
158 img.setOriginTopLeft(
true);
160 THROW_EXCEPTION(
"The MRPT has been compiled with MRPT_HAS_OPENCV=0 !");
174 res.x = xy.
x - A.get_unsafe(0, 2);
175 res.y = xy.
y - A.get_unsafe(1, 2);
176 res.z = A.get_unsafe(0, 0);
179 const double u =
res.norm();
190 const double focalLengthX,
const double focalLengthY,
const double centerX,
191 const double centerY)
195 A(0, 0) = focalLengthX;
196 A(1, 1) = focalLengthY;
209 unsigned int camIndex,
unsigned int resX,
unsigned int resY)
211 float fx, fy, cx, cy;
234 "Unknown camera index!! for 'camIndex'=%u", camIndex);
239 resX * fx, resY * fy, resX * cx, resY * cy);
248 float lx = 0.0, ly = 0.0;
251 for (itList1 = feat_list.
begin(); itList1 != feat_list.
end(); itList1++)
255 for (itList2 = itList1; itList2 != feat_list.
end(); itList2++)
257 if ((lx == (*itList2)->x && ly == (*itList2)->y) &&
258 ((*itList2)->x > 0.0f && (*itList2)->y > 0.0f))
260 (*itList2)->x = -1.0f;
261 (*itList2)->y = -1.0f;
267 for (itList1 = feat_list.
begin(); itList1 != feat_list.
end();)
269 if ((*itList1)->x == -1.0f && (*itList1)->y == -1.0f)
270 itList1 = feat_list.
erase(itList1);
285 std::cout << std::endl
286 <<
"[ROW CHECKING]------------------------------------------" 290 for (itLeft = leftList.
begin(), itRight = rightList.
begin();
291 itLeft != leftList.
end();)
293 if ((*itLeft)->x < 0 || (*itLeft)->y < 0 || (*itRight)->x < 0 ||
294 (*itRight)->y < 0 || fabs((*itLeft)->y - (*itRight)->y) > threshold)
296 std::cout <<
"[Erased Feature] Row Dif: " 297 << fabs((*itLeft)->y - (*itRight)->y) << std::endl;
298 itLeft = leftList.
erase(itLeft);
299 itRight = rightList.
erase(itRight);
308 std::cout <<
"------------------------------------------" << std::endl;
310 std::cout <<
"Tracked features: " << leftList.
size() <<
" and " 311 << rightList.
size() << std::endl;
326 double varx = 0, vary = 0;
328 for (it = list.
begin(); it != list.
end(); it++)
336 for (it = list.
begin(); it != list.
end(); it++)
360 for (it = feat_list.begin(); it != feat_list.end(); it++)
362 err.
x = it->other_x - (it->this_x * mat.get_unsafe(0, 0) +
363 it->this_y * mat.get_unsafe(0, 1) +
364 it->this_z * mat.get_unsafe(0, 2) + Rt.
x());
365 err.
y = it->other_y - (it->this_x * mat.get_unsafe(1, 0) +
366 it->this_y * mat.get_unsafe(1, 1) +
367 it->this_z * mat.get_unsafe(1, 2) + Rt.
y());
368 err.
z = it->other_z - (it->this_x * mat.get_unsafe(2, 0) +
369 it->this_y * mat.get_unsafe(2, 1) +
370 it->this_z * mat.get_unsafe(2, 2) + Rt.z());
375 return (acum / feat_list.size());
392 if (itLand1->ID == itLand2->ID)
397 pair.
this_x = itLand1->pose_mean.x;
398 pair.
this_y = itLand1->pose_mean.y;
399 pair.
this_z = itLand1->pose_mean.z;
401 pair.
other_x = itLand2->pose_mean.x;
402 pair.
other_y = itLand2->pose_mean.y;
403 pair.
other_z = itLand2->pose_mean.z;
405 outList.push_back(pair);
416 float orientation = 0;
417 if ((
int(
x) - 1 >= 0) && (
int(
y) - 1 >= 0) && (
x + 1 <
image.getWidth()) &&
418 (
y + 1 <
image.getHeight()))
419 orientation = (float)atan2(
440 nim.resize(
image.getHeight(),
image.getWidth());
442 image.getAsMatrix(im);
445 im.meanAndStdAll(m,
s);
447 for (
int k1 = 0; k1 < (int)nim.cols(); ++k1)
448 for (
int k2 = 0; k2 < (int)nim.rows(); ++k2)
449 nim.set_unsafe(k2, k1, (im.get_unsafe(k2, k1) - m) /
s);
467 size_t sz1 = list1.
size(), sz2 = list2.
size();
469 ASSERT_((sz1 > 0) && (sz2 > 0));
486 double minSAD1, minSAD2;
488 vector<int> idxLeftList, idxRightList;
491 vector<double> distCorrs(sz1);
493 int minLeftIdx = 0, minRightIdx;
497 for (lFeat = 0, itList1 = list1.
begin(); itList1 != list1.
end();
515 for (rFeat = 0, itList2 = list2.
begin(); itList2 != list2.
end();
523 d = (*itList1)->y - (*itList2)->y;
530 TPoint2D oPoint((*itList2)->x, (*itList2)->y);
533 p(0, 0) = (*itList1)->x;
534 p(1, 0) = (*itList1)->y;
539 epiLine.
coefs[0] = l(0, 0);
540 epiLine.
coefs[1] = l(1, 0);
541 epiLine.
coefs[2] = l(2, 0);
551 ? ((*itList1)->x - (*itList2)->x) > 0
562 (*itList1)->descriptors.hasDescriptorSIFT() &&
563 (*itList2)->descriptors.hasDescriptorSIFT());
567 (*itList1)->descriptorSIFTDistanceTo(*(*itList2));
570 if (distDesc < minDist1)
577 else if (distDesc < minDist2)
590 (*itList1)->patchSize > 0 &&
591 (*itList2)->patchSize > 0);
593 (*itList1)->patch, (*itList2)->patch, u,
v,
res);
603 else if (
res > maxCC2)
613 (*itList1)->descriptors.hasDescriptorSURF() &&
614 (*itList2)->descriptors.hasDescriptorSURF());
618 (*itList1)->descriptorSURFDistanceTo(*(*itList2));
621 if (distDesc < minDist1)
628 else if (distDesc < minDist2)
638 (*itList1)->descriptors.hasDescriptorORB() &&
639 (*itList2)->descriptors.hasDescriptorORB());
641 (*itList1)->descriptorORBDistanceTo(*(*itList2));
644 if (distDesc < minDist1)
651 else if (distDesc < minDist2)
661 (*itList1)->patchSize > 0 &&
662 (*itList2)->patchSize == (*itList1)->patchSize);
666 IplImage *aux1, *aux2;
667 if ((*itList1)->patch.isColor() &&
668 (*itList2)->patch.isColor())
670 const IplImage* preAux1 =
671 (*itList1)->patch.getAs<IplImage>();
672 const IplImage* preAux2 =
673 (*itList2)->patch.getAs<IplImage>();
675 aux1 = cvCreateImage(
677 (*itList1)->patch.getHeight(),
678 (*itList1)->patch.getWidth()),
680 aux2 = cvCreateImage(
682 (*itList2)->patch.getHeight(),
683 (*itList2)->patch.getWidth()),
686 cvCvtColor(preAux1, aux1, CV_BGR2GRAY);
687 cvCvtColor(preAux2, aux2, CV_BGR2GRAY);
691 aux1 =
const_cast<IplImage*
>(
692 (*itList1)->patch.getAs<IplImage>());
693 aux2 =
const_cast<IplImage*
>(
694 (*itList2)->patch.getAs<IplImage>());
719 for (
unsigned int ii = 0;
720 ii < (
unsigned int)aux1->height; ++ii)
721 for (
unsigned int jj = 0;
722 jj < (
unsigned int)aux1->width; ++jj)
724 (
double)(aux1->imageData[ii * aux1->widthStep + jj]) -
725 ((
double)(aux2->imageData[ii * aux2->widthStep + jj])));
726 res =
res / (255.0f * aux1->width * aux1->height);
735 else if (
res < minSAD2)
744 bool cond1 =
false, cond2 =
false;
752 cond2 = (minDist1 / minDist2) <
759 cond2 = (maxCC2 / maxCC1) <
769 (minDist1 / minDist2) <
775 cond2 = (minSAD1 / minSAD2) < options.
SAD_RATIO;
790 int auxIdx = idxRightList[minRightIdx];
793 if (distCorrs[auxIdx] > minVal)
803 distCorrs[minLeftIdx] = minVal;
804 idxLeftList[minLeftIdx] = minRightIdx;
805 idxRightList[minRightIdx] = minLeftIdx;
807 distCorrs[auxIdx] = 1.0;
819 idxRightList[minRightIdx] = minLeftIdx;
820 idxLeftList[minLeftIdx] = minRightIdx;
821 distCorrs[minLeftIdx] = minVal;
832 for (
int vCnt = 0; vCnt < (int)idxLeftList.size(); ++vCnt)
836 std::pair<CFeature::Ptr, CFeature::Ptr> thisMatch;
839 double dp1 = -1.0, dp2 = -1.0;
844 list1[vCnt], list2[idxLeftList[vCnt]], p3D,
params);
854 dp1 = sqrt(p3D.
x * p3D.
x + p3D.
y * p3D.
y + p3D.
z * p3D.
z);
857 p3D.
y * p3D.
y + p3D.
z * p3D.
z);
867 thisMatch.first = list1[vCnt];
868 thisMatch.second = list2[idxLeftList[vCnt]];
873 idLeft = thisMatch.first->ID;
874 idRight = thisMatch.second->ID;
878 keep_max(idLeft, thisMatch.first->ID);
881 keep_max(idRight, thisMatch.second->ID);
888 thisMatch.first->initialDepth = dp1;
889 thisMatch.first->p3D = p3D;
891 thisMatch.second->initialDepth = dp2;
892 thisMatch.second->p3D =
897 matches.push_back(thisMatch);
901 return matches.size();
919 int hwsize = (int)(0.5 * wSize);
924 for (it = mList.begin(); it != mList.end(); ++it)
926 for (
int ii = -hwsize; ii < hwsize; ++ii)
927 for (
int jj = -hwsize; jj < hwsize; ++jj)
929 idx = (int)(it->first->x) + ii;
930 idy = (int)(it->first->y) + jj;
931 if (idx >= 0 && idy >= 0 && idx < mx && idy < my)
935 for (
int ii = -hwsize; ii < hwsize; ++ii)
936 for (
int jj = -hwsize; jj < hwsize; ++jj)
938 idx = (int)(it->second->x) + ii;
939 idy = (int)(it->second->y) + jj;
940 if (idx >= 0 && idy >= 0 && idx < mx && idy < my)
953 const IplImage* im1 = patch1.
getAs<IplImage>();
954 const IplImage* im2 = patch2.
getAs<IplImage>();
956 ASSERT_(im1->width == im2->width && im1->height == im2->height);
958 for (
unsigned int ii = 0; ii < (
unsigned int)im1->height; ++ii)
959 for (
unsigned int jj = 0; jj < (
unsigned int)im1->width; ++jj)
961 (
double)(im1->imageData[ii * im1->widthStep + jj]) -
962 ((
double)(im2->imageData[ii * im2->widthStep + jj])));
963 return res / (255.0f * im1->width * im1->height);
966 "MRPT compiled without OpenCV, can't compute SAD of images!")
981 (*it)->x - 5, (*it)->y - 5, (*it)->x + 5, (*it)->y + 5,
991 vector<TPoint3D>& out_points)
994 out_points.reserve(matches.size());
996 it != matches.end(); ++it)
998 const double disp = it->first->x - it->second->x;
999 if (disp < 1)
continue;
1002 out_points.push_back(
1016 vP3D.reserve(leftList.
size());
1018 for (it1 = leftList.
begin(), it2 = rightList.
begin(); it1 != leftList.
end();
1024 vP3D.push_back(p3D);
1047 const double f0 = 600;
1048 double nfx1 = leftFeat->x, nfy1 = leftFeat->y,
1049 nfx2 = rightFeat->x;
1051 const double x = leftFeat->x * f0;
1052 const double y = leftFeat->y * f0;
1053 const double xd = rightFeat->x * f0;
1054 const double yd = rightFeat->y * f0;
1056 const double f2 = f0 * f0;
1057 const double p9 = f2 *
params.F.get_unsafe(2, 2);
1059 f2 * (
params.F.get_unsafe(0, 2) *
params.F.get_unsafe(0, 2) +
1060 params.F.get_unsafe(1, 2) *
params.F.get_unsafe(1, 2) +
1061 params.F.get_unsafe(2, 0) *
params.F.get_unsafe(2, 0) +
1062 params.F.get_unsafe(2, 1) *
params.F.get_unsafe(2, 1));
1064 double Jh = (std::numeric_limits<double>::max)();
1077 (xh * xhd + xhd * xt + xh * xtd) *
params.F.get_unsafe(0, 0);
1079 (xh * yhd + yhd * xt + xh * ytd) *
params.F.get_unsafe(0, 1);
1080 const double p3 = (f0 * (xh + xt)) *
params.F.get_unsafe(0, 2);
1082 (yh * xhd + xhd * yt + yh * xtd) *
params.F.get_unsafe(1, 0);
1084 (yh * yhd + yhd * yt + yh * ytd) *
params.F.get_unsafe(1, 1);
1085 const double p6 = (f0 * (yh + yt)) *
params.F.get_unsafe(1, 2);
1086 const double p7 = (f0 * (xhd + xtd)) *
params.F.get_unsafe(2, 0);
1087 const double p8 = (f0 * (yhd + ytd)) *
params.F.get_unsafe(2, 1);
1089 const double udotxi = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
1091 const double Q11 = (xh * xh + xhd * xhd) *
params.F.get_unsafe(0, 0) *
1092 params.F.get_unsafe(0, 0);
1093 const double Q22 = (xh * xh + yhd * yhd) *
params.F.get_unsafe(0, 1) *
1094 params.F.get_unsafe(0, 1);
1095 const double Q44 = (yh * yh + xhd * xhd) *
params.F.get_unsafe(1, 0) *
1096 params.F.get_unsafe(1, 0);
1097 const double Q55 = (yh * yh + yhd * yhd) *
params.F.get_unsafe(1, 1) *
1098 params.F.get_unsafe(1, 1);
1100 xhd * yhd *
params.F.get_unsafe(0, 0) *
params.F.get_unsafe(0, 1);
1102 f0 * xhd *
params.F.get_unsafe(0, 0) *
params.F.get_unsafe(0, 2);
1104 xh * yh *
params.F.get_unsafe(0, 0) *
params.F.get_unsafe(1, 0);
1106 f0 * xh *
params.F.get_unsafe(0, 0) *
params.F.get_unsafe(2, 0);
1108 f0 * yhd *
params.F.get_unsafe(0, 1) *
params.F.get_unsafe(0, 2);
1110 xh * yh *
params.F.get_unsafe(0, 1) *
params.F.get_unsafe(1, 1);
1112 f0 * xh *
params.F.get_unsafe(0, 1) *
params.F.get_unsafe(2, 1);
1114 xhd * yhd *
params.F.get_unsafe(1, 0) *
params.F.get_unsafe(1, 1);
1116 f0 * xhd *
params.F.get_unsafe(1, 0) *
params.F.get_unsafe(1, 2);
1118 f0 * yh *
params.F.get_unsafe(1, 0) *
params.F.get_unsafe(2, 0);
1120 f0 * yhd *
params.F.get_unsafe(1, 1) *
params.F.get_unsafe(1, 2);
1122 f0 * yh *
params.F.get_unsafe(1, 1) *
params.F.get_unsafe(2, 1);
1124 const double udotV0xiu = Q00 + Q11 + Q22 + Q44 + Q55 +
1125 2.0 * (Q12 + Q13 + Q14 + Q17 + Q23 + Q25 +
1126 Q28 + Q45 + Q46 + Q47 + Q56 + Q58);
1128 ASSERT_(fabs(udotV0xiu) > 1e-5);
1130 const double C = udotxi / udotV0xiu;
1133 (
params.F.get_unsafe(0, 0) * xhd +
1134 params.F.get_unsafe(0, 1) * yhd + f0 *
params.F.get_unsafe(0, 2));
1136 (
params.F.get_unsafe(1, 0) * xhd +
1137 params.F.get_unsafe(1, 1) * yhd + f0 *
params.F.get_unsafe(1, 2));
1139 (
params.F.get_unsafe(0, 0) * xh +
params.F.get_unsafe(1, 0) * yh +
1140 f0 *
params.F.get_unsafe(2, 0));
1142 (
params.F.get_unsafe(0, 1) * xh +
params.F.get_unsafe(1, 1) * yh +
1143 f0 *
params.F.get_unsafe(2, 1));
1145 const double Jt = xt * xt + yt * yt + xtd * xtd + ytd * ytd;
1147 if ((std::abs)(Jt - Jh) <= 1e-5)
1166 double disp = nfx1 - nfx2;
1167 double aux =
params.baseline / disp;
1168 p3D.
x = (nfx1 -
params.K(0, 2)) * aux;
1169 p3D.
y = (nfy1 -
params.K(1, 2)) * aux;
1189 for (itList = mfList.begin(); itList != mfList.end();)
1191 float disp = (itList->first->x - itList->second->x);
1193 itList = mfList.erase(
1200 (itList->first->x -
param.K(0, 2)) * ((
param.baseline)) / disp;
1202 (itList->first->y -
param.K(1, 2)) * ((
param.baseline)) / disp;
1203 float z3D = (
param.K(0, 0)) * ((
param.baseline)) / disp;
1206 if ((z3D <
param.minZ) || (z3D >
param.maxZ))
1207 itList = mfList.erase(itList);
1217 norm3D *= -1 / norm3D.
norm();
1221 lm.
ID = itList->first->ID;
1231 switch (
param.uncPropagation)
1236 float c0 =
param.K(0, 2);
1237 float r0 =
param.K(1, 2);
1240 square(itList->first->x - itList->second->x);
1244 square(itList->first->x - c0) /
1247 stdDisp2 * base2 * (itList->first->x - c0) *
1248 (itList->first->y - r0) /
square(disp2);
1250 (itList->first->x - c0) /
1254 square(itList->first->y - r0) /
1257 (itList->first->y - r0) /
1260 stdDisp2 * foc2 * base2 /
square(disp2);
1267 unsigned int Na = 3;
1270 float k =
param.factor_k;
1272 float w0 = k / (Na + k);
1273 float w1 = 1 / (2 * (Na + k));
1279 Pa(0, 0) = Pa(1, 1) = (Na + k) *
square(
param.stdPixel);
1289 B.resize(2 * Na + 1);
1300 meanA[0] = itList->first->x;
1301 meanA[1] = itList->first->y;
1312 for (i = 1; i <= 2 * Na; i++)
1319 myPoint[0] = meanA[0] + vAux[0];
1320 myPoint[1] = meanA[1] + vAux[1];
1321 myPoint[2] = meanA[2] + vAux[2];
1328 myPoint[0] = meanA[0] - vAux[0];
1329 myPoint[1] = meanA[1] - vAux[1];
1330 myPoint[2] = meanA[2] - vAux[2];
1334 x3D = (myPoint[0] -
param.K(0, 2)) *
1335 ((
param.baseline)) / myPoint[2];
1336 y3D = (myPoint[1] -
param.K(1, 2)) *
1337 ((
param.baseline)) / myPoint[2];
1342 meanB.
x = meanB.
x +
w1 * x3D;
1343 meanB.
y = meanB.
y +
w1 * y3D;
1344 meanB.
z = meanB.
z +
w1 * z3D;
1353 for (i = 0; i <= 2 * Na; i++)
1362 v(0, 0) = B[i].x - meanB.
x;
1363 v(1, 0) = B[i].y - meanB.
y;
1364 v(2, 0) = B[i].z - meanB.
z;
1366 Pb = Pb + weight * (
v *
v.transpose());
1382 unsigned int Na = 3;
1385 float a =
param.factor_a;
1386 float b =
param.factor_b;
1387 float k =
param.factor_k;
1389 float lambda =
square(
a) * (Na + k) - Na;
1391 float w0_m = lambda / (Na + lambda);
1392 float w0_c = w0_m + (1 -
square(
a) +
b);
1393 float w1 = 1 / (2 * (Na + lambda));
1399 Pa(0, 0) = Pa(1, 1) =
1410 B.resize(2 * Na + 1);
1421 meanA[0] = itList->first->x;
1422 meanA[1] = itList->first->y;
1426 meanB.
x = w0_m * x3D;
1427 meanB.
y = w0_m * y3D;
1428 meanB.
z = w0_m * z3D;
1433 for (i = 1; i <= 2 * Na; i++)
1440 myPoint = meanA + vAux;
1450 myPoint = meanA - vAux;
1457 x3D = (myPoint[0] -
param.K(0, 2)) *
1458 ((
param.baseline)) / myPoint[2];
1459 y3D = (myPoint[1] -
param.K(1, 2)) *
1460 ((
param.baseline)) / myPoint[2];
1465 meanB.
x = meanB.
x +
w1 * x3D;
1466 meanB.
y = meanB.
y +
w1 * y3D;
1467 meanB.
z = meanB.
z +
w1 * z3D;
1476 for (i = 0; i <= 2 * Na; i++)
1485 v(0, 0) = B[i].x - meanB.
x;
1486 v(1, 0) = B[i].y - meanB.
y;
1487 v(2, 0) = B[i].z - meanB.
z;
1489 Pb = Pb + weight * (
v *
v.transpose());
1530 for (itListL = leftList.
begin(), itListR = rightList.
begin();
1531 itListL != leftList.
end();)
1533 float disp = ((*itListL)->x - (*itListR)->x);
1536 itListL = leftList.
erase(itListL);
1538 itListR = rightList.
erase(itListR);
1545 ((*itListL)->x -
param.K(0, 2)) * ((
param.baseline)) / disp;
1547 ((*itListL)->y -
param.K(1, 2)) * ((
param.baseline)) / disp;
1548 float z3D = (
param.K(0, 0)) * ((
param.baseline)) / disp;
1551 if ((z3D <
param.minZ) || (z3D >
param.maxZ))
1554 leftList.
erase(itListL);
1557 rightList.
erase(itListR);
1568 norm3D *= -1 / norm3D.
norm();
1572 lm.
ID = (*itListL)->ID;
1583 switch (
param.uncPropagation)
1588 float c0 =
param.K(0, 2);
1589 float r0 =
param.K(1, 2);
1591 float disp2 =
square((*itListL)->x - (*itListR)->x);
1595 square((*itListL)->x - c0) /
1598 ((*itListL)->x - c0) *
1599 ((*itListL)->y - r0) /
square(disp2);
1601 ((*itListL)->x - c0) /
square(disp2);
1604 square((*itListL)->y - r0) /
1607 ((*itListL)->y - r0) /
square(disp2);
1609 stdDisp2 * foc2 * base2 /
square(disp2);
1616 unsigned int Na = 3;
1619 float k =
param.factor_k;
1621 float w0 = k / (Na + k);
1622 float w1 = 1 / (2 * (Na + k));
1628 Pa(0, 0) = Pa(1, 1) = (Na + k) *
square(
param.stdPixel);
1638 B.resize(2 * Na + 1);
1649 meanA[0] = (*itListL)->x;
1650 meanA[1] = (*itListL)->y;
1661 for (i = 1; i <= 2 * Na; i++)
1668 myPoint[0] = meanA[0] + vAux[0];
1669 myPoint[1] = meanA[1] + vAux[1];
1670 myPoint[2] = meanA[2] + vAux[2];
1677 myPoint[0] = meanA[0] - vAux[0];
1678 myPoint[1] = meanA[1] - vAux[1];
1679 myPoint[2] = meanA[2] - vAux[2];
1683 x3D = (myPoint[0] -
param.K(0, 2)) *
1684 ((
param.baseline)) / myPoint[2];
1685 y3D = (myPoint[1] -
param.K(1, 2)) *
1686 ((
param.baseline)) / myPoint[2];
1691 meanB.
x = meanB.
x +
w1 * x3D;
1692 meanB.
y = meanB.
y +
w1 * y3D;
1693 meanB.
z = meanB.
z +
w1 * z3D;
1702 for (i = 0; i <= 2 * Na; i++)
1711 v(0, 0) = B[i].x - meanB.
x;
1712 v(1, 0) = B[i].y - meanB.
y;
1713 v(2, 0) = B[i].z - meanB.
z;
1715 Pb = Pb + weight * (
v *
v.transpose());
1731 unsigned int Na = 3;
1734 float a =
param.factor_a;
1735 float b =
param.factor_b;
1736 float k =
param.factor_k;
1738 float lambda =
square(
a) * (Na + k) - Na;
1740 float w0_m = lambda / (Na + lambda);
1741 float w0_c = w0_m + (1 -
square(
a) +
b);
1742 float w1 = 1 / (2 * (Na + lambda));
1748 Pa(0, 0) = Pa(1, 1) =
1759 B.resize(2 * Na + 1);
1770 meanA[0] = (*itListL)->x;
1771 meanA[1] = (*itListL)->y;
1775 meanB.
x = w0_m * x3D;
1776 meanB.
y = w0_m * y3D;
1777 meanB.
z = w0_m * z3D;
1782 for (i = 1; i <= 2 * Na; i++)
1789 myPoint = meanA + vAux;
1799 myPoint = meanA - vAux;
1806 x3D = (myPoint[0] -
param.K(0, 2)) *
1807 ((
param.baseline)) / myPoint[2];
1808 y3D = (myPoint[1] -
param.K(1, 2)) *
1809 ((
param.baseline)) / myPoint[2];
1814 meanB.
x = meanB.
x +
w1 * x3D;
1815 meanB.
y = meanB.
y +
w1 * y3D;
1816 meanB.
z = meanB.
z +
w1 * z3D;
1825 for (i = 0; i <= 2 * Na; i++)
1834 v(0, 0) = B[i].x - meanB.
x;
1835 v(1, 0) = B[i].y - meanB.
y;
1836 v(2, 0) = B[i].z - meanB.
z;
1838 Pb = Pb + weight * (
v *
v.transpose());
1868 const CPose3D& sensorPose,
const vector<double>& sg,
1872 double f = intrinsicParams(0, 0);
1873 double x0 = intrinsicParams(0, 2);
1874 double y0 = intrinsicParams(1, 2);
1875 double b = baseline;
1876 double sg_c2 =
square(sg[0]);
1877 double sg_r2 =
square(sg[1]);
1878 double sg_d2 =
square(sg[2]);
1881 itMatchList != inMatches.end(); itMatchList++)
1883 double x = itMatchList->first->x;
1884 double y = itMatchList->first->y;
1886 double d = itMatchList->first->x - itMatchList->second->x;
1893 double X = (
x - x0) *
b / d;
1894 double Y = (
y - y0) *
b / d;
1895 double Z = f *
b / d;
1906 m.
yaw = atan2(Y, X);
1920 aux.get_unsafe(0, 0) = k * (sg_c2 + sg_d2 *
square(
x - x0) / d2);
1921 aux.get_unsafe(0, 1) = aux.get_unsafe(1, 0) =
1922 k * (sg_d2 * (
x - x0) * (
y - y0) / d2);
1923 aux.get_unsafe(0, 2) = aux.get_unsafe(2, 0) =
1924 k * (sg_d2 * (
x - x0) * f / d2);
1926 aux.get_unsafe(1, 1) = k * (sg_r2 + sg_d2 *
square(
y - y0) / d2);
1927 aux.get_unsafe(1, 2) = aux.get_unsafe(2, 1) =
1928 k * (sg_d2 * (
y - y0) * f / d2);
1930 aux.get_unsafe(2, 2) = k * (sg_d2 *
square(f) / d2);
1956 JG.set_unsafe(0, 0, X / m.
range);
1957 JG.set_unsafe(0, 1, Y / m.
range);
1958 JG.set_unsafe(0, 2, Z / m.
range);
1962 JG.set_unsafe(1, 2, 0);
2003 unsigned int id = 0;
2023 double sg_c2 =
square(sg[0]);
2024 double sg_r2 =
square(sg[1]);
2025 double sg_d2 =
square(sg[2]);
2028 itMatchList != matchList.end(); itMatchList++,
id++)
2030 double x = itMatchList->first->x;
2031 double y = itMatchList->first->y;
2033 double d = itMatchList->first->x - itMatchList->second->x;
2040 double X = (
x - x0) *
b / d;
2041 double Y = (
y - y0) *
b / d;
2042 double Z = f *
b / d;
2055 m.
yaw = atan2(X, Z);
2056 m.
pitch = atan2(Y, Z);
2068 aux.get_unsafe(0, 0) = k * (sg_c2 + sg_d2 *
square(
x - x0) / d2);
2069 aux.get_unsafe(0, 1) = aux.get_unsafe(1, 0) =
2070 k * (sg_d2 * (
x - x0) * (
y - y0) / d2);
2071 aux.get_unsafe(0, 2) = aux.get_unsafe(2, 0) =
2072 k * (sg_d2 * (
x - x0) * f / d2);
2074 aux.get_unsafe(1, 1) = k * (sg_r2 + sg_d2 *
square(
y - y0) / d2);
2075 aux.get_unsafe(1, 2) = aux.get_unsafe(2, 1) =
2076 k * (sg_d2 * (
y - y0) * f / d2);
2078 aux.get_unsafe(2, 2) = k * (sg_d2 *
square(f) / d2);
2104 JG.set_unsafe(0, 0, X / m.
range);
2105 JG.set_unsafe(0, 1, Y / m.
range);
2106 JG.set_unsafe(0, 2, Z / m.
range);
2110 JG.set_unsafe(1, 2, 0);
2159 square(itCloud->pose_mean.x) +
square(itCloud->pose_mean.y) +
2160 square(itCloud->pose_mean.z));
2166 m.
yaw = atan2(itCloud->pose_mean.y, itCloud->pose_mean.x);
2167 m.
pitch = -sin(itCloud->pose_mean.z / m.
range);
2179 const poses::CPose3D& rightCameraPose,
void* outMap1x,
void* outMap1y,
2180 void* outMap2x,
void* outMap2y)
2184 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x211 2186 cv::Mat *mapx1, *mapy1, *mapx2, *mapy2;
2187 mapx1 =
static_cast<cv::Mat*
>(outMap1x);
2188 mapy1 =
static_cast<cv::Mat*
>(outMap1y);
2189 mapx2 =
static_cast<cv::Mat*
>(outMap2x);
2190 mapy2 =
static_cast<cv::Mat*
>(outMap2y);
2192 const int resX = cam1.
ncols;
2193 const int resY = cam1.
nrows;
2199 rcTrans[0] = hMatrix(0, 3);
2200 rcTrans[1] = hMatrix(1, 3);
2201 rcTrans[2] = hMatrix(2, 3);
2204 for (
unsigned int i = 0; i < 3; ++i)
2205 for (
unsigned int j = 0; j < 3; ++j) m1[i][j] = hMatrix(i, j);
2207 double ipl[3][3], ipr[3][3], dpl[5], dpr[5];
2208 for (
unsigned int i = 0; i < 3; ++i)
2209 for (
unsigned int j = 0; j < 3; ++j)
2215 for (
unsigned int i = 0; i < 5; ++i)
2217 dpl[i] = cam1.
dist[i];
2218 dpr[i] = cam2.
dist[i];
2221 cv::Mat
R(3, 3, CV_64F, &m1);
2222 cv::Mat T(3, 1, CV_64F, &rcTrans);
2224 cv::Mat K1(3, 3, CV_64F, ipl);
2225 cv::Mat K2(3, 3, CV_64F, ipr);
2226 cv::Mat D1(1, 5, CV_64F, dpl);
2227 cv::Mat D2(1, 5, CV_64F, dpr);
2229 double _R1[3][3], _R2[3][3], _P1[3][4], _P2[3][4], _Q[4][4];
2230 cv::Mat R1(3, 3, CV_64F, _R1);
2231 cv::Mat R2(3, 3, CV_64F, _R2);
2232 cv::Mat P1(3, 4, CV_64F, _P1);
2233 cv::Mat P2(3, 4, CV_64F, _P2);
2234 cv::Mat Q(4, 4, CV_64F, _Q);
2236 cv::Size nSize(resX, resY);
2240 #if MRPT_OPENCV_VERSION_NUM < 0x210 2243 K1, D1, K2, D2, nSize,
R, T, R1, R2, P1, P2, Q,
2244 cv::CALIB_ZERO_DISPARITY);
2245 #elif MRPT_OPENCV_VERSION_NUM < 0x230 2248 K1, D1, K2, D2, nSize,
R, T, R1, R2, P1, P2, Q,
alpha,
2251 cv::CALIB_ZERO_DISPARITY);
2255 K1, D1, K2, D2, nSize,
R, T, R1, R2, P1, P2, Q,
2256 cv::CALIB_ZERO_DISPARITY,
alpha);
2261 cv::initUndistortRectifyMap(
2262 K1, D1, R1, P1, cv::Size(resX, resY), CV_32FC1, *mapx1, *mapy1);
2263 cv::initUndistortRectifyMap(
2264 K2, D2, R2, P2, cv::Size(resX, resY), CV_32FC1, *mapx2, *mapy2);
2268 "The MRPT has been compiled with MRPT_HAS_OPENCV = 0 or OpenCV version " 2278 : xMin(x1), xMax(x2), yMin(y1), yMax(y2), zMin(
z1), zMax(
z2)
2287 : xMin(x1), xMax(x2), yMin(y1), yMax(y2)
2295 : uncPropagation(Prop_Linear),
2308 F.set_unsafe(1, 2, -1);
2309 F.set_unsafe(2, 1, 1);
2336 for (
unsigned int ii = 0; ii < 3; ++ii)
2337 for (
unsigned int jj = 0; jj < 3; ++jj)
K(ii, jj) = k_vec[ii * 3 + jj];
2342 for (
unsigned int ii = 0; ii < 3; ++ii)
2343 for (
unsigned int jj = 0; jj < 3; ++jj)
F(ii, jj) = f_vec[ii * 3 + jj];
2361 out.
printf(
"\n----------- [vision::TStereoSystemParams] ------------ \n");
2362 out.
printf(
"Method for 3D Uncert. \t= ");
2366 out.
printf(
"Linear propagation\n");
2369 out.
printf(
"Unscented Transform\n");
2372 out.
printf(
"Scaled Unscented Transform\n");
2376 out.
printf(
"K\t\t\t= [%f\t%f\t%f]\n",
K(0, 0),
K(0, 1),
K(0, 2));
2377 out.
printf(
" \t\t\t [%f\t%f\t%f]\n",
K(1, 0),
K(1, 1),
K(1, 2));
2378 out.
printf(
" \t\t\t [%f\t%f\t%f]\n",
K(2, 0),
K(2, 1),
K(2, 2));
2380 out.
printf(
"F\t\t\t= [%f\t%f\t%f]\n",
F(0, 0),
F(0, 1),
F(0, 2));
2381 out.
printf(
" \t\t\t [%f\t%f\t%f]\n",
F(1, 0),
F(1, 1),
F(1, 2));
2382 out.
printf(
" \t\t\t [%f\t%f\t%f]\n",
F(2, 0),
F(2, 1),
F(2, 2));
2394 out.
printf(
"-------------------------------------------------------- \n");
2402 useEpipolarRestriction(true),
2405 hasFundamentalMatrix(
2407 parallelOpticalAxis(true),
2410 useXRestriction(true),
2414 useDisparityLimits(false),
2419 matching_method(mmCorrelation),
2441 estimateDepth(false),
2442 maxDepthThreshold(15.0)
2518 out.
printf(
"\n----------- [vision::TMatchingOptions] ------------ \n");
2519 out.
printf(
"Matching method: ");
2523 out.
printf(
"Cross Correlation\n");
2529 out.
printf(
"SIFT descriptor\n");
2534 out.
printf(
"SURF descriptor\n");
2549 out.
printf(
"Using epipolar restriction?: ");
2551 out.
printf(
"Has Fundamental Matrix?: ");
2553 out.
printf(
"Are camera axis parallel?: ");
2555 out.
printf(
"Use X-coord restriction?: ");
2557 out.
printf(
"Use disparity limits?: ");
2561 "· Min/max disp limits: %.2f/%.2f px\n",
min_disp,
2563 out.
printf(
"Estimate depth?: ");
2574 out.
printf(
"Add matches to list?: ");
2576 out.
printf(
"-------------------------------------------------------- \n");
void clear()
Erase all the contents of the map.
void projectMatchedFeatures(const CMatchedFeatureList &matches, const mrpt::utils::TStereoCamera &stereo_camera, std::vector< mrpt::math::TPoint3D > &out_points)
float fieldOfView_yaw
Information about the.
A pair (x,y) of pixel coordinates (subpixel resolution).
float EDD_RATIO
Boundary Ratio between the two lowest EDD.
double x() const
Common members of all points & poses classes.
TMatchingOptions()
Intrinsic parameters of the stereo rig.
std::shared_ptr< CFeature > Ptr
GLclampf GLclampf GLclampf alpha
float rCC_TH
Maximum Ratio Between the two highest CC values.
mrpt::math::CMatrixDouble33 F
Stereo Fundamental matrix.
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
double computeSAD(const mrpt::utils::CImage &patch1, const mrpt::utils::CImage &patch2)
Calculates the Sum of Absolutes Differences (range [0,1]) between two patches.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
double maxORB_dist
Maximun distance between ORB descriptors.
Declares a matrix of booleans (non serializable).
mrpt::utils::CImage imageLeft
Image from the left camera (this image will be ALWAYS present)
std::vector< mrpt::vision::CFeature::Ptr > features
The set of features from which the landmark comes.
float range
The sensed landmark distance, in meters.
bool estimateDepth
Whether or not estimate the 3D position of the real features for the matches (only with parallelOptic...
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
bool useXRestriction
Whether or not employ the x-coord restriction for finding correspondences (bumblebee camera...
void cloudsToMatchedList(const mrpt::obs::CObservationVisualLandmarks &cloud1, const mrpt::obs::CObservationVisualLandmarks &cloud2, mrpt::utils::TMatchingPairList &outList)
Transform two clouds of 3D points into a matched list of points ...
A class for storing images as grayscale or RGB bitmaps.
Linear propagation of the uncertainty.
void setRightMaxID(const TFeatureID &rightID)
double SAD_RATIO
Boundary Ratio between the two highest SAD.
#define THROW_EXCEPTION(msg)
void resize(unsigned int width, unsigned int height, TImageChannels nChannels, bool originTopLeft)
Changes the size of the image, erasing previous contents (does NOT scale its current content...
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
void StereoObs2BRObs(const mrpt::obs::CObservationStereoImages &inObs, const std::vector< double > &sg, mrpt::obs::CObservationBearingRange &outObs)
Converts a stereo images observation into a bearing and range observation.
double cy() const
Get the value of the principal point y-coordinate (in pixels).
Declares a class derived from "CObservation" that stores a Landmarks Map as seen from a stereo camera...
float min_disp
Disparity limits, see also 'useDisparityLimits'.
double norm() const
Point norm.
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
GLenum GLsizei GLenum GLenum const GLvoid * image
TInternalFeatList::const_iterator const_iterator
void rectangle(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color, unsigned int width=1)
Draws a rectangle (an empty rectangle, without filling)
float epipolar_TH
Epipolar constraint (rows of pixels)
const Scalar * const_iterator
float minZ
Maximum allowed distance.
float EDSD_RATIO
Boundary Ratio between the two lowest SURF EDSD.
void addFeaturesToImage(const mrpt::utils::CImage &inImg, const CFeatureList &theList, mrpt::utils::CImage &outImg)
Draw rectangles around each of the features on a copy of the input image.
bool useEpipolarRestriction
Whether or not take into account the epipolar restriction for finding correspondences.
Matching by Hamming distance between ORB descriptors.
const T * getAs() const
Returns a pointer to a const T* containing the image - the idea is to call like "img.getAs<IplImage>()" so we can avoid here including OpenCV's headers.
float factor_k
K factor for the UT.
Structure to hold the parameters of a pinhole stereo camera model.
This class allows loading and storing values and vectors of different types from a configuration text...
T square(const T x)
Inline function for the square of a number.
bool useDisparityLimits
Whether or not use limits (min,max) for the disparity, see also 'min_disp, max_disp'.
float stdPixel
Standard deviation of the error in feature detection.
float yaw
The sensed landmark direction, in radians, measured as the yaw (azimuth) and pitch (negative elevatio...
mrpt::math::TPoint3D pixelTo3D(const mrpt::utils::TPixelCoordf &xy, const mrpt::math::CMatrixDouble33 &A)
Extract a UNITARY 3D vector in the direction of a 3D point, given from its (x,y) pixels coordinates...
double fx() const
Get the value of the focal length x-value (in pixels).
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
mrpt::poses::CPose3DQuat cameraPose
The pose of the LEFT camera, relative to the robot.
int32_t landmarkID
The ID of the sensed beacon, or INVALID_LANDMARK_ID (-1) if the sensor does not identify the landmark...
Matching by Euclidean distance between SIFT descriptors.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
bool parallelOpticalAxis
Whether or not the stereo rig has the optical axes parallel.
float minDCC_TH
Minimum Difference Between the Maximum Cross Correlation Values.
This base provides a set of functions for maths stuff.
size_t getWidth() const override
Returns the width of the image in pixels.
A class for storing a map of 3D probabilistic landmarks.
TUnc_Prop_Method uncPropagation
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void getMaxID(const TListIdx &idx, TFeatureID &firstListID, TFeatureID &secondListID)
Returns the maximum ID of the features in the list.
Parameters associated to a stereo system.
bool addMatches
Whether or not to add the matches found into the input matched list (if false the input list will be ...
void push_back(const CLandmark &lm)
The object is copied, thus the original copy passed as a parameter can be released.
Matching by Euclidean distance between SURF descriptors.
void openCV_cross_correlation(const mrpt::utils::CImage &img, const mrpt::utils::CImage &patch_img, size_t &x_max, size_t &y_max, double &max_val, int x_search_ini=-1, int y_search_ini=-1, int x_search_size=-1, int y_search_size=-1)
Computes the correlation between this image and another one, encapsulating the openCV function cvMatc...
void read_vector(const std::string §ion, const std::string &name, const VECTOR_TYPE &defaultValue, VECTOR_TYPE &outValues, bool failIfNotFound=false) const
Reads a configuration parameter of type vector, stored in the file as a string: "[v1 v2 v3 ...
float maxY
Maximum allowed height.
CImage grayscale() const
Returns a grayscale version of the image, or itself if it is already a grayscale image.
size_t getHeight() const override
Returns the height of the image in pixels.
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
float fieldOfView_pitch
Information about the sensor: The "field-of-view" of the sensor, in radians (for pitch )...
This namespace contains representation of robot actions and observations.
uint32_t ncols
Camera resolution.
double coefs[3]
Line coefficients, stored as an array: .
Classes for computer vision, detectors, features, etc.
double computeMsd(const mrpt::utils::TMatchingPairList &list, const poses::CPose3D &Rt)
Computes the mean squared distance between a set of 3D correspondences ...
void dumpToTextStream(mrpt::utils::CStream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
double x
X,Y,Z coordinates.
Uncertainty propagation through the Unscented Transformation.
double maxDepthThreshold
The maximum allowed depth for the matching.
iterator erase(const iterator &it)
uint64_t TFeatureID
Definition of a feature ID.
void setFromIplImageReadOnly(void *iplImage)
Reads the image from a OpenCV IplImage object (WITHOUT making a copy) and from now on the image canno...
void flip(mrpt::utils::CImage &img)
Invert an image using OpenCV function.
void set_unsafe(size_t row, size_t col, const T &v)
Fast but unsafe method to write a value in the matrix.
double cx() const
Get the value of the principal point x-coordinate (in pixels).
mrpt::utils::TCamera leftCamera
Parameters for the left/right cameras: individual intrinsic and distortion parameters of the cameras...
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value...
void rowChecking(CFeatureList &leftList, CFeatureList &rightList, float threshold=1.0)
Search for correspondences which are not in the same row and deletes them.
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
float computeMainOrientation(const mrpt::utils::CImage &image, unsigned int x, unsigned int y)
Computes the main orientation of a set of points with an image (for using in SIFT-based algorithms) ...
mrpt::utils::CImage imageRight
Image from the right camera, only contains a valid image if hasImageRight == true.
Each one of the measurements:
mrpt::math::CMatrixDouble33 intrinsicParams
Matrix of intrinsic parameters (containing the focal length and principal point coordinates) ...
TStereoSystemParams()
Initilization of default parameters.
Matching by sum of absolute differences of the image patches.
double maxSAD_TH
Minimum Euclidean Distance Between Sum of Absolute Differences.
void setFromMatrix(const Eigen::MatrixBase< Derived > &m, bool matrix_is_normalized=true)
Set the image from a matrix, interpreted as grayscale intensity values, in the range [0...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
The class for storing "landmarks" (visual or laser-scan-extracted features,...)
void setFromImageReadOnly(const CImage &other_img)
Sets the internal IplImage pointer to that of another given image, WITHOUT making a copy...
mrpt::math::CArrayDouble< 5 > dist
[k1 k2 t1 t2 k3] -> k_i: parameters of radial distortion, t_i: parameters of tangential distortion (d...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::math::TPoint3D normal
The "normal" to the landmark, i.e.
TCamera leftCamera
Intrinsic and distortion parameters of the left and right cameras.
float maxZ
Maximum allowed distance.
mrpt::poses::CPose3DQuat rightCameraPose
The pose of the right camera, relative to the left one: Note that using the conventional reference co...
void computeStereoRectificationMaps(const mrpt::utils::TCamera &cam1, const mrpt::utils::TCamera &cam2, const mrpt::poses::CPose3D &rightCameraPose, void *outMap1x, void *outMap1y, void *outMap2x, void *outMap2y)
Computes a pair of x-and-y maps for stereo rectification from a pair of cameras and the relative pose...
size_t matchFeatures(const CFeatureList &list1, const CFeatureList &list2, CMatchedFeatureList &matches, const TMatchingOptions &options=TMatchingOptions(), const TStereoSystemParams ¶ms=TStereoSystemParams())
Find the matches between two lists of features which must be of the same type.
This observation represents a number of range-bearing value pairs, each one for a detected landmark...
A structure containing options for the matching.
void extract_patch(CImage &patch, const unsigned int col=0, const unsigned int row=0, const unsigned int width=1, const unsigned int height=1) const
Extract a patch from this image, saveing it into "patch" (its previous contents will be overwritten)...
Matching by cross correlation of the image patches.
void setLeftMaxID(const TFeatureID &leftID)
Explicitly set the max IDs values to certain values.
void generateMask(const CMatchedFeatureList &mList, mrpt::math::CMatrixBool &mask1, mrpt::math::CMatrixBool &mask2, int wSize=10)
Calculates the Sum of Absolutes Differences (range [0,1]) between two patches.
bool hasFundamentalMatrix
Whether or not there is a fundamental matrix.
mrpt::maps::CLandmarksMap landmarks
The landmarks, with coordinates origin in the camera reference system.
size_t getColCount() const
Number of columns in the matrix.
A matrix of dynamic size.
size_t getRowCount() const
Number of rows in the matrix.
int round(const T value)
Returns the closer integer (int) to x.
TInternalFeatList::iterator iterator
float maxEDSD_TH
Maximum Euclidean Distance Between SURF Descriptors.
float minCC_TH
Minimum Value of the Cross Correlation.
float factor_a
Alpha factor for SUT.
internal::TSequenceLandmarks::const_iterator const_iterator
float factor_b
Beta factor for the SUT.
float maxEDD_TH
Maximum Euclidean Distance Between SIFT Descriptors.
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
dynamic_vector< double > CVectorDouble
Column vector, like Eigen::MatrixXd, but automatically initialized to zeros since construction...
void deleteRepeatedFeats(CFeatureList &list)
Explore the feature list and removes features which are in the same coordinates.
bool validCovariances
True: The individual 3x3 covariance matrices must be taken into account, false (default): All the mea...
void getDispersion(const CFeatureList &list, mrpt::math::CVectorFloat &std, mrpt::math::CVectorFloat &mean)
Computes the dispersion of the features in the image.
TFeatureType get_type() const
The type of the first feature in the list.
mrpt::math::TPoint3D pose_mean
The mean of the landmark 3D position.
double distance(const TPoint2D &point) const
Distance from a given point.
This class is a "CSerializable" wrapper for "CMatrixFloat".
TMatchingMethod matching_method
Matching method.
GLubyte GLubyte GLubyte a
void normalizeImage(const mrpt::utils::CImage &image, mrpt::utils::CImage &nimage)
Normalizes the brigthness and contrast of an image by setting its mean value to zero and its standard...
GLenum const GLfloat * params
void projectMatchedFeature(const CFeature::Ptr &leftFeat, const CFeature::Ptr &rightFeat, mrpt::math::TPoint3D &p3D, const TStereoSystemParams ¶ms=TStereoSystemParams())
Computes the 3D position of a particular matched feature.
mrpt::math::CMatrixDouble33 defaultIntrinsicParamsMatrix(unsigned int camIndex=0, unsigned int resolutionX=320, unsigned int resolutionY=240)
Returns the stored, default intrinsic params matrix for a given camera:
struct mrpt::maps::CLandmarksMap::TCustomSequenceLandmarks landmarks
A structure for holding correspondences between two sets of points or points-like entities in 2D or 3...
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
mrpt::poses::CPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
Structure to hold the parameters of a pinhole camera model.
Uncertainty propagation through the Scaled Unscented Transformation.
float stdDisp
Standard deviation of the error in disparity computation.
void dumpToTextStream(mrpt::utils::CStream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
TLandmarkID ID
An ID for the landmark (see details next...) This ID was introduced in the version 3 of this class (2...
TMeasurementList sensedData
The list of observed ranges:
mrpt::math::CMatrixDouble33 K
Intrinsic parameters.
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
2D line without bounds, represented by its equation .
mrpt::math::CMatrixDouble33 buildIntrinsicParamsMatrix(const double focalLengthX, const double focalLengthY, const double centerX, const double centerY)
Builds the intrinsic parameters matrix A from parameters:
mrpt::math::CMatrixDouble33 covariance
The covariance matrix of the landmark, with variable indices [0,1,2] being [range,yaw,pitch].