From 96dc6f448a80de41782d42a2cf5b16fd4b40cb25 Mon Sep 17 00:00:00 2001 From: Zer01HD Date: Tue, 8 May 2018 13:54:31 -0500 Subject: [PATCH] fixed concept based issues --- src/Rectangle/Ruler.cpp | 12 ++++++------ src/Rectangle/Ruler.h | 4 ++-- src/main.cpp | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Rectangle/Ruler.cpp b/src/Rectangle/Ruler.cpp index dc69ca6..5fa2b03 100755 --- a/src/Rectangle/Ruler.cpp +++ b/src/Rectangle/Ruler.cpp @@ -11,11 +11,11 @@ Ruler::Ruler(UI *ui, int *lastKey) { Ruler::ui = ui; Ruler::lastKey = lastKey; - focalLength = estimateFocalLength(); + focalLength = estimateFocalLength(HFOV); } void Ruler::update(cv::Rect rect) { - focalLength = estimateFocalLength(); + focalLength = estimateFocalLength(HFOV); distance = estimateDistance(rect); inputUpdate(); updateUI(); @@ -27,11 +27,11 @@ float Ruler::estimateFocalLength(int HFOV) { void Ruler::updateUI() { if (inputtingVal) { - cv::putText(*(ui->drawnFrame()), ("Given width: " << widthInCM), confTextPos, cv::FONT_HERSHEY_DUPLEX, 0.7, textFontColor + 50); + cv::putText(*(ui->drawnFrame()), ("Given width: " + std::to_string(widthInCM)), confTextPos, cv::FONT_HERSHEY_DUPLEX, 0.7, textFontColor, 2); } else { - cv::putText(*(ui->drawnFrame()), ("Given width: " << widthInCM), confTextPos, cv::FONT_HERSHEY_DUPLEX, 0.7, textFontColor); + cv::putText(*(ui->drawnFrame()), ("Given width: " + std::to_string(widthInCM)), confTextPos, cv::FONT_HERSHEY_DUPLEX, 0.7, textFontColor); } - cv::putText(*(ui->drawnFrame()), ("distance: " << distance << "cm"), distanceTextPos, cv::FONT_HERSHEY_DUPLEX, 0.7, textFontColor); + cv::putText(*(ui->drawnFrame()), ("distance: " + std::to_string(distance) + "cm"), distanceTextPos, cv::FONT_HERSHEY_DUPLEX, 0.7, textFontColor); } @@ -56,7 +56,7 @@ void Ruler::inputUpdate() { numBuild.push_back(val); } std::string numString{numBuild.begin(), numBuild.end()}; - numString >> widthInCM; + widthInCM = std::stod(numString); } } diff --git a/src/Rectangle/Ruler.h b/src/Rectangle/Ruler.h index b5ce937..ef0a91f 100755 --- a/src/Rectangle/Ruler.h +++ b/src/Rectangle/Ruler.h @@ -8,7 +8,7 @@ #ifndef RECTANGLE_RULER_H_ #define RECTANGLE_RULER_H_ #include "../UI.h" -#include "../UIListener.hpp"; +#include "../UIListener.hpp" class Ruler: public UIListener { cv::Point distanceTextPos {5, 60}; @@ -26,7 +26,7 @@ class Ruler: public UIListener { public: Ruler(UI *ui, int *lastKey); - float estimateFocalLength(int HFOV = Ruler::HFOV); + float estimateFocalLength(int HFOV); int estimateDistance(cv::Rect rect); void update(cv::Rect rect); void componentSetup(); diff --git a/src/main.cpp b/src/main.cpp index 799f498..ffc63e4 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,7 @@ BoundTracker tracker { lastKey, ui }; cv::Point statusTextPos {5, 15}; cv::Scalar textFontColor { 20, 20, 20}; cv::Scalar rectangleBoundColor { 255, 0, 0 }; - +cv::Rect subject; unsigned frameCount = 0; void run() { switch (state) { @@ -63,6 +63,7 @@ void run() { scaledSearchArea.y = std::min(scaledSearchArea.y, ui->getHeight()-scaledSearchArea.height -1); ca.analyze(scaledSearchArea); + ca.convertContoursToBounds();