PatternMatcherIsometric::Result PatternMatcherIsometric::MatchImagePairs()

in IsometricPatternMatcher/PatternMatcherIsometric.cpp [173:231]


PatternMatcherIsometric::Result PatternMatcherIsometric::MatchImagePairs(
    const Image<uint8_t>& imageCode1U8,
    const Image<uint8_t>& imageCode0U8) const {
  CHECK(((imageCode1U8.w == imageCode0U8.w) &&
         (imageCode1U8.h == imageCode0U8.h)))
      << "imageCode1 and imageCode0 should have same size";
  // detect dots
  PatternMatcherIsometric::Result res;
  Eigen::Matrix2Xd detectedCode1Dots = DotDetection(imageCode1U8);
  Eigen::Matrix2Xd detectedCode0Dots = DotDetection(imageCode0U8);
  Eigen::Matrix2Xd detectedDots(
      detectedCode1Dots.rows(),
      detectedCode1Dots.cols() + detectedCode0Dots.cols());
  detectedDots << detectedCode1Dots, detectedCode0Dots;
  for (int i = 0; i < detectedCode1Dots.cols(); ++i) {
    res.debug.feature_pts.push_back(detectedCode1Dots.col(i));
  }
  for (int i = 0; i < detectedCode0Dots.cols(); ++i) {
    res.debug.feature_pts.push_back(detectedCode0Dots.col(i));
  }

  // get intensity of the extracted dots
  Eigen::VectorXd intensityCode1 =
      GetIntensity(detectedCode1Dots, imageCode1U8);
  Eigen::VectorXd intensityCode0 =
      GetIntensity(detectedCode0Dots, imageCode0U8);
  CHECK(intensityCode1.rows() == detectedCode1Dots.cols())
      << "intensity and dot position length not consistent";
  CHECK(intensityCode1.rows() == detectedCode1Dots.cols())
      << "intensity and dot position length not consistent";

  // build dot code labels
  Eigen::VectorXi dotLabels(intensityCode1.rows() + intensityCode0.rows());
  Eigen::VectorXi labelOne(intensityCode1.rows());
  labelOne.setOnes();
  Eigen::VectorXi labelZero(intensityCode0.rows());
  labelZero.setZero();
  dotLabels << labelOne, labelZero;

  // detect pattern from the extracted dots
  Eigen::Vector2d centerXY;
  centerXY << imageCode1U8.w / 2, imageCode1U8.h / 2;
  double spacing = 1.0;
  int numNeighboursForPoseEst = 3;
  HexGridFitting grid(
      detectedDots, centerXY, opts_.focalLength, dotLabels, opts_.ifDistort,
      true, opts_.ifPoseMerge, opts_.goodPoseInlierRatio, spacing,
      numNeighboursForPoseEst, opts_.numberSegX, opts_.numberSegY);

  // store detected pattern into a storagemap
  Eigen::Vector2i offset;
  int rotationIndx;
  StoreIntoMap(grid, detectedDots, res, rotationIndx, offset);

  // Generate result
  generateResult(grid, detectedDots, rotationIndx, offset, res);

  return res;
}