コード例 #1
0
void ExtractionWidget::afficheLineDetection ()
{
  augmentedImage = loadedImage;
  QPainter painter (&augmentedImage);
  drawStraightLine (p1, p2, Qt::red, painter);

//cout << "P1 = (" << p1.x () << "," << p1.y ()
//     << ") et P2 = (" << p2.x () << "," << p2.y () << ")" << endl;

  if (manualModeOn)
  {
    /** ZZZ
    DirectionalScan dirScan = DirectionalScan (p1, p2);
    dirScan.computeAllScans (0, 0, width, height);
    */
    DirectionalScan dirScan = DirectionalScan (p1, p2, 0, 0, width, height);

    vector<Pixel> pointsLineOrigin  = dirScan.getLeftScan (0);
    drawListPixels (pointsLineOrigin, Qt::white, painter);

    Profile *pr = prof->profile ();
    pr->clear ();
    pr->addCentral (p1, p2);
    for (int i = 0; i < dirScan.getNbRightScan (); i++)
      pr->addToRight (vector<Pixel> (dirScan.getRightScan (i)));
    for (int i = 0; i < dirScan.getNbLeftScan (); i++)
      pr->addToLeft (vector<Pixel> (dirScan.getLeftScan (i)));

    update (QRect (QPoint (0, 0), QPoint (width, height)));

    prof->scene()->update ();
    prof->show ();
    return;
  }

  BlurredSegment *bs = detector.detect (p1, p2);
  vector<Pixel> vpoints;
  if (bs != NULL) vpoints = bs->getPrintedPoints ();

  if (vpoints.size () < 6)
  {
    return;
  }

  if (supportLinesDisplayOn)
  {
    drawListPixels (vpoints, Qt::blue, painter);
  }

  lastDetectedSegment.vectPoints = vpoints;
  lastDetectedSegment.p1 = p1;
  lastDetectedSegment.p2 = p2;

  painter.setPen (QPen (Qt::red, myPenWidth, Qt::SolidLine,
                        Qt::RoundCap, Qt::RoundJoin));
  painter.drawText (100, 20,
       tr ("E : width = ") + QString::number (segmentMaxWidth));
  painter.drawText (100, 40,
       tr ("Z : # pixels missing = ") + QString::number (detectionLacks));

  update (QRect (QPoint (0, 0), QPoint (width, height)));
}