ccd_tracker.cpp
Go to the documentation of this file.
00001 // Software License Agreement (BSD License)
00002 // 
00003 //   Copyright (c) 2011, Shulei Zhu <schuleichu@gmail.com>
00004 //   All rights reserved.
00005 // 
00006 //   Redistribution and use in source and binary forms, with or without
00007 //   modification, are permitted provided that the following conditions
00008 //   are met:
00009 // 
00010 //    * Redistributions of source code must retain the above copyright
00011 //      notice, this list of conditions and the following disclaimer.
00012 //    * Redistributions in binary form must reproduce the above
00013 //      copyright notice, this list of conditions and the following
00014 //      disclaimer in the documentation and/or other materials provided
00015 //      with the distribution.
00016 //    * Neither the name of Shulei Zhu nor the names of its
00017 //      contributors may be used to endorse or promote products derived
00018 //      from this software without specific prior written permission.
00019 // 
00020 //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021 //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022 //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023 //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024 //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025 //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026 //   BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 //   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028 //   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029 //   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030 //   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031 //   POSSIBILITY OF SUCH DAMAGE.
00032 // 
00033 // 
00034 // ccd_tracker.cpp --- 
00035 // File            : ccd_tracker.cpp
00036 // Created: Sa Jun 18 14:04:47 2011 (+0200)
00037 // Author: Shulei Zhu
00038 
00039 // Code:
00040 
00041 #include "opencv/cv.h"
00042 #include "opencv/highgui.h"
00043 #include <iostream>
00044 #include <vector>
00045 #include <string>
00046 #include <fstream>
00047 #include "ccd/sift_init.h"
00048 #include "ccd/bspline.h"
00049 #include "ccd/ccd.h"
00050 using namespace std;
00051 using namespace cv;
00052 namespace {
00053 void help(char** av) {
00054   cout << "\nThis program justs gets you started reading images from video\n"
00055       "Usage:\n./" << av[0] << " <video device number>\n"
00056        << "\tThis is a starter sample, to get you up and going in a copy pasta fashion\n"
00057        << "\tThe program captures frames from a camera connected to your computer.\n"
00058        << "\tTo find the video device number, try ls /dev/video* \n"
00059        << "\tYou may also pass a video file, like my_vide.avi instead of a device number"
00060        << endl;
00061 }
00062 
00063 int process(VideoCapture& capture) {
00064   string window_name = "video | q or esc to quit";
00065   cout << "press q or esc to quit" << endl;
00066   //  capture.set(CV_CAP_PROP_FPS, 10);
00067   CCD my_ccd;  
00068 
00069 
00070   // namedWindow(window_name, CV_WINDOW_KEEPRATIO); //resizable window;
00071   Mat frame;
00072   for (int frame_count =0 ;; frame_count++) {
00073     capture >> frame;
00074     if (frame.empty())
00075       continue;
00076     // imshow(window_name, frame);
00077     frame.copyTo(my_ccd.canvas);
00078     frame.copyTo(my_ccd.image);
00079     // if(template_path != "")
00080     //   my_ccd.tpl = cv::imread(template_path, 1 );
00081     if(frame_count == 0)
00082     {
00083       my_ccd.init_pts(1);
00084       my_ccd.read_params("ccd_params.xml");
00085       my_ccd.init_mat();
00086     }
00087 
00088   // std::cout << "hellooooooo" << std::endl;
00089     my_ccd.run_ccd();
00090     std::cout << "frame_count: " << frame_count << std::endl;
00091     
00092     cv::imshow("CCD", my_ccd.canvas);
00093     cv::waitKey(100);
00094   }
00095   return 0;
00096 }
00097 
00098 }
00099 
00100 int main (int argc, char * argv[]) 
00101 {
00102   if (argc != 2) {
00103     help(argv);
00104     return 1;
00105   }
00106   std::string arg = argv[1];
00107   VideoCapture capture(arg); //try to open string, this will attempt to open it as a video file
00108   if (!capture.isOpened()) //if this fails, try to open as a video camera, through the use of an integer param
00109     capture.open(atoi(arg.c_str()));
00110   if (!capture.isOpened()) {
00111     cerr << "Failed to open a video device or video file!\n" << endl;
00112     help(argv);
00113     return 1;
00114   }
00115   std::cout << "fps: " << capture.get(CV_CAP_PROP_FPS)<< std::endl;
00116   return process(capture);
00117 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


contracting_curve_density_algorithm
Author(s): Shulei Zhu, Dejan Pangercic
autogenerated on Thu May 23 2013 14:41:45