minimum size slider
This commit is contained in:
parent
c2b817d200
commit
e1cbdbae7d
@ -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));
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user