50 nbRejectedMatches(-1),
53 weightedPointUsedRatio(-1.0)
64 assert(matches.
ids.rows() > 0);
65 assert(matches.
ids.cols() > 0);
66 assert(matches.
ids.cols() == requestedPts.
features.cols());
67 assert(outlierWeights.rows() == matches.
ids.rows());
69 const int knn = outlierWeights.rows();
70 const int dimFeat = requestedPts.
features.rows();
71 const int dimReqDesc = requestedPts.
descriptors.rows();
72 const int dimReqTime = requestedPts.
times.rows();
75 const int pointsCount = (outlierWeights.array() != 0.0).count();
79 Matrix keptFeat(dimFeat, pointsCount);
83 keptDesc =
Matrix(dimReqDesc, pointsCount);
89 Matches keptMatches (Dists(1,pointsCount), Ids(1, pointsCount));
93 int rejectedMatchCount = 0;
94 int rejectedPointCount = 0;
95 bool matchExist =
false;
96 this->weightedPointUsedRatio = 0;
98 for (
int i = 0; i < requestedPts.
features.cols(); ++i)
101 for(
int k = 0; k < knn; k++)
103 const auto matchDist = matches.
dists(k, i);
108 if (outlierWeights(k,i) != 0.0)
114 keptTime.col(j) = requestedPts.
times.col(i);
117 keptFeat.col(j) = requestedPts.
features.col(i);
118 keptMatches.
ids(0, j) = matches.
ids(k, i);
119 keptMatches.
dists(0, j) = matchDist;
120 keptWeights(0,j) = outlierWeights(k,i);
122 this->weightedPointUsedRatio += outlierWeights(k,i);
127 rejectedMatchCount++;
131 if(matchExist ==
false)
133 rejectedPointCount++;
137 assert(j == pointsCount);
139 this->pointUsedRatio = T(j)/T(knn*requestedPts.
features.cols());
140 this->weightedPointUsedRatio /= T(knn*requestedPts.
features.cols());
142 assert(dimFeat == sourcePts.
features.rows());
143 const int dimSourDesc = sourcePts.
descriptors.rows();
144 const int dimSourTime = sourcePts.
times.rows();
146 Matrix associatedFeat(dimFeat, pointsCount);
150 associatedDesc =
Matrix(dimSourDesc, pointsCount);
154 associatedTime =
Int64Matrix(dimSourTime, pointsCount);
157 for (
int i = 0; i < pointsCount; ++i)
159 const int refIndex(keptMatches.
ids(i));
160 associatedFeat.col(i) = sourcePts.
features.block(0, refIndex, dimFeat, 1);
163 associatedDesc.col(i) = sourcePts.
descriptors.block(0, refIndex, dimSourDesc, 1);
166 associatedTime.col(i) = sourcePts.
times.block(0, refIndex, dimSourTime, 1);
189 this->weights = keptWeights;
190 this->matches = keptMatches;
191 this->nbRejectedMatches = rejectedMatchCount;
192 this->nbRejectedPoints = rejectedPointCount;
228 this->lastErrorElements = matchedPoints;
238 return lastErrorElements.pointUsedRatio;
246 return lastErrorElements;
253 return lastErrorElements.weightedPointUsedRatio;
260 LOG_WARNING_STREAM(
"ErrorMinimizer - warning, no specific method to compute overlap was provided for the ErrorMinimizer used.");
261 return lastErrorElements.weightedPointUsedRatio;
268 LOG_WARNING_STREAM(
"ErrorMinimizer - warning, no specific method to compute covariance was provided for the ErrorMinimizer used.");
269 return Matrix::Zero(6,6);
276 LOG_WARNING_STREAM(
"ErrorMinimizer - warning, no specific method to compute residual was provided for the ErrorMinimizer used.");
277 return std::numeric_limits<T>::max();
287 assert(A.cols() == B.cols());
290 assert(A.rows() -1 == B.rows());
293 assert(A.rows() == 4 || A.rows() == 3);
295 const unsigned int x = 0;
296 const unsigned int y = 1;
297 const unsigned int z = 2;
302 cross =
Matrix(B.rows(), B.cols());
304 cross.row(
x) = A.row(y).array() * B.row(z).array() - A.row(z).array() * B.row(y).array();
305 cross.row(y) = A.row(z).array() * B.row(
x).array() - A.row(
x).array() * B.row(z).array();
306 cross.row(z) = A.row(
x).array() * B.row(y).array() - A.row(y).array() * B.row(
x).array();
312 cross = A.row(
x).array() * B.row(y).array() - A.row(y).array() * B.row(
x).array();