view from top added

This commit is contained in:
Micaela Verucchi
2019-04-20 17:06:37 +02:00
parent ea1f0cc193
commit 41ba8afa6d
2 changed files with 19 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

+19 -1
View File
@@ -68,6 +68,10 @@ int main(int argc, char *argv[])
cv::Mat frame; cv::Mat frame;
cv::Mat dnn_input; cv::Mat dnn_input;
cv::namedWindow("detection", cv::WINDOW_NORMAL); cv::namedWindow("detection", cv::WINDOW_NORMAL);
cv::namedWindow("topview", cv::WINDOW_NORMAL);
cv::Mat frame_top;
frame_top = cv::imread("../demo/demo/data/map_b.jpg");
/*projection matrix*/ /*projection matrix*/
@@ -93,7 +97,7 @@ int main(int argc, char *argv[])
std::vector<Tracker> trackers; std::vector<Tracker> trackers;
std::vector<Data> cur_frame; std::vector<Data> cur_frame;
int initial_age = -5; int initial_age = -5;
int age_threshold = -20; int age_threshold = -8;
int n_states = 5; int n_states = 5;
float dt = 0.03; float dt = 0.03;
@@ -103,6 +107,7 @@ int main(int argc, char *argv[])
while (gRun) while (gRun)
{ {
cap >> frame; cap >> frame;
if (!frame.data) if (!frame.data)
{ {
@@ -154,8 +159,11 @@ int main(int argc, char *argv[])
//std::cout<<obj_class<<" ("<<prob<<"): "<<x0<<" "<<y0<<" "<<x1<<" "<<y1<<"\n"; //std::cout<<obj_class<<" ("<<prob<<"): "<<x0<<" "<<y0<<" "<<x1<<" "<<y1<<"\n";
cv::rectangle(frame, cv::Point(x0, y0), cv::Point(x1, y1), yolo.colors[obj_class], 2); cv::rectangle(frame, cv::Point(x0, y0), cv::Point(x1, y1), yolo.colors[obj_class], 2);
} }
TIMER_START
cur_frame.clear(); cur_frame.clear();
for (int i = 0; i < coord_i; i++) for (int i = 0; i < coord_i; i++)
{ {
@@ -177,6 +185,8 @@ int main(int argc, char *argv[])
Track(cur_frame, dt, n_states, initial_age, age_threshold, trackers); Track(cur_frame, dt, n_states, initial_age, age_threshold, trackers);
} }
TIMER_STOP
//std::cout << "There are " << trackers.size() << " trackers" << std::endl; //std::cout << "There are " << trackers.size() << " trackers" << std::endl;
for (auto t : trackers) for (auto t : trackers)
@@ -188,7 +198,10 @@ int main(int argc, char *argv[])
//std::cout << "lat: " << lat << " lon: " << lon << std::endl; //std::cout << "lat: " << lat << " lon: " << lon << std::endl;
int pix_x, pix_y; int pix_x, pix_y;
coord2pixel(lat, lon, pix_x, pix_y, adfGeoTransform); coord2pixel(lat, lon, pix_x, pix_y, adfGeoTransform);
//std::cout << "pix_x: " << pix_x << " pix_y: " << pix_y << std::endl; //std::cout << "pix_x: " << pix_x << " pix_y: " << pix_y << std::endl;
if(pix_x < frame_top.cols && pix_y < frame_top.rows && pix_x >= 0 && pix_y >= 0)
cv::circle(frame_top, cv::Point(pix_x,pix_y), 7.0, cv::Scalar(t.r_, t.g_, t.b_), CV_FILLED, 8, 0);
std::vector<cv::Point2f> map_p, camera_p; std::vector<cv::Point2f> map_p, camera_p;
map_p.push_back(cv::Point2f(pix_x, pix_y)); map_p.push_back(cv::Point2f(pix_x, pix_y));
@@ -206,11 +219,16 @@ int main(int argc, char *argv[])
send_client_dummy(coords, coord_i, sock, socket_opened, CAM_IDX); send_client_dummy(coords, coord_i, sock, socket_opened, CAM_IDX);
if (to_show) if (to_show)
{ {
cv::imshow("detection", frame); cv::imshow("detection", frame);
cv::imshow("topview", frame_top);
cv::waitKey(1); cv::waitKey(1);
} }
} }
/* for (size_t i = 0; i < trackers.size(); i++) /* for (size_t i = 0; i < trackers.size(); i++)