From 9746242e57cb494992cb8df103ccf5b66e37bec3 Mon Sep 17 00:00:00 2001 From: gdd Date: Fri, 28 Oct 2011 13:45:22 +0000 Subject: [PATCH] rnc: - Fix of the contour correction mechanism - Added some debug tools - Call to FeatureDetector methods with nex parameters - Test of a segment detector --- .../EntityGUI_FeatureDetectorDlg.cxx | 99 ++++++++++++++++--- src/EntityGUI/EntityGUI_FeatureDetectorDlg.h | 2 + 2 files changed, 90 insertions(+), 11 deletions(-) diff --git a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx index 7cb0c85c0..a3570c28a 100644 --- a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx +++ b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx @@ -79,7 +79,8 @@ // Constructors enum{ CONTOURS, - CORNERS + CORNERS, + LINES }; enum { @@ -119,8 +120,8 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom mainFrame()->RadioButton2->setText(tr("GEOM_CORNERS")); // mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); // mainFrame()->RadioButton2->close(); - mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); - mainFrame()->RadioButton3->close(); +// mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); +// mainFrame()->RadioButton3->close(); // myViewGroup = new DlgRef_3Radio(centralWidget()); // myViewGroup->GroupBox1->setTitle(tr("GEOM_VIEW")); @@ -143,12 +144,14 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom mySelButton = new QPushButton(mySelectionGroup); mySelButton->setIcon(image1); myLineEdit = new QLineEdit(mySelectionGroup); + myCheckBox = new QCheckBox(mySelectionGroup); mySnapshotLabel = new QLabel(mySelectionGroup); mySelectGrpLayout->addWidget(myLineEdit, 0, 1); mySelectGrpLayout->addWidget(mySelButton, 0, 0); mySelectGrpLayout->addWidget(mySnapshotLabel, 1, 1); mySelectGrpLayout->addWidget(myPushButton, 1, 0); + mySelectGrpLayout->addWidget(myCheckBox, 2, 0); myOutputGroup = new DlgRef_3Radio(centralWidget()); myOutputGroup->GroupBox1->setTitle(tr("GEOM_DETECT_OUTPUT")); @@ -378,6 +381,13 @@ void EntityGUI_FeatureDetectorDlg::ConstructorsClicked(int id) mySnapshotLabel->setText(tr("GEOM_COLOR_FILTER")); initName(tr("GEOM_CONTOURS")); break; + case LINES: +// myViewGroup->hide(); +// mySelectionGroup->hide(); +// mySelectionGroup->show(); + mySnapshotLabel->setText(tr("")); + initName(tr("GEOM_LINES")); + break; } } @@ -593,15 +603,17 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) } else if (myConstructorId == CONTOURS) { - if( !aRect.isEmpty() ) + int method = 0 ; //CANNY + if( !aRect.isEmpty() && aRect.width() > 1 ) { aDetector->SetROI( aRect ); + method = 1 ; //COLORFILTER } GEOM::GEOM_ICurvesOperations_var aCurveOperations = myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); // GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); - aDetector->ComputeContours(); + aDetector->ComputeContours( method ); std::vector< std::vector > contours = aDetector->GetContours(); std::vector hierarchy = aDetector->GetContoursHierarchy(); @@ -613,6 +625,11 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) bool insert; + // TEST for debug only +// GEOM::GEOM_Object_var aRemovedPnt; +// GEOM::ListOfGO_var removedPnts = new GEOM::ListOfGO(); +// int r = 0; + MESSAGE("hierarchy.size() =" << hierarchy.size()) for( ; idx >= 0; idx = hierarchy[idx][0]) { @@ -625,6 +642,7 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) std::vector< cv::Point >::iterator it_next; GEOM::GEOM_Object_var aGeomContourPnt; GEOM::ListOfGO_var geomContourPnts = new GEOM::ListOfGO(); + geomContourPnts->length( contour.size() ); int j = 0; @@ -642,7 +660,7 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) std::vector pnt (pnt_array, pnt_array + sizeof(pnt_array) / sizeof(int) ); pnt_it=existing_points.insert(pnt); - if (pnt_it.second == true) // To avoid double points in the contours + if (pnt_it.second == true || !myCheckBox->isChecked() ) // To avoid double points in the contours { insert = true; if (it!=contour.begin()) // From the second point on perform some checking to avoid loops in the contours we build @@ -665,22 +683,44 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) double u_v_sinus = u_v_det / (norme_u * norme_v); - if (u_v_sinus < Precision::Confusion()) + if (fabs(u_v_sinus) < Precision::Confusion()) { - insert =false; + // TEST for debug only +// if (myCheckBox->isChecked()) +// { +// MESSAGE("correction appliquee : fabs(u_v_sinus) ="<x = "<x) +// MESSAGE("it->y = "<y) +// MESSAGE("it_previous->x = "<x) +// MESSAGE("it_previous->y = "<y) +// MESSAGE("it_next->x = "<x) +// MESSAGE("it_next->y = "<y) +// MESSAGE("norme_u = "<