This version was submitted

This commit is contained in:
Harrison Deng 2018-05-08 22:05:40 -05:00
parent 0efd3a02f7
commit 1a4101e800
7 changed files with 22 additions and 51 deletions

1
.gitignore vendored
View File

@ -97,3 +97,4 @@ local.properties
# End of https://www.gitignore.io/api/eclipse # End of https://www.gitignore.io/api/eclipse
/Debug/ /Debug/
/Release/

View File

@ -52,7 +52,6 @@ bool Confidence::check(std::vector<cv::Rect> bounds) {
cv::Point{5, 45}, cv::FONT_HERSHEY_PLAIN, 0.8, boundColor); cv::Point{5, 45}, cv::FONT_HERSHEY_PLAIN, 0.8, boundColor);
} }
// std::cout << confident.size() << std::endl;
return (confident.size() > 0); return (confident.size() > 0);
} }
@ -68,5 +67,4 @@ void Confidence::drawBoundsOnMat(cv::Mat &mat) {
Confidence::~Confidence() { Confidence::~Confidence() {
// TODO Auto-generated destructor stub
} }

View File

@ -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
}

View File

@ -1,22 +0,0 @@
/*
* RectangleTracker.h
*
* Created on: Apr 29, 2018
* Author: yunya
*/
#ifndef RECTANGLE_RECTANGLETRACKER_H_
#define RECTANGLE_RECTANGLETRACKER_H_
#include <opencv2/core/utility.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
class RectangleTracker {
public:
RectangleTracker();
virtual ~RectangleTracker();
};
#endif /* RECTANGLE_RECTANGLETRACKER_H_ */

View File

@ -4,6 +4,7 @@
Ruler::Ruler(std::shared_ptr<UI> ui, std::shared_ptr<int> lastKey) { Ruler::Ruler(std::shared_ptr<UI> ui, std::shared_ptr<int> lastKey) {
this->ui = ui; this->ui = ui;
this->lastKey = lastKey; this->lastKey = lastKey;
ui->UIListeners.push_back(this);
} }
void Ruler::update() { void Ruler::update() {
@ -71,10 +72,10 @@ void Ruler::setDetectedWidth(int width) {
} }
void Ruler::componentSetup() { void Ruler::componentSetup() {
cv::createTrackbar("HFOV", UI::DEBUG_WINDOW, &HFOV , 100);
} }
Ruler::~Ruler() { Ruler::~Ruler() {
// TODO Auto-generated destructor stub ui->UIListeners.erase(std::remove(ui->UIListeners.begin(), ui->UIListeners.end(), this));
} }

View File

@ -16,7 +16,7 @@ class Ruler: public UIListener {
float distance = 0; float distance = 0;
float givenWidth = 0; float givenWidth = 0;
float focalLength = 0; float focalLength = 0;
float HFOV = 60; int HFOV = 54;
bool inputtingVal = false; bool inputtingVal = false;
std::deque<char> numBuild; std::deque<char> numBuild;

View File

@ -17,15 +17,15 @@ Webcam webcam;
std::shared_ptr<int> lastKey {new int(0)}; std::shared_ptr<int> lastKey {new int(0)};
std::shared_ptr<UI> ui {new UI(lastKey)}; std::shared_ptr<UI> ui {new UI(lastKey)};
ContourAnalyzer ca { ui, lastKey }; ContourAnalyzer ca { ui, lastKey };
Confidence conf { lastKey, ui, 6, 0.78}; Confidence conf { lastKey, ui, 5, 0.74};
BoundTracker tracker { lastKey, ui }; 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 };
Ruler ruler{ui, lastKey}; Ruler ruler{ui, lastKey};
cv::RotatedRect subject;
unsigned frameCount = 0; unsigned frameCount = 0;
cv::Point center;
void run() { void run() {
switch (state) { switch (state) {
case detection: case detection:
@ -83,7 +83,14 @@ void run() {
largest.y += scaledSearchArea.y; largest.y += scaledSearchArea.y;
tracker.init(largest); 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; break;
@ -117,7 +124,7 @@ void run() {
frameCount = 0; frameCount = 0;
} }
} }
cv::rectangle(*(ui->drawnFrame()), largest, cv::Scalar { 255, 0, 0 }, 1); cv::rectangle(*(ui->drawnFrame()), largest, cv::Scalar { 100, 0, 0});
} else { } else {
frameCount++; frameCount++;
if (frameCount > 30) { 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; break;
} }
ruler.update(); ruler.update();
ui->render(); ui->render();
} }