$search
00001 00005 #include "initialization.hpp" 00006 00007 bool initializationData::obtainStartingData(ros::NodeHandle& nh) { 00008 00009 numDetectors = 0; 00010 00011 nh.param<std::string>("video_stream", video_stream, "video_stream"); 00012 00013 if (video_stream != "video_stream") { 00014 printf("%s << Video stream (%s) selected.\n", __FUNCTION__, video_stream.c_str()); 00015 } else { 00016 printf("%s << ERROR! No video stream specified.\n", __FUNCTION__); 00017 return false; 00018 } 00019 00020 nh.param<bool>("debug_mode", debugMode, false); 00021 00022 if (debugMode) { 00023 printf("%s << Running in DEBUG mode.\n", __FUNCTION__); 00024 } else { 00025 printf("%s << Running in OPTIMIZED mode.\n", __FUNCTION__); 00026 } 00027 00028 nh.param<int>("max_frame_count", max_frame_count, DEFAULT_MAX_FRAMES); 00029 00030 if (max_frame_count > MAXIMUM_FRAMES_TO_STORE) { 00031 printf("%s << ERROR! Maximum frames specified (%d) is too high.\n", __FUNCTION__, max_frame_count); 00032 } else { 00033 printf("%s << Maximum frames specified: %d\n", __FUNCTION__, max_frame_count); 00034 } 00035 00036 for (int iii = 0; iii < MAX_DETECTORS; iii++) { 00037 00038 char detector_tag[256], sensitivity_tag[256], method_tag[256], descriptor_tag[256]; 00039 00040 sprintf(detector_tag, "detector_%d", iii + 1); 00041 sprintf(sensitivity_tag, "sensitivity_%d", iii + 1); 00042 sprintf(method_tag, "method_%d", iii + 1); 00043 sprintf(descriptor_tag, "descriptor_%d", iii + 1); 00044 00045 //printf("%s << detector_tag = %s\n", __FUNCTION__, detector_tag); 00046 00047 if (iii == 0) { 00048 nh.param<std::string>(detector_tag, detector[iii], "SURF"); 00049 } else { 00050 nh.param<std::string>(detector_tag, detector[iii], "NONE"); 00051 } 00052 00053 //printf("%s << detector[%d] = %s\n", __FUNCTION__, iii, detector[iii].c_str()); 00054 00055 if ((detector[iii] == "SURF") || (detector[iii] == "FAST") || (detector[iii] == "GFTT") || (detector[iii] == "HARRIS") || (detector[iii] == "ORB") || (detector[iii] == "STAR")) { 00056 printf("%s << detector [%d]: %s\n", __FUNCTION__, iii, detector[iii].c_str()); 00057 } else if (detector[iii] == "NONE"){ 00058 // printf("%s << No [%d] detector requested.\n", __FUNCTION__, iii); 00059 break; 00060 } else { 00061 printf("%s << ERROR! Detector (%s) not recognized.\n", __FUNCTION__, detector[iii].c_str()); 00062 return false; 00063 } 00064 00065 nh.param<double>(sensitivity_tag, sensitivity[iii], 30.0); 00066 00067 printf("%s << detector [%d] sensitivity: %f\n", __FUNCTION__, iii, sensitivity[iii]); 00068 00069 nh.param<std::string>(method_tag, method[iii], "match"); 00070 00071 if ((method[iii] == "match") || (method[iii] == "track")) { 00072 printf("%s << detector [%d] matching method: %s\n", __FUNCTION__, iii, method[iii].c_str()); 00073 if (method[iii] == "match") { 00074 method_match[iii] = true; 00075 } else { 00076 method_match[iii] = false; 00077 } 00078 } else { 00079 printf("%s << ERROR! detector [%d] matching method (%s) not recognized.\n", __FUNCTION__, iii, method[iii].c_str()); 00080 return false; 00081 } 00082 00083 nh.param<std::string>(descriptor_tag, descriptor[iii], "SURF"); 00084 00085 if (method_match[iii]) { 00086 if ((descriptor[iii] == "SURF") || (descriptor[iii] == "ORB") || (descriptor[iii] == "BRIEF") || (descriptor[iii] == "SIFT")) { 00087 printf("%s << descriptor [%d]: %s\n", __FUNCTION__, iii, descriptor[iii].c_str()); 00088 } else { 00089 printf("%s << ERROR! descriptor [%d] (%s) not recognized.\n", __FUNCTION__, iii, descriptor[iii].c_str()); 00090 return false; 00091 } 00092 } 00093 00094 numDetectors++; 00095 } 00096 00097 printf("%s << [%d] detectors to be implemented.\n", __FUNCTION__, numDetectors); 00098 00099 nh.param<std::string>("intrinsics", intrinsics, "intrinsics"); 00100 00101 if (intrinsics != "intrinsics") { 00102 printf("%s << Intrinsics at %s selected.\n", __FUNCTION__, intrinsics.c_str()); 00103 } else { 00104 printf("%s << ERROR! No valid intrinsics file (%s) specified.\n", __FUNCTION__, intrinsics.c_str()); 00105 } 00106 00107 return true; 00108 } 00109 00110 void initializationData::initializeDescriptors(Ptr<DescriptorExtractor> *desc) { 00111 00112 for (int iii = 0; iii < numDetectors; iii++) { 00113 if (descriptor[iii] == "SURF") { 00114 ROS_ERROR("SURF has been deactivated due to copyright protection!"); 00115 //desc[iii] = new SurfDescriptorExtractor( ); 00116 } else if (descriptor[iii] == "SIFT") { 00117 ROS_ERROR("SIFT has been deactivated due to copyright protection!"); 00118 //desc[iii] = new SiftDescriptorExtractor( ); 00119 } else if (descriptor[iii] == "BRIEF") { 00120 desc[iii] = new BriefDescriptorExtractor( ); 00121 } else if (descriptor[iii] == "ORB") { 00122 desc[iii] = new OrbDescriptorExtractor( ); 00123 } 00124 } 00125 00126 } 00127 00128 void initializationData::initializeDetectors(Ptr<FeatureDetector> *det) { 00129 00130 for (int iii = 0; iii < numDetectors; iii++) { 00131 if (detector[iii] == "SURF") { 00132 ROS_ERROR("SURF has been deactivated due to copyright protection!"); 00133 // det[iii] = new SurfFeatureDetector( sensitivity[iii] ); 00134 } else if (detector[iii] == "FAST") { 00135 det[iii] = new FastFeatureDetector( sensitivity[iii] ); 00136 } else if (detector[iii] == "GFTT") { 00137 det[iii] = new GoodFeaturesToTrackDetector( MAXIMUM_FEATURES_PER_DETECTOR, sensitivity[iii], 1.0, 3, false ); 00138 } else if (detector[iii] == "STAR") { 00139 det[iii] = new StarFeatureDetector( 16, sensitivity[iii] ); 00140 } else if (detector[iii] == "ORB") { 00141 det[iii] = new OrbFeatureDetector( MAXIMUM_FEATURES_PER_DETECTOR ); 00142 } else if (detector[iii] == "HARRIS") { 00143 det[iii] = new GoodFeaturesToTrackDetector( MAXIMUM_FEATURES_PER_DETECTOR, sensitivity[iii], 1.0, 3, true ); 00144 } 00145 } 00146 00147 }