fixed concept based issues
This commit is contained in:
parent
8c413c5adb
commit
96dc6f448a
@ -11,11 +11,11 @@
|
|||||||
Ruler::Ruler(UI *ui, int *lastKey) {
|
Ruler::Ruler(UI *ui, int *lastKey) {
|
||||||
Ruler::ui = ui;
|
Ruler::ui = ui;
|
||||||
Ruler::lastKey = lastKey;
|
Ruler::lastKey = lastKey;
|
||||||
focalLength = estimateFocalLength();
|
focalLength = estimateFocalLength(HFOV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ruler::update(cv::Rect rect) {
|
void Ruler::update(cv::Rect rect) {
|
||||||
focalLength = estimateFocalLength();
|
focalLength = estimateFocalLength(HFOV);
|
||||||
distance = estimateDistance(rect);
|
distance = estimateDistance(rect);
|
||||||
inputUpdate();
|
inputUpdate();
|
||||||
updateUI();
|
updateUI();
|
||||||
@ -27,11 +27,11 @@ float Ruler::estimateFocalLength(int HFOV) {
|
|||||||
|
|
||||||
void Ruler::updateUI() {
|
void Ruler::updateUI() {
|
||||||
if (inputtingVal) {
|
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 {
|
} 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);
|
numBuild.push_back(val);
|
||||||
}
|
}
|
||||||
std::string numString{numBuild.begin(), numBuild.end()};
|
std::string numString{numBuild.begin(), numBuild.end()};
|
||||||
numString >> widthInCM;
|
widthInCM = std::stod(numString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#ifndef RECTANGLE_RULER_H_
|
#ifndef RECTANGLE_RULER_H_
|
||||||
#define RECTANGLE_RULER_H_
|
#define RECTANGLE_RULER_H_
|
||||||
#include "../UI.h"
|
#include "../UI.h"
|
||||||
#include "../UIListener.hpp";
|
#include "../UIListener.hpp"
|
||||||
|
|
||||||
class Ruler: public UIListener {
|
class Ruler: public UIListener {
|
||||||
cv::Point distanceTextPos {5, 60};
|
cv::Point distanceTextPos {5, 60};
|
||||||
@ -26,7 +26,7 @@ class Ruler: public UIListener {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Ruler(UI *ui, int *lastKey);
|
Ruler(UI *ui, int *lastKey);
|
||||||
float estimateFocalLength(int HFOV = Ruler::HFOV);
|
float estimateFocalLength(int HFOV);
|
||||||
int estimateDistance(cv::Rect rect);
|
int estimateDistance(cv::Rect rect);
|
||||||
void update(cv::Rect rect);
|
void update(cv::Rect rect);
|
||||||
void componentSetup();
|
void componentSetup();
|
||||||
|
@ -20,7 +20,7 @@ BoundTracker tracker { lastKey, ui };
|
|||||||
cv::Point statusTextPos {5, 15};
|
cv::Point statusTextPos {5, 15};
|
||||||
cv::Scalar textFontColor { 20, 20, 20};
|
cv::Scalar textFontColor { 20, 20, 20};
|
||||||
cv::Scalar rectangleBoundColor { 255, 0, 0 };
|
cv::Scalar rectangleBoundColor { 255, 0, 0 };
|
||||||
|
cv::Rect subject;
|
||||||
unsigned frameCount = 0;
|
unsigned frameCount = 0;
|
||||||
void run() {
|
void run() {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
@ -63,6 +63,7 @@ void run() {
|
|||||||
scaledSearchArea.y = std::min(scaledSearchArea.y, ui->getHeight()-scaledSearchArea.height -1);
|
scaledSearchArea.y = std::min(scaledSearchArea.y, ui->getHeight()-scaledSearchArea.height -1);
|
||||||
|
|
||||||
ca.analyze(scaledSearchArea);
|
ca.analyze(scaledSearchArea);
|
||||||
|
|
||||||
ca.convertContoursToBounds();
|
ca.convertContoursToBounds();
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user