From 1a4101e8008877b0982ba37daff4fc2ec0f5c662 Mon Sep 17 00:00:00 2001 From: Zer01HD Date: Tue, 8 May 2018 22:05:40 -0500 Subject: [PATCH] This version was submitted --- .gitignore | 1 + src/Rectangle/Confidence.cpp | 2 -- src/Rectangle/RectangleTracker.cpp | 18 ------------------ src/Rectangle/RectangleTracker.h | 22 ---------------------- src/Rectangle/Ruler.cpp | 5 +++-- src/Rectangle/Ruler.h | 2 +- src/main.cpp | 23 +++++++++++++++++------ 7 files changed, 22 insertions(+), 51 deletions(-) delete mode 100755 src/Rectangle/RectangleTracker.cpp delete mode 100755 src/Rectangle/RectangleTracker.h diff --git a/.gitignore b/.gitignore index 8280406..26c2548 100755 --- a/.gitignore +++ b/.gitignore @@ -97,3 +97,4 @@ local.properties # End of https://www.gitignore.io/api/eclipse /Debug/ +/Release/ diff --git a/src/Rectangle/Confidence.cpp b/src/Rectangle/Confidence.cpp index bb9b8eb..81d7036 100755 --- a/src/Rectangle/Confidence.cpp +++ b/src/Rectangle/Confidence.cpp @@ -52,7 +52,6 @@ bool Confidence::check(std::vector bounds) { cv::Point{5, 45}, cv::FONT_HERSHEY_PLAIN, 0.8, boundColor); } -// std::cout << confident.size() << std::endl; return (confident.size() > 0); } @@ -68,5 +67,4 @@ void Confidence::drawBoundsOnMat(cv::Mat &mat) { Confidence::~Confidence() { - // TODO Auto-generated destructor stub } diff --git a/src/Rectangle/RectangleTracker.cpp b/src/Rectangle/RectangleTracker.cpp deleted file mode 100755 index 0ffeb9b..0000000 --- a/src/Rectangle/RectangleTracker.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * RectangleTracker.cpp - * - * Created on: Apr 29, 2018 - * Author: yunya - */ - -#include "RectangleTracker.h" - -RectangleTracker::RectangleTracker() { - // TODO Auto-generated constructor stub - -} - -RectangleTracker::~RectangleTracker() { - // TODO Auto-generated destructor stub -} - diff --git a/src/Rectangle/RectangleTracker.h b/src/Rectangle/RectangleTracker.h deleted file mode 100755 index d0aa91d..0000000 --- a/src/Rectangle/RectangleTracker.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * RectangleTracker.h - * - * Created on: Apr 29, 2018 - * Author: yunya - */ - -#ifndef RECTANGLE_RECTANGLETRACKER_H_ -#define RECTANGLE_RECTANGLETRACKER_H_ -#include -#include -#include -#include - -class RectangleTracker { - -public: - RectangleTracker(); - virtual ~RectangleTracker(); -}; - -#endif /* RECTANGLE_RECTANGLETRACKER_H_ */ diff --git a/src/Rectangle/Ruler.cpp b/src/Rectangle/Ruler.cpp index 2f0d0fd..bbb5f35 100755 --- a/src/Rectangle/Ruler.cpp +++ b/src/Rectangle/Ruler.cpp @@ -4,6 +4,7 @@ Ruler::Ruler(std::shared_ptr ui, std::shared_ptr lastKey) { this->ui = ui; this->lastKey = lastKey; + ui->UIListeners.push_back(this); } void Ruler::update() { @@ -71,10 +72,10 @@ void Ruler::setDetectedWidth(int width) { } void Ruler::componentSetup() { - + cv::createTrackbar("HFOV", UI::DEBUG_WINDOW, &HFOV , 100); } Ruler::~Ruler() { - // TODO Auto-generated destructor stub + ui->UIListeners.erase(std::remove(ui->UIListeners.begin(), ui->UIListeners.end(), this)); } diff --git a/src/Rectangle/Ruler.h b/src/Rectangle/Ruler.h index 374ec53..5840b58 100755 --- a/src/Rectangle/Ruler.h +++ b/src/Rectangle/Ruler.h @@ -16,7 +16,7 @@ class Ruler: public UIListener { float distance = 0; float givenWidth = 0; float focalLength = 0; - float HFOV = 60; + int HFOV = 54; bool inputtingVal = false; std::deque numBuild; diff --git a/src/main.cpp b/src/main.cpp index 126a045..2259690 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,15 +17,15 @@ Webcam webcam; std::shared_ptr lastKey {new int(0)}; std::shared_ptr ui {new UI(lastKey)}; ContourAnalyzer ca { ui, lastKey }; -Confidence conf { lastKey, ui, 6, 0.78}; +Confidence conf { lastKey, ui, 5, 0.74}; BoundTracker tracker { lastKey, ui }; cv::Point statusTextPos {5, 15}; cv::Scalar textFontColor { 20, 20, 20}; cv::Scalar rectangleBoundColor { 255, 0, 0 }; Ruler ruler{ui, lastKey}; -cv::RotatedRect subject; unsigned frameCount = 0; +cv::Point center; void run() { switch (state) { case detection: @@ -83,7 +83,14 @@ void run() { largest.y += scaledSearchArea.y; tracker.init(largest); } - cv::rectangle(*(ui->drawnFrame()), tracker.getROI(), cv::Scalar {255, 0, 0}, 2); + + cv::Rect2d bound = tracker.getROI(); + center.x = bound.width/2; + center.y = bound.height/2; + center.x += bound.x; + center.y += bound.y; + + cv::circle(*(ui->drawnFrame()), center, 3, rectangleBoundColor, 2); } break; @@ -117,7 +124,7 @@ void run() { frameCount = 0; } } - cv::rectangle(*(ui->drawnFrame()), largest, cv::Scalar { 255, 0, 0 }, 1); + cv::rectangle(*(ui->drawnFrame()), largest, cv::Scalar { 100, 0, 0}); } else { frameCount++; if (frameCount > 30) { @@ -126,11 +133,15 @@ void run() { } } - cv::rectangle(*(ui->drawnFrame()), tracker.getROI(), cv::Scalar { 255, 0, 0 }, 2); + cv::Rect2d bound = tracker.getROI(); + center.x = bound.width/2; + center.y = bound.height/2; + center.x += bound.x; + center.y += bound.y; + cv::circle(*(ui->drawnFrame()), center, 3, rectangleBoundColor); break; } - ruler.update(); ui->render(); }