GOTURN icon indicating copy to clipboard operation
GOTURN copied to clipboard

How to get tracker's quality?

Open delongqilinksprite opened this issue 7 years ago • 1 comments

use GUTURN to tracks a object,I need to know when the tracker is bad, i need to re-detect and re-track.

delongqilinksprite avatar Nov 30 '17 08:11 delongqilinksprite

I test use two GOTURN to track two different objects,but result is always same.what's wrong with my code! thanks in advances!

code:

#include #include

#include <opencv2/opencv.hpp> #include "network/regressor.h" #include "tracker/tracker.h" #include "helper/bounding_box.h" #include "loader/loader_base.h"

using std::string; using std::chrono::high_resolution_clock; using std::chrono::milliseconds;

int main(int argc, char *argv[]) {

    : :google::InitGoogleLogging(argv[0]);
int gpu_id = 0;
    const string model_file = argv[1];
    const string pretrain_file = argv[2];
    Regressor regressor1(model_file,pretrain_file,gpu_id, false);
Regressor regressor2(model_file,pretrain_file,gpu_id, false);
    Tracker tracker1(false);
Tracker tracker2(false);
cv::Mat image_curr;
BoundingBox bbox_gt1;
BoundingBox bbox_gt2;
cv::VideoCapture cap(0);
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1280);  
    cap.set(CV_CAP_PROP_FRAME_HEIGHT, 720); 
cap >> image_curr;
cv::Rect2d roi1 = selectROI("tracking", image_curr);
bbox_gt1.x1_ = roi1.x;
bbox_gt1.y1_ = roi1.y;
bbox_gt1.x2_ = roi1.x+roi1.width;
bbox_gt1.y2_ = roi1.y+roi1.height;
tracker1.Init(image_curr,bbox_gt1,&regressor1);
cv::Rect2d roi2 = selectROI("tracking", image_curr);
bbox_gt2.x1_ = roi2.x;
bbox_gt2.y1_ = roi2.y;
bbox_gt2.x2_ = roi2.x+roi2.width;
bbox_gt2.y2_ = roi2.y+roi2.height;
tracker2.Init(image_curr,bbox_gt2,&regressor2);
while(true)
{
	cv::Rect targetBox1;
	cv::Rect targetBox2;
	cap >> image_curr;
	BoundingBox bbox_estimate_uncentered1;
	high_resolution_clock::time_point beginTime = high_resolution_clock::now();
	tracker1.Track(image_curr, &regressor1, &bbox_estimate_uncentered1);
	high_resolution_clock::time_point endTime = high_resolution_clock::now();
	milliseconds timeInterval = std::chrono::duration_cast<milliseconds>(endTime - beginTime);
	std::cout << "takes " << timeInterval.count() << " ms\n";
	
	targetBox1.x = (int)bbox_estimate_uncentered1.x1_;
	targetBox1.y = (int)bbox_estimate_uncentered1.y1_;
	targetBox1.width = (int)bbox_estimate_uncentered1.x2_ - targetBox1.x;
	targetBox1.height = (int)bbox_estimate_uncentered1.y2_ - targetBox1.y;
	
	BoundingBox bbox_estimate_uncentered2;
	high_resolution_clock::time_point beginTime1 = high_resolution_clock::now();
	tracker1.Track(image_curr, &regressor2, &bbox_estimate_uncentered2);
	high_resolution_clock::time_point endTime1 = high_resolution_clock::now();
	milliseconds timeInterval1 = std::chrono::duration_cast<milliseconds>(endTime1 - beginTime1);
	std::cout << "takes " << timeInterval1.count() << " ms\n";
	
	targetBox2.x = (int)bbox_estimate_uncentered2.x1_;
	targetBox2.y = (int)bbox_estimate_uncentered2.y1_;
	targetBox2.width = (int)bbox_estimate_uncentered2.x2_ - targetBox2.x;
	targetBox2.height = (int)bbox_estimate_uncentered2.y2_ - targetBox2.y;
	
	cv::Mat display;
	image_curr.copyTo(display);
	cv::rectangle(display,targetBox1,CV_RGB(0,0,255), 2);
	cv::rectangle(display,targetBox2,CV_RGB(0,255,0), 2);
	cv::imshow("tracking",display);
	cv::waitKey(1);
}
cv::destroyAllWindows();
return 0;

}

delongqilinksprite avatar Nov 30 '17 09:11 delongqilinksprite