}
x = img_gray->width / 2;
y = img_gray->height / 2;
tracker_psa.
Track(img_gray);
}
tracker_psa.
Track(img_gray);
cvCircle(
image, cvPoint(
int(x),
int(y)), 10, CV_RGB(255,0,0));
}
x = img_gray->width / 2;
y = img_gray->height / 2;
r = 0;
tracker_psa_rot.
Track(img_gray);
}
tracker_psa_rot.
Track(img_gray);
r += tracker_psa_rot.
rotd;
cvCircle(
image, cvPoint(
int(x),
int(y)), 15, CV_RGB(255,0,0));
double r_rad = r*3.1415926535/180;
cvLine(
image, cvPoint(
int(x),
int(y)), cvPoint(
int(x-sin(r_rad)*15),
int(y+cos(r_rad)*15)), CV_RGB(255,0,0));
}
x = img_gray->width / 2;
y = img_gray->height / 2;
tracker_stat.
Track(img_gray);
}
tracker_stat.
Track(img_gray);
cvCircle(
image, cvPoint(
int(x),
int(y)), 10, CV_RGB(0,255,0));
}
x = img_gray->width / 2;
y = img_gray->height / 2;
r = 0;
tracker_stat_rot.
Track(img_gray);
}
tracker_stat_rot.
Track(img_gray);
r += tracker_stat_rot.
rotd;
cvCircle(
image, cvPoint(
int(x),
int(y)), 15, CV_RGB(0,255,0));
double r_rad = r*3.1415926535/180;
cvLine(
image, cvPoint(
int(x),
int(y)), cvPoint(
int(x-sin(r_rad)*15),
int(y+cos(r_rad)*15)), CV_RGB(0,255,0));
}
tracker_features.
Reset();
}
tracker_features.
Purge();
tracker_features.
Track(img_gray);
cvPoint(
int(tracker_features.
features[i].x),
int(tracker_features.
features[i].y)), 2,
CV_RGB(tracker_features.
ids[i]%255,(tracker_features.
ids[i]*7)%255,(tracker_features.
ids[i]*11)%255));
}
}
};
"No tracker - Press any key to change",
"TrackerPsa",
"TrackerPsaRot",
"TrackerStat",
"TrackerStatRot",
"TrackerFeatures",
};
{
assert(image);
static IplImage *img_gray=NULL;
if (init) {
init = false;
cout<<" [Ok]"<<endl;
}
else {
cam.
SetRes(image->width, image->height);
cout<<" [Fail]"<<endl;
}
}
if (image->nChannels == 1) cvCopy(image, img_gray);
else cvCvtColor(image, img_gray, CV_RGB2GRAY);
}
if ((key == 'r') || (key == 't')) {
return 0;
}
else if ((key == 'n') || (key == ' ')){
return 0;
}
return key;
}
int main(
int argc,
char *argv[])
{
try {
filename = filename.substr(filename.find_last_of('\\') + 1);
std::cout << "SampleTrack" << std::endl;
std::cout << "===========" << std::endl;
std::cout << std::endl;
std::cout << "Description:" << std::endl;
std::cout << " This is an example of how to use the 'TrackerPsa', 'TrackerPsaRot'," << std::endl;
std::cout << " 'TrackerFeatures', 'TrackerStat' and 'TrackerStatRot' classes to" << std::endl;
std::cout << " track the optical flow of the video." << std::endl;
std::cout << std::endl;
std::cout << "Usage:" << std::endl;
std::cout << " " << filename << " [device]" << std::endl;
std::cout << std::endl;
std::cout << " device integer selecting device from enumeration list (default 0)" << std::endl;
std::cout << " highgui capture devices are prefered" << std::endl;
std::cout << std::endl;
std::cout << "Keyboard Shortcuts:" << std::endl;
std::cout << " r,t: reset tracker" << std::endl;
std::cout << " n,space: cycle through tracking algorithms" << std::endl;
std::cout << " q: quit" << std::endl;
std::cout << std::endl;
cvInitFont(&
font, CV_FONT_HERSHEY_PLAIN, 1.0, 1.0);
if (plugins.size() < 1) {
std::cout << "Could not find any capture plugins." << std::endl;
return 0;
}
std::cout << "Available Plugins: ";
std::cout << std::endl;
if (devices.size() < 1) {
std::cout << "Could not find any capture devices." << std::endl;
return 0;
}
if (argc > 1) {
selectedDevice = atoi(argv[1]);
}
if (selectedDevice >= (int)devices.size()) {
}
std::cout << "Enumerated Capture Devices:" << std::endl;
std::cout << std::endl;
std::string uniqueName = devices[selectedDevice].uniqueName();
if (cap) {
std::stringstream settingsFilename;
settingsFilename << "camera_settings_" << uniqueName << ".xml";
std::cout << "Loading settings: " << settingsFilename.str() << std::endl;
}
std::stringstream title;
std::cout << "Saving settings: " << settingsFilename.str() << std::endl;
}
delete cap;
}
}
else {
std::cout << "Could not initialize the selected capture backend." << std::endl;
}
return 0;
}
catch (const std::exception &e) {
std::cout << "Exception: " << e.what() << endl;
}
catch (...) {
std::cout << "Exception: unknown" << std::endl;
}
}