Skip to content

Commit

Permalink
Added live.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
fyquah committed Jun 6, 2015
2 parents 0cc3338 + b2212ce commit f6105a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,4 +1,4 @@
build/
**.DS_STORE
json
live
live
30 changes: 25 additions & 5 deletions live.cpp
Expand Up @@ -15,6 +15,7 @@
#include <iostream>

#include "FiducialMap.h"
#include <cmath>

int main(int argc, char* argv[])
{
Expand Down Expand Up @@ -58,7 +59,7 @@ int main(int argc, char* argv[])
// at the same position. When tags disappear for more than 5 frames,
// Chilitags actually removes it.
// Here, we cancel this to show the raw detection results.
chilitags.setFilter(0, 0.0f);
//chilitags.setFilter(0, 0.0f);

cv::namedWindow("DisplayChilitags");
// Main loop, exiting when 'q is pressed'
Expand All @@ -84,11 +85,30 @@ int main(int argc, char* argv[])
cout << rectPoints[1] << endl;
cout << rectPoints[2] << endl;
cout << rectPoints[3] << endl;

float l1 = pow(pow((rectPoints[1].x - rectPoints[0].x),2) + pow((rectPoints[1].y - rectPoints[0].y),2),0.5);
float l2 = pow(pow((rectPoints[1].x - rectPoints[2].x),2) + pow((rectPoints[1].y - rectPoints[2].y),2),0.5);
float len;
if (l1 > l2) {len = l1;}
else {len = l2;}
len=len/50;
cv::Scalar col = cv::Scalar(0,180,0);


float notdeveloped = 20; //cm
float illegal = 10;

if (len<notdeveloped) {
col = cv::Scalar(0,165,255);
}

if (len<illegal) {
col = cv::Scalar(0,0,255);
}
for (int i = 0 ; i < 4 ; i++) {
cv::Scalar color = cv::Scalar(rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255));
line(outputImage, rectPoints[i], rectPoints[(i+1) % 4], color , 1, 8);
}
line(outputImage, rectPoints[i], rectPoints[(i+1) % 4], col , 2, 8);
}
cv::putText(outputImage, cv::format("%.01f", len), Point2f(50,50),
cv::FONT_HERSHEY_SIMPLEX, 2.0f, col);
} else {
cout << "Unable to obtained best rectangle!" << endl;
}
Expand Down

0 comments on commit f6105a1

Please sign in to comment.