|
@@ -31,6 +31,27 @@ LabeledFileList::~LabeledFileList()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+int LabeledFileList::getClassFromNumber (
|
|
|
+ const std::string & lfile,
|
|
|
+ const int exampleID ) const
|
|
|
+{
|
|
|
+ int cvalue = -1;
|
|
|
+
|
|
|
+ std::ifstream file( lfile.c_str() );
|
|
|
+ std::string str;
|
|
|
+ while ( std::getline(file, str) )
|
|
|
+ {
|
|
|
+ NICE::Vector valList(2,0);
|
|
|
+ NICE::StringTools::splitVector( str, ',', valList );
|
|
|
+ if ( (int)valList[0] == exampleID )
|
|
|
+ {
|
|
|
+ cvalue = (int)valList[1];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return cvalue;
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* @brief Loads the label information according to a given label file format.
|
|
@@ -107,6 +128,19 @@ LocalizationResult *LabeledFileList::getLocalizationInfo ( const ClassNames & cl
|
|
|
lr = new LocalizationResult ( &classnames, mask );
|
|
|
|
|
|
}
|
|
|
+ else if ( format == "csv" ) {
|
|
|
+ // CAUTION! This is for experimental use only and needs a certain configuration of
|
|
|
+ // the csv file and scheme for the image file names!
|
|
|
+ NICE::ColorImage mask;
|
|
|
+ mask.read( file );
|
|
|
+ int exampleID = -1;
|
|
|
+ std::size_t found = file.find( "ID" );
|
|
|
+ std::string exampleIDStr = file.substr(found+2,found+8);
|
|
|
+ exampleID = std::atoi(exampleIDStr.c_str());
|
|
|
+ int g = getClassFromNumber( lfile, exampleID );
|
|
|
+ mask.set((uchar)g,(uchar)g,(uchar)g);
|
|
|
+ lr = new LocalizationResult ( &classnames, mask );
|
|
|
+ }
|
|
|
else if ( format == "polygon" ) {
|
|
|
lr = new LocalizationResult ( &classnames );
|
|
|
|
|
@@ -131,7 +165,7 @@ LocalizationResult *LabeledFileList::getLocalizationInfo ( const ClassNames & cl
|
|
|
else {
|
|
|
fthrow(Exception, "Localization format not yet supported !!\n");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if ( debug_dataset )
|
|
|
if ( lr != NULL )
|
|
|
fprintf (stderr, "%s (%d objects)\n", lfile.c_str(), (int)lr->size() );
|