Exemplo n.º 1
0
QImage Rotater::RotateWithCornerFilling(const QImage image)
{
    QImage destImage = QImage( image);
    QImage origImage = QImage( image);

    vector<Form> lines;

    readLines(destImage, &lines);
//    m_line_detector->print(lines, LineFacts, -1);

    for (int quater=1; quater<=4; quater++)
    {
        get_shift_values(quater, lines.at(quater-1));
//        if (quater != 1) continue;
//        destImage = markOnImage( destImage, m_dx[0], m_dy[0], 1); // TEST
//        destImage = markOnImage( destImage, m_dx[5], m_dy[5], 0); // TEST
    }
    destImage = shiftImage( destImage);

    destImage = RotateImage( destImage, origImage);

    return destImage;
}
Exemplo n.º 2
0
// ######################################################################
 Image<byte> calculateShift(Image<byte> lum, Image<byte> prevLum,
                            nub::ref<OutputFrameSeries> ofs)
{
  VisualObjectMatchAlgo voma(VOMA_SIMPLE);
//   if (strcmp(argv[1], "KDTree") == 0) voma = VOMA_KDTREE;
//   else if (strcmp(argv[1], "KDBBF") == 0) voma = VOMA_KDTREEBBF;
//   else if (strcmp(argv[1], "Simple") != 0)
//     LFATAL("Unknown matching method %s", argv[0]);

  // create visual objects:
  rutz::shared_ptr<VisualObject> vo1(new VisualObject("lum", "", lum));
  rutz::shared_ptr<VisualObject> vo2(new VisualObject("plum", "", prevLum));

  // compute the matching keypoints:
  VisualObjectMatch match(vo1, vo2, voma);
  LDEBUG("Found %u matches", match.size());

  // let's prune the matches:
  uint np = match.prune();
  LDEBUG("Pruned %u outlier matches.", np);

  // show our final affine transform:
  SIFTaffine s = match.getSIFTaffine();
  LDEBUG("[tstX]   [ %- .3f %- .3f ] [refX]   [%- .3f]", s.m1, s.m2, s.tx);
  LDEBUG("[tstY] = [ %- .3f %- .3f ] [refY] + [%- .3f]", s.m3, s.m4, s.ty);


  LDEBUG("getKeypointAvgDist = %f", match.getKeypointAvgDist());
  LDEBUG("getAffineAvgDist = %f", match.getAffineAvgDist());
  LDEBUG("getScore = %f", match.getScore());

  if (match.checkSIFTaffine() == false)
    LINFO("### Affine is too weird -- BOGUS MATCH");

  // get an image showing the matches:
  Image< PixRGB<byte> > mimg = match.getMatchImage(1.0F);
  Image< PixRGB<byte> > fimg = match.getFusedImage(0.25F);

  // LINFO("lum");
  // ofs->writeRGB
  //   (toRGB(lum), "test-FOE Main", FrameInfo("foe output", SRC_POS));
  // Raster::waitForKey();

  // LINFO("prevLum");
  // ofs->writeRGB
  //   (toRGB(prevLum), "test-FOE Main", FrameInfo("foe output", SRC_POS));
  // Raster::waitForKey();


  LINFO("Shift: %f %f", s.tx, s.ty);
  // ofs->writeRGB
  //   (fimg, "test-FOE Main", FrameInfo("foe output", SRC_POS));
  // Raster::waitForKey();

  Image<byte> res = shiftImage(s, lum, prevLum);

  // LINFO("shifted result");
  // ofs->writeRGB
  //   (toRGB(res), "test-FOE Main", FrameInfo("foe output", SRC_POS));
  // Raster::waitForKey();

  //Point2D<float> shift(s.tx,s.ty);
  return res;
}