run_esm.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <iomanip>
00003 
00004 #include <posest/esm.hpp>
00005 using namespace cv;
00006 
00007 int main(int argc, char *argv[])
00008 {
00009   if (argc != 3)
00010   {
00011     std::cout << "Format: run_esm [template_image] [test_folder]" << std::endl;
00012     exit(0);
00013   }
00014 
00015   string tplFilename = argv[1];
00016   string testFolder = argv[2];
00017   Mat templateImage = imread(tplFilename, 0);
00018   assert( !templateImage.empty() );
00019 
00020   HomoESM homoESM;
00021   homoESM.setTemplateImage(templateImage);
00022 
00023   const int nIters = 20;
00024   Mat H = Mat::eye(3, 3, CV_64FC1);
00025   H.at<double> (0, 2) = 220;
00026   H.at<double> (1, 2) = 200;
00027   const int lastFrameIdx = 200;
00028 
00029   for (int frameIdx = 0; frameIdx <= lastFrameIdx; frameIdx++)
00030   {
00031     std::stringstream filename;
00032     filename << testFolder << "/im" << std::setfill('0') << std::setw(3) << frameIdx << ".pgm";
00033     Mat frame = imread(filename.str(), 0);
00034     assert( !frame.empty() );
00035 
00036     homoESM.setTestImage(frame);
00037     double rmsError;
00038     homoESM.track(nIters, H, rmsError);
00039 
00040     Mat visualization;
00041     homoESM.visualizeTracking(H, visualization);
00042     imshow("Tracking", visualization);
00043     waitKey(10);
00044   }
00045   return 0;
00046 }


posest
Author(s): Kurt Konolige
autogenerated on Thu Jan 2 2014 12:12:17