in IsometricPatternMatcher/PatternMatcherIsometric.cpp [94:136]
void PatternMatcherIsometric::generateResult(
const HexGridFitting& grid, const Eigen::Matrix2Xd& detectedDots,
int rotationIndx, const Eigen::Vector2i& offset,
PatternMatcherIsometric::Result& res) const {
Eigen::MatrixXi referenceIndxMap;
size_t storageMapRows = isometricGrids_[0]->storageMapRows();
referenceIndxMap.resize(storageMapRows, storageMapRows);
for (int r = 0; r < storageMapRows; ++r) {
for (int c = 0; c < storageMapRows; ++c)
referenceIndxMap(r, c) = r * storageMapRows + c;
}
fmt::print("rotationIndx: {}, offset: ({}, {}).\n", rotationIndx, offset.x(),
offset.y());
for (int i = 0; i < rotationIndx; ++i) {
referenceIndxMap = isometricGrids_[0]->Rotate60Right(referenceIndxMap);
}
Eigen::Matrix<double, 2, Eigen::Dynamic> correspondences;
correspondences.resize(2, isometricGrids_[0]->GetPattern().cols());
correspondences.setConstant(std::numeric_limits<double>::quiet_NaN());
Eigen::MatrixXi detectedIndxMap = grid.indexMap();
int numVisualizedDot = 0;
for (int r = 0; r < detectedIndxMap.rows(); ++r) {
for (int c = 0; c < detectedIndxMap.cols(); ++c) {
if (r + offset.x() >= 0 && r + offset.x() < storageMapRows &&
c + offset.y() >= 0 && c + offset.y() < storageMapRows) {
const int id = referenceIndxMap(r + offset.x(), c + offset.y());
if (detectedIndxMap(r, c) >= 0) {
CHECK(id < correspondences.cols());
if (isometricGrids_[0]->GetBinaryPatternGroup()[rotationIndx](
r + offset.x(), c + offset.y()) ==
grid.detectPattern()(r, c) &&
grid.detectPattern()(r, c) != 2) {
correspondences.col(id) = detectedDots.col(detectedIndxMap(r, c));
numVisualizedDot += 1;
}
}
} // end if
} // end c
} // end r
res.detections.emplace_back(0, correspondences);
std::cout << "Visualize matched point number is: " << numVisualizedDot
<< std::endl;
}