contrib/brl/vvid/bin/command_line_grid_finder.cxx
Go to the documentation of this file.
00001 #include <vcl_iostream.h>
00002 #include <vcl_string.h>
00003 #include <vcl_sstream.h>
00004 #include <sdet/sdet_detector_params.h>
00005 #include <sdet/sdet_fit_lines_params.h>
00006 #include <sdet/sdet_grid_finder_params.h>
00007 #include <vpro/vpro_video_process_sptr.h>
00008 #include <vpro/vpro_grid_finder_process.h>
00009 #include <vvid/vvid_command_line_player.h>
00010 #include <vul/vul_arg.h>
00011 
00012 int main(int argc, char** argv)
00013 {
00014   // create arg list
00015   vul_arg_info_list arg_list;
00016 
00017   // create player
00018   vvid_command_line_player player;
00019 
00020   vul_arg<vcl_string> output_file(arg_list,"-F","output file","grid_points.txt");
00021 
00022   // sdet_detector_params
00023   vul_arg<float> smooth_sigma(arg_list,"-ss","smooth sigma",(float)1.0);
00024   vul_arg<float> noise_threshold(arg_list,"-nt","noise threshold",(float)3.5);
00025   vul_arg<bool> automatic_threshold(arg_list,"-auto_threshold","automatic threshold",false);
00026   vul_arg<bool> aggressive_closure(arg_list,"-aggressive_closure","aggressive closure",true);
00027   vul_arg<bool> compute_junctions(arg_list,"-compute_junctions","compute junctions",true);
00028   //sdet_fit_lines params
00029   vul_arg<int> min_fit_length(arg_list,"-mfl","min line fit length",10);
00030   vul_arg<float> rms_distance(arg_list,"-rmsd","max rms distance",(float)0.1);
00031   //sdet_grid_finder params
00032   vul_arg<float> angle_tolerance(arg_list,"-at","angle tolerance",(float)5.0);
00033   vul_arg<int> line_cnt_threshold(arg_list,"-lct","line count threshold",1);
00034 
00035   // system_info args
00036   player.add_system_info_args(arg_list);
00037   player.add_output_file(output_file);
00038 
00039   vul_arg_include(arg_list);
00040   vul_arg_parse(argc, argv);
00041 
00042 
00043   // if print_xml_params returns 0, exit with no error
00044   vcl_string param_block_name("grid_finder_params");
00045   player.print_xml_params(arg_list,param_block_name);
00046   if (player.print_params_only())
00047     return 0;
00048 
00049 #if 0
00050   if (parameter_output_file() != "")
00051   {
00052     vcl_string param_block_name("grid_finder_params");
00053     player.print_xml_params(parameter_output_file(), arg_list, param_block_name);
00054     return 0;
00055   }
00056 #endif
00057 
00058   sdet_detector_params dp;
00059   sdet_fit_lines_params flp;
00060   sdet_grid_finder_params gfp;
00061 
00062   dp.smooth = smooth_sigma();
00063   dp.noise_multiplier = noise_threshold();
00064   dp.automatic_threshold = automatic_threshold();
00065   if (aggressive_closure())
00066     dp.aggressive_junction_closure=1;
00067   else
00068     dp.aggressive_junction_closure=0;
00069   dp.junctionp = compute_junctions();
00070   flp.min_fit_length_ = min_fit_length();
00071   flp.rms_distance_ = rms_distance();
00072   gfp.angle_tol_ = angle_tolerance();
00073   gfp.thresh_ = line_cnt_threshold();
00074 
00075   // create video process
00076   vpro_grid_finder_process* gfpro = new vpro_grid_finder_process(dp,flp,gfp);
00077   vpro_video_process_sptr gf_process = gfpro;
00078   // set output file
00079   vcl_stringstream output_file_stream;
00080   //output_file_stream << output_directory() << '/';
00081   output_file_stream << output_file();
00082   gfpro->set_output_file(output_file_stream.str());
00083   // set video process
00084   player.set_video_process(gf_process);
00085   // set input file
00086   player.load_video_file();//input_video_file());
00087   // set status block output file
00088   //player.set_status_output_file(status_block_file());
00089 
00090   vcl_cout << "playing video..\n";
00091   if (!player.play_video())
00092   {
00093     // error
00094     return 1;
00095   }
00096   vcl_cout << "...done.\n";
00097   player.print_performance_output("calibration video",gfpro->frame_scores_);
00098   vcl_cout << "wrote performance file\n";
00099 
00100   return 0;
00101 }
00102