int main( int argc, char** argv ) { string reference; string input_dir; string ground_truth_dir; static int verbose_flag; int option_index = 0; int c; static struct option long_options[] = { {"verbose", no_argument, &verbose_flag, 1}, {"brief", no_argument, &verbose_flag, 0}, {"img", required_argument, 0, 'i'}, {0, 0, 0, 0} }; while ((c = getopt_long(argc, argv, "r:i:", long_options, &option_index)) != -1) { if (c == -1) break; switch (c) { case 'i': ground_truth_dir = optarg; break; case 'h': case '?': display_usage(); break; default: abort (); } } // Read files from input directory string output_dir ("dscore_map"); if ( !exists(path(output_dir)) ) create_directory(output_dir); map<unsigned int, string> gt_files; int gt_size = -1; // Verify input name is a video file or sequences of jpg files path path_to_ground_truth ( chomp(ground_truth_dir) ); //path path_to_ground_truth (ground_truth_dir.c_str()); if (is_directory(path_to_ground_truth)) { // fills list gt_files with <number,file_number> list_files(ground_truth_dir,gt_files); gt_size = gt_files.size(); output_dir += "/" + path_to_ground_truth.filename().string(); // Create local directory to save xml maps. if ( !exists(path(output_dir)) ) create_directory(output_dir); } else { cout << "Invalid ground-truth directory ... "<< endl; return 0; } map<unsigned int, string>::iterator gt_it; Performance *measure = new Performance(); Mat Image; Mat Map; for (gt_it = gt_files.begin(); gt_it != gt_files.end(); ++gt_it) { Image = Scalar::all(0); Map = Scalar::all(0); // open ground truth frame. Image = imread(gt_it->second, CV_LOAD_IMAGE_GRAYSCALE); // get general Map measure->computeGeneralDSCoreMap(Image, Map); string dirname = fileName(gt_it->second); cout << dirname << endl; stringstream mapfile; mapfile << output_dir << "/" << gt_it->first << ".xml"; FileStorage fs(mapfile.str(), FileStorage::WRITE); stringstream tagname; tagname << "DSCORE" << gt_it->first; fs << "DSCORE" << Map; fs.release(); // just for testing if (gt_it->first == (unsigned int)(gt_size/2)) { Mat mask; stringstream map_name; map_name << "Map_" << gt_it->first ; cout << "Looking for: "<< map_name.str() << endl; FileStorage fsread(mapfile.str(), FileStorage::READ); fsread["DSCORE"] >> mask; fsread.release(); map_name.str(""); map_name << gt_it->first << ".png" ; normalize(mask, mask, 0, 255, cv::NORM_MINMAX); imwrite(map_name.str().c_str(), mask); } }