From e1cbdbae7d915479a5eeec49f8465b9325382864 Mon Sep 17 00:00:00 2001 From: Zer01HD Date: Mon, 7 May 2018 18:21:48 -0500 Subject: [PATCH] minimum size slider --- src/Rectangle/Detection/ContourAnalyzer.cpp | 5 +++-- src/Rectangle/Detection/ContourAnalyzer.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Rectangle/Detection/ContourAnalyzer.cpp b/src/Rectangle/Detection/ContourAnalyzer.cpp index f020499..4d505a7 100755 --- a/src/Rectangle/Detection/ContourAnalyzer.cpp +++ b/src/Rectangle/Detection/ContourAnalyzer.cpp @@ -11,12 +11,12 @@ ContourAnalyzer::ContourAnalyzer(UI *ui, int *lastKey) { void ContourAnalyzer::analyze() { prunedContours.clear(); - if (*lastKey == 99) { cannyRec = !cannyRec; } else if (*lastKey == 118) { drawContours = !drawContours; } + minSize = ((ui->originalFrame()->cols)*(ui->originalFrame()->rows))*(minSizeScale/(float)10000); if (cannyRec) { cannyUpper = std::min(3*cannyLower, 255); @@ -31,7 +31,7 @@ void ContourAnalyzer::analyze() { for (unsigned i = 0; i < contours.size(); i++) { - if ((cv::contourArea(contours[i]) > 225) && (cv::contourArea(contours[i]) < (ui->currentFrame(0)->cols * ui->currentFrame(0)->rows) -25)) { + if ((cv::contourArea(contours[i]) > minSize) && (cv::contourArea(contours[i]) < (ui->currentFrame(0)->cols * ui->currentFrame(0)->rows) -25)) { double perimeter = cv::arcLength(contours[i], true); cv::approxPolyDP(contours[i], contours[i], (epsilon/(float)1000)*perimeter, true); @@ -102,6 +102,7 @@ void ContourAnalyzer::componentSetup() { cv::createTrackbar("Can. Lower", UI::DEBUG_WINDOW, &cannyLower , 255); cv::createTrackbar("Can. Upper", UI::DEBUG_WINDOW, &cannyUpper , 255); cv::createTrackbar("Epsilon", UI::DEBUG_WINDOW, &epsilon , 1000); + cv::createTrackbar("Min. Size", UI::DEBUG_WINDOW, &minSizeScale, 10000); } ContourAnalyzer::~ContourAnalyzer() { ui->UIListeners.erase(std::remove(ui->UIListeners.begin(), ui->UIListeners.end(), this)); diff --git a/src/Rectangle/Detection/ContourAnalyzer.h b/src/Rectangle/Detection/ContourAnalyzer.h index 77c62d3..76602ae 100755 --- a/src/Rectangle/Detection/ContourAnalyzer.h +++ b/src/Rectangle/Detection/ContourAnalyzer.h @@ -25,6 +25,8 @@ class ContourAnalyzer: public UIListener { public: int binLower = 52; + int minSize = 0; + int minSizeScale = 15; int cannyLower = 57; int cannyUpper = 3*cannyLower;