Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
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
00067 CCD my_ccd;
00068
00069
00070
00071 Mat frame;
00072 for (int frame_count =0 ;; frame_count++) {
00073 capture >> frame;
00074 if (frame.empty())
00075 continue;
00076
00077 frame.copyTo(my_ccd.canvas);
00078 frame.copyTo(my_ccd.image);
00079
00080
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
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);
00108 if (!capture.isOpened())
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 }