Esempio n. 1
0
void Builder::showWnds(VisualHolder const& vs_holder){


	VideoLib::FrameBufferPtr const& framebuf = vs_holder.getStabilizer()->getFrameBuf();

	for(VisualFlags::const_iterator it = vs_holder.getFlags().begin(); it != vs_holder.getFlags().end(); it++){
		if(it->second != ShowFlags::NONE){
			cv::Mat img;

			if(it->second & ShowFlags::FRAME) showFrame(it->first,vs_holder.getStabilizer(),img);

			if(it->second & ShowFlags::PREV_FEATURES) showFeatures(framebuf->getDelayed(DEFAULT_DELAY)->features(),CV_RGB(255,0,0),img,1);//img.cols/320);
			if(it->second & ShowFlags::CURR_FEATURES) showFeatures(framebuf->getCurrent()->features(),CV_RGB(0,300,0),img,1);//img.cols/320);
			if(it->second & ShowFlags::OPTICAL_FLOW) showOpticalFlow(framebuf->getCurrent(),CV_RGB(0,300,0),img);
			//if(it->second & ShowFlags::PROJ_TRANSFORM) showTransform(it->first,vs_holder,img);
			//if(it->second & ShowFlags::BUFFER_MAP) showBufferMap(it->first,vs_holder,img);

			if(created_wnds.find(it->first) == created_wnds.end()){
				createWnd(it->first);
			}
			//cv::imshow(getWndName(it->first),framebuf->getCurrent()->matGray());
			cv::imshow(getWndName(it->first),img);
		}
	}
}
Esempio n. 2
0
/*
The openFabMapcli accepts a YML settings file, an example of which is provided.
Modify options in the settings file for desired operation
*/
int main(int argc, char * argv[])
{
	//load the settings file
	std::string settfilename;
	if (argc == 1) {
		//assume settings in working directory
		settfilename = "settings.yml";
	} else if (argc == 3) {
		if(std::string(argv[1]) != "-s") {
			//incorrect option
			return help();
		} else {
			//settings provided as argument
			settfilename = std::string(argv[2]);
		}
	} else {
		//incorrect arguments
		return help();
	}

	cv::FileStorage fs;
	fs.open(settfilename, cv::FileStorage::READ);
	if (!fs.isOpened()) {
		std::cerr << "Could not open settings file: " << settfilename << 
			std::endl;
		return -1;
	}

	cv::Ptr<cv::FeatureDetector> detector = generateDetector(fs);
	if(!detector) {
		std::cerr << "Feature Detector error" << std::endl;
		return -1;
	}

	cv::Ptr<cv::DescriptorExtractor> extractor = generateExtractor(fs);
	if(!extractor) {
		std::cerr << "Feature Extractor error" << std::endl;
		return -1;
	}

	//std::string extractorType = fs["FeatureOptions"]["ExtractorType"];
	//cv::Ptr<cv::DescriptorExtractor> extractor;
	//if(extractorType == "SIFT") {
	//	extractor = new cv::SiftDescriptorExtractor();
	//} else if(extractorType == "SURF") {
	//	extractor = new cv::SurfDescriptorExtractor(
	//		fs["FeatureOptions"]["SurfDetector"]["NumOctaves"],
	//		fs["FeatureOptions"]["SurfDetector"]["NumOctaveLayers"],
	//		(int)fs["FeatureOptions"]["SurfDetector"]["Extended"] > 0,
	//		(int)fs["FeatureOptions"]["SurfDetector"]["Upright"] > 0);
	//} else {
	//	std::cerr << "Could not create Descriptor Extractor. Please specify "
	//		"extractor type in settings file" << std::endl;
	//	return -1;
	//}

	//run desired function
	int result = 0;
	std::string function = fs["Function"];
	if (function == "ShowFeatures") {
		result = showFeatures(
			fs["FilePaths"]["TrainPath"],
			detector);

	} else if (function == "GenerateVocabTrainData") {
		result = generateVocabTrainData(fs["FilePaths"]["TrainPath"],
			fs["FilePaths"]["TrainFeatDesc"], 
			detector, extractor);

	} else if (function == "TrainVocabulary") {
		result = trainVocabulary(fs["FilePaths"]["Vocabulary"],
			fs["FilePaths"]["TrainFeatDesc"],
			fs["VocabTrainOptions"]["ClusterSize"]);

	} else if (function == "GenerateFABMAPTrainData") {
		result = generateBOWImageDescs(fs["FilePaths"]["TrainPath"],
			fs["FilePaths"]["TrainImagDesc"], 
			fs["FilePaths"]["Vocabulary"], detector, extractor,
			fs["BOWOptions"]["MinWords"]);

	} else if (function == "TrainChowLiuTree") {
		result = trainChowLiuTree(fs["FilePaths"]["ChowLiuTree"],
			fs["FilePaths"]["TrainImagDesc"],
			fs["ChowLiuOptions"]["LowerInfoBound"]);

	} else if (function == "GenerateFABMAPTestData") {
		result = generateBOWImageDescs(fs["FilePaths"]["TestPath"],
			fs["FilePaths"]["TestImageDesc"],
			fs["FilePaths"]["Vocabulary"], detector, extractor,
			fs["BOWOptions"]["MinWords"]);

	} else if (function == "RunOpenFABMAP") {
		std::string placeAddOption = fs["FabMapPlaceAddition"];
		bool addNewOnly = (placeAddOption == "NewMaximumOnly");
		of2::FabMap *fabmap = generateFABMAPInstance(fs);
		if(fabmap) {
			result = openFABMAP(fs["FilePaths"]["TestImageDesc"], fabmap,
				fs["FilePaths"]["Vocabulary"],
				fs["FilePaths"]["FabMapResults"], addNewOnly);
		}
			
	} else {
		std::cerr << "Incorrect Function Type" << std::endl;
		result = -1;
	}

	std::cout << "openFABMAP done" << std::endl;
	std::cin.sync(); std::cin.ignore();

	fs.release();
	return result;

}