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
/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);
}
// 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
}

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) {
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));
}

View File

@ -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<char> numBuild;

View File

@ -17,15 +17,15 @@ Webcam webcam;
std::shared_ptr<int> lastKey {new int(0)};
std::shared_ptr<UI> 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();
}