Graphenvergleich - Fehler



  • Hallo zusammen,

    ich habe ein Programm für einen Modellgraphenvergleich. Der Vergleich erfolgt immer zwischen einem Gallery-Modellgraphen und einem Probe-Modellgraphen. Diese werden anhand von FileLists eingelesen und es wird darüber iteriert. Leider habe ich vermutlich Syntaxfehler und ich habe das Problem, dass ich über die Dateinamen iteriere, anstatt über die bereits gelesenen Modellgraphen.
    Vielleicht kann sich ja jemand mein Programm angucken und eventuell die Fehlerquellen sehen. Pragma ist eine Bibliothek für verschiedene Funktionen aus dem Bereich der Neuroinformatik.

    Anbei der relevante Auszug:

    int pragma::main(int argc, char *argv[])
    //----------------------------------------------------------------------------
    {
    	freopen("datei.txt", "w", stdout);
    	//----------------------------------------------------------------------------
    #ifndef PRAGMA_HAVE_LIB_EGM
    
    	pragma_Exception("...");
    
    	//----------------------------------------------------------------------------
    #else 
    
    	// get the path if given.
    	pragma::string databasePathL;
    	if (argc > 1)
    	{
    		databasePathL = argv[1];
    	} // if.
    	else
    	{
    		databasePathL = databasePathG;
    	}
    
    	//----------------------------------------------------------------------------
    
    	// File list paths
    	pragma::string galleryImageFileListL = databasePathL + "FileLists/age_g_0_tif.txt";
    	pragma::string galleryGraphFileListL = databasePathL + "FileLists/age_g_0_xml.txt";
    	//----------------------------------------------------------------------------
    
    	// Prepare the gallery.
    
    	// Read List of gallery graphs.
    	pragma::vector<pragma::string> galleryGraphFilesL;
    	readFileList(galleryGraphFileListL, galleryGraphFilesL);
    
    	// Prepare a properly sized vector of model graphs.
    	pragma::vector<pragma::GraphLab::ModelGraphPointer> galleryGraphsL;
    	galleryGraphsL.reserve(galleryGraphFileListL.size());
    
    	// Create vector of gallery graphs.
    	for
    		(pragma::vector<pragma::string>::const_iterator fileNameItL
    		= galleryGraphFilesL.begin();
    	fileNameItL < galleryGraphFilesL.end();
    	++fileNameItL
    		)
    	{
    		// Compose filename of individual graph xml file.
    		pragma::string modelFileNameL(databasePathL + *fileNameItL);
    
    		// Read the graph from file.
    		pragma::GraphLab::GraphPointer graphL;
    		graphL.read(modelFileNameL);
    
    		// Shove it into the vector and wrap in proper pointer for this graph type.
    		galleryGraphsL.push_back(graphL);
    	}
    
    	// File list paths
    	pragma::string probeGraphFileListL = databasePathL + "FileLists/age_p_xml.txt";
    
    	// Prepare the probe
    	// Read List of probe graphs.
    	pragma::vector<pragma::string> probeGraphFilesL;
    	readFileList(probeGraphFileListL, probeGraphFilesL);
    
    	// Prepare a properly sized vector of model graphs.
    	pragma::vector<pragma::GraphLab::ModelGraphPointer> probeGraphsL;
    	probeGraphsL.reserve(probeGraphFileListL.size());
    
    	// Create vector of probe graphs.
    	for
    		(pragma::vector<pragma::string>::const_iterator fileNameItL
    		= probeGraphFilesL.begin();
    	fileNameItL < probeGraphFilesL.end();
    	++fileNameItL
    		)
    	{
    		// Compose filename of individual graph xml file.
    		pragma::string modelFileNameL(databasePathL + *fileNameItL);
    
    		// Read the graph from file.
    		pragma::GraphLab::GraphPointer graphL;
    		graphL.read(modelFileNameL);
    
    		// Shove it into the vector and wrap in proper pointer for this graph type.
    		probeGraphsL.push_back(graphL);
    	}
    
    	pragma::UINT32 numberOfCorrectMatchesL = 0;
    	pragma::UINT32 numberOfTrialsL = 0;
    
    	// Iterater over all probe graphs.
    	for
    		(pragma::vector<pragma::string>::const_iterator probeGraphItL = probeGraphFilesL.begin();
    	probeGraphItL  < probeGraphFilesL.end();
    	++probeGraphItL
    		)
    	{
    		// Compose filename of individual graph xml file.
    		pragma::string modelFileNameL(databasePathL + *probeGraphItL);
    
    		std::cout << "Probing situation " << probeGraphItL - probeGraphFilesL.begin() << "...\n";
    		// Put filenames for current situation into a vector.
    		pragma::vector<pragma::string> probeGraphFilesL;
    		readFileList(*probeGraphItL, probeGraphFilesL);
    
    		// Iterate over all probe graphs of the current situation.
    		for
    			(pragma::vector<pragma::string>::const_iterator fileNameItL
    			= probeGraphFilesL.begin();
    		fileNameItL < probeGraphFilesL.end();
    		++fileNameItL
    			)
    		{
    			// Copy current gallery graph.
    			pragma::GraphLab::ModelGraphPointer probeGraphL;
    			probeGraphL->copyStructureFrom(*probeGraphItL, pragma::TRUE);
    			// Current graph filename.
    			pragma::string imageFileNameL(databasePathL + *fileNameItL);
    
    			// Read the color image.
    			pragma::Image::ColorImagePointer probeImageL;
    			probeImageL->read(imageFileNameL);
    
    			pragma::INT32 indexOfBestGalleryGraphL = -1;
    			pragma::REAL bestSimilarityL = pragma::Limits<pragma::REAL>::lowest();
    			std::cout << "Iterating over all gallery graphs.\n";
    			for
    				(pragma::vector<pragma::GraphLab::ModelGraphPointer>::const_iterator galleryGraphItL
    				= galleryGraphsL.begin();
    			galleryGraphItL < galleryGraphsL.end();
    			++galleryGraphItL
    				)
    			{
    				// Copy current gallery graph.
    				pragma::GraphLab::ModelGraphPointer galleryGraphL;
    				galleryGraphL->copyStructureFrom(*galleryGraphItL, pragma::TRUE);
    
    				// Compare the current probe graph to all gallery graphs.
    				pragma::REAL highestSimilarityL = pragma::MIN_REAL;
    				pragma::INT32 indexOfBestMatchL = -1;
    				for
    					(pragma::vector<pragma::GraphLab::ModelGraphPointer>::const_iterator galleryGraphItL
    					= galleryGraphsL.begin();
    				galleryGraphItL < galleryGraphsL.end();
    				++galleryGraphItL
    					)
    				{
    					pragma::REAL similarityL = probeGraphItL->similarity(galleryGraphItL);
    					if (similarityL > highestSimilarityL)
    					{
    						highestSimilarityL = similarityL;
    
    					indexOfBestGalleryGraphL = galleryGraphItL - galleryGraphsL.begin();
    					std::cout << "  new best similarity " << bestSimilarityL << " with gallery graph " << indexOfBestGalleryGraphL << ".\n";
    				}
    			}
    			std::cout << "Done iterating over all gallery graphs.\n";
    


  • aybalam1693 schrieb:

    Leider habe ich vermutlich Syntaxfehler

    Ein Compiler kann das zur Gewissheit werden lassen

    aybalam1693 schrieb:

    ich habe das Problem, dass ich über die Dateinamen iteriere, anstatt über die bereits gelesenen Modellgraphen.

    Dann iterier nicht über die Dateinamen. Wenn du das API deiner Bibliothek nicht verstehst, solltest du nicht in einem C++ Forum fragen, sondern in einem, dass sich mit dieser Bibliothek befasst.


Anmelden zum Antworten