Navigation Menu

Skip to content

Commit

Permalink
visual
Browse files Browse the repository at this point in the history
  • Loading branch information
foolwood committed Sep 29, 2017
1 parent f1a6ddc commit f3387fb
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 125 deletions.
10 changes: 6 additions & 4 deletions readme.md
Expand Up @@ -5,22 +5,24 @@ For more info, visit the autor's [webpage](https://lrs.icg.tugraz.at/members/pos

![dat](dat.png)

##Usage
## Usage

Simple test can be compiled like:
```
cmake
make
.\DAT test
.\DAT
```
![result](result.gif)

For test the **[vot2015](http://votchallenge.net/vot2015/dataset.html)** challenge, please download the [dataset](http://box.vicos.si/vot/vot2015.zip) at first and then unzip to ${DAT}.
```
cmake
make
.\DAT vot2015
```

##Speed
## Speed

Test in Windows with Intel i7-4790

Expand All @@ -30,7 +32,7 @@ Test in ubuntu 16.04 with Intel i7-6700

![speed](TEST_ON_UBUNTU1604.png)

##Reference
## Reference

```
@INPROCEEDINGS{possegger15a,
Expand Down
Binary file added result.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
242 changes: 121 additions & 121 deletions src/demo.cpp
Expand Up @@ -15,140 +15,140 @@ std::vector<cv::Rect> poly2rect(std::vector<std::vector<cv::Point2f> > polygon_v
std::vector<cv::Rect> getgroundtruth(std::string txt_file);


int main(){
std::string video_base_path = ".";
std::vector<std::string> videos = { "bag", "ball1", "ball2", "basketball", "birds1", "birds2",
"blanket", "bmx", "bolt1", "bolt2", "book", "butterfly", "car1", "car2", "crossing", "dinosaur",
"fernando", "fish1", "fish2", "fish3", "fish4", "girl", "glove", "godfather", "graduate",
"gymnastics1", "gymnastics2", "gymnastics3", "gymnastics4", "hand", "handball1", "handball2",
"helicopter","iceskater1","iceskater2","leaves","marching","matrix","motocross1",
"motocross2","nature","octopus","pedestrian1","pedestrian2","rabbit","racing","road",
"shaking","sheep","singer1","singer2","singer3","soccer1","soccer2","soldier",
"sphere","tiger","traffic","tunnel","wiper" };

//std::vector<std::string> videos = {"birds2"};
std::vector<double> time_v;
std::vector<double> frame_v;
for (int v = 0; v < videos.size(); ++v) {
std::string video = videos[v];
std::string pattern_jpg = video_base_path + "\\" + video + "\\*.jpg";
std::string txt_base_path = video_base_path + "\\" + video + "\\groundtruth.txt";

std::vector<cv::String> image_files;
cv::glob(pattern_jpg, image_files);
std::sort(image_files.begin(), image_files.end());
if (image_files.size() == 0)
return -1;

std::vector<cv::Rect> groundtruth_rect;
groundtruth_rect = getgroundtruth(txt_base_path);

DAT_TRACKER dat;

cv::Rect location = groundtruth_rect[0];
cv::Mat image;
std::vector<cv::Rect> result_rects;
int64 tic, toc;
double time = 0;
bool show_visualization = true;

for (unsigned int frame = 0; frame < image_files.size(); ++frame) {
image = cv::imread(image_files[frame]);
tic = cv::getTickCount();
if (frame == 0){
dat.tracker_dat_initialize(image, location);
}
else {
location = dat.tracker_dat_update(image);
}

toc = cv::getTickCount() - tic;
time += toc;
result_rects.push_back(location);

if (show_visualization) {
cv::putText(image, std::to_string(frame + 1), cv::Point(20, 40), 6, 1,
cv::Scalar(0, 255, 255), 2);
cv::rectangle(image, groundtruth_rect[frame], cv::Scalar(0, 255, 0), 2);
cv::rectangle(image, location, cv::Scalar(0, 0, 255), 2);
cv::imshow(video, image);

char key = cv::waitKey(1);
if (key == 27 || key == 'q' || key == 'Q')
break;
}
}
time = time / double(cv::getTickFrequency());
double fps = double(result_rects.size()) / time;
time_v.push_back(time);
frame_v.push_back(result_rects.size());
printf("\t%2d / %2d video: %12s\tFPS: %3.2f\n", v + 1, videos.size(), video, fps);
cv::destroyAllWindows();
}
printf("\t\t\tAverage FPS: %3.2f\n", std::accumulate(frame_v.begin(), frame_v.end(), 0.0) / std::accumulate(time_v.begin(), time_v.end(), 0.0));
return 0;
}


//int main(){
//
// std::string video_base_path = ".";
// std::string pattern_jpg = video_base_path + "\\sequence\\*.jpg";
// std::string txt_base_path = video_base_path + "\\sequence\\groundtruth.txt";
// std::vector<std::string> videos = { "bag", "ball1", "ball2", "basketball", "birds1", "birds2",
// "blanket", "bmx", "bolt1", "bolt2", "book", "butterfly", "car1", "car2", "crossing", "dinosaur",
// "fernando", "fish1", "fish2", "fish3", "fish4", "girl", "glove", "godfather", "graduate",
// "gymnastics1", "gymnastics2", "gymnastics3", "gymnastics4", "hand", "handball1", "handball2",
// "helicopter","iceskater1","iceskater2","leaves","marching","matrix","motocross1",
// "motocross2","nature","octopus","pedestrian1","pedestrian2","rabbit","racing","road",
// "shaking","sheep","singer1","singer2","singer3","soccer1","soccer2","soldier",
// "sphere","tiger","traffic","tunnel","wiper" };
//
// std::vector<cv::String> image_files;
// cv::glob(pattern_jpg, image_files);
// if (image_files.size() == 0)
// return -1;
//
// std::vector<cv::Rect> groundtruth_rect;
// groundtruth_rect = getgroundtruth(txt_base_path);
// //for (size_t i = 0; i < groundtruth_rect.size(); ++i)
// // std::cout << i+1 << '\t' <<groundtruth_rect[i] << std::endl;
// //std::vector<std::string> videos = {"birds2"};
// std::vector<double> time_v;
// std::vector<double> frame_v;
// for (int v = 0; v < videos.size(); ++v) {
// std::string video = videos[v];
// std::string pattern_jpg = video_base_path + "\\" + video + "\\*.jpg";
// std::string txt_base_path = video_base_path + "\\" + video + "\\groundtruth.txt";
//
// DAT_TRACKER dat;
// std::vector<cv::String> image_files;
// cv::glob(pattern_jpg, image_files);
// std::sort(image_files.begin(), image_files.end());
// if (image_files.size() == 0)
// return -1;
//
// cv::Rect location = groundtruth_rect[0];
// cv::Mat image;
// std::vector<cv::Rect> result_rects;
// int64 tic, toc;
// double time = 0;
// bool show_visualization = true;
// std::vector<cv::Rect> groundtruth_rect;
// groundtruth_rect = getgroundtruth(txt_base_path);
//
// for (unsigned int frame = 0; frame < image_files.size(); ++frame) {
// image = cv::imread(image_files[frame]);
// tic = cv::getTickCount();
// if (frame == 0){
// dat.tracker_dat_initialize(image, location);
// }
// else {
// location = dat.tracker_dat_update(image);
// }
//
// toc = cv::getTickCount() - tic;
// time += toc;
// result_rects.push_back(location);
// DAT_TRACKER dat;
//
// cv::Rect location = groundtruth_rect[0];
// cv::Mat image;
// std::vector<cv::Rect> result_rects;
// int64 tic, toc;
// double time = 0;
// bool show_visualization = true;
//
// for (unsigned int frame = 0; frame < image_files.size(); ++frame) {
// image = cv::imread(image_files[frame]);
// tic = cv::getTickCount();
// if (frame == 0){
// dat.tracker_dat_initialize(image, location);
// }
// else {
// location = dat.tracker_dat_update(image);
// }
//
// toc = cv::getTickCount() - tic;
// time += toc;
// result_rects.push_back(location);
//
// if (show_visualization) {
// cv::putText(image, std::to_string(frame + 1), cv::Point(20, 40), 6, 1,
// cv::Scalar(0, 255, 255), 2);
// cv::rectangle(image, groundtruth_rect[frame], cv::Scalar(0, 255, 0), 2);
// cv::rectangle(image, location, cv::Scalar(0, 128, 255), 2);
// cv::imshow("DAT", image);
// if (show_visualization) {
// cv::putText(image, std::to_string(frame + 1), cv::Point(20, 40), 6, 1,
// cv::Scalar(0, 255, 255), 2);
// cv::rectangle(image, groundtruth_rect[frame], cv::Scalar(0, 255, 0), 2);
// cv::rectangle(image, location, cv::Scalar(0, 0, 255), 2);
// cv::imshow(video, image);
//
// char key = cv::waitKey(1);
// if (key == 27 || key == 'q' || key == 'Q')
// break;
// char key = cv::waitKey(1);
// if (key == 27 || key == 'q' || key == 'Q')
// break;
// }
// }
// time = time / double(cv::getTickFrequency());
// double fps = double(result_rects.size()) / time;
// time_v.push_back(time);
// frame_v.push_back(result_rects.size());
// printf("\t%2d / %2d video: %12s\tFPS: %3.2f\n", v + 1, videos.size(), video, fps);
// cv::destroyAllWindows();
// }
// time = time / double(cv::getTickFrequency());
// double fps = double(result_rects.size()) / time;
// std::cout << "fps:" << fps << std::endl;
// cv::destroyAllWindows();
//
// printf("\t\t\tAverage FPS: %3.2f\n", std::accumulate(frame_v.begin(), frame_v.end(), 0.0) / std::accumulate(time_v.begin(), time_v.end(), 0.0));
// return 0;
//}


int main(){

std::string video_base_path = ".";
std::string pattern_jpg = video_base_path + "/sequence/*.jpg";
std::string txt_base_path = video_base_path + "/sequence/groundtruth.txt";

std::vector<cv::String> image_files;
cv::glob(pattern_jpg, image_files);
if (image_files.size() == 0)
return -1;

std::vector<cv::Rect> groundtruth_rect;
groundtruth_rect = getgroundtruth(txt_base_path);
//for (size_t i = 0; i < groundtruth_rect.size(); ++i)
// std::cout << i+1 << '\t' <<groundtruth_rect[i] << std::endl;

DAT_TRACKER dat;

cv::Rect location = groundtruth_rect[0];
cv::Mat image;
std::vector<cv::Rect> result_rects;
int64 tic, toc;
double time = 0;
bool show_visualization = true;

for (unsigned int frame = 0; frame < image_files.size(); ++frame) {
image = cv::imread(image_files[frame]);
tic = cv::getTickCount();
if (frame == 0){
dat.tracker_dat_initialize(image, location);
}
else {
location = dat.tracker_dat_update(image);
}

toc = cv::getTickCount() - tic;
time += toc;
result_rects.push_back(location);

if (show_visualization) {
cv::putText(image, std::to_string(frame + 1), cv::Point(20, 40), 6, 1,
cv::Scalar(0, 255, 255), 2);
cv::rectangle(image, groundtruth_rect[frame], cv::Scalar(0, 255, 0), 2);
cv::rectangle(image, location, cv::Scalar(0, 128, 255), 2);
cv::imshow("DAT", image);

char key = cv::waitKey(1);
if (key == 27 || key == 'q' || key == 'Q')
break;
}
}
time = time / double(cv::getTickFrequency());
double fps = double(result_rects.size()) / time;
std::cout << "fps:" << fps << std::endl;
cv::destroyAllWindows();

return 0;
}

cv::Rect poly2rect(std::vector<cv::Point2f> polygon){
// POLY2RECT Convert polygon to rectangle
// Compute axis aligned bounding boxes with correct area and center
Expand Down

0 comments on commit f3387fb

Please sign in to comment.