|
@@ -357,6 +357,91 @@ void LocalizationResult::restore (istream & is, int format)
|
|
|
}
|
|
|
|
|
|
//sortEmpricalDepth();
|
|
|
+ } else if ( format == FILEFORMAT_POLYGON_SIFTFLOW ) {
|
|
|
+ // parser for xml annotations of SIFTFlow dataset
|
|
|
+ if ( is.good() )
|
|
|
+ {
|
|
|
+ std::string tmp;
|
|
|
+ is >> tmp; // annotation tag
|
|
|
+
|
|
|
+ bool b_endOfBlock = false;
|
|
|
+
|
|
|
+ while ( !b_endOfBlock )
|
|
|
+ {
|
|
|
+ is >> tmp; // get current line
|
|
|
+
|
|
|
+ // reached end of file properly
|
|
|
+ if ( this->isEndTag ( tmp, "annotation") )
|
|
|
+ {
|
|
|
+ b_endOfBlock = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ StringTools::normalize_string( tmp );
|
|
|
+ tmp = this->removeStartTag ( tmp );
|
|
|
+
|
|
|
+ // found new single localization result
|
|
|
+ if ( tmp.compare("object") == 0 )
|
|
|
+ {
|
|
|
+ std::string classname;
|
|
|
+ is >> classname;
|
|
|
+ classname = classname.substr( 6, classname.length()-13 ); //remove tags
|
|
|
+ int classno = cn->classnoFromText(classname);
|
|
|
+
|
|
|
+ bool foundPolygonBlock = false;
|
|
|
+
|
|
|
+ while ( !foundPolygonBlock )
|
|
|
+ {
|
|
|
+ is >> tmp;
|
|
|
+ StringTools::normalize_string( tmp );
|
|
|
+ tmp = this->removeStartTag ( tmp );
|
|
|
+
|
|
|
+ if ( tmp.compare("polygon") == 0 )
|
|
|
+ foundPolygonBlock = true;
|
|
|
+ }
|
|
|
+ is >> tmp; // 'username' line
|
|
|
+
|
|
|
+ NICE::Region newPolygon;
|
|
|
+ bool endOfPolyBlock = false;
|
|
|
+
|
|
|
+ while ( !endOfPolyBlock )
|
|
|
+ {
|
|
|
+ is >> tmp; // <pt> or </polygon> ?
|
|
|
+ if ( this->isEndTag ( tmp, "polygon" ) )
|
|
|
+ {
|
|
|
+ endOfPolyBlock = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ int x, y;
|
|
|
+
|
|
|
+ is >> tmp; // <x> ... </x>
|
|
|
+ StringTools::normalize_string( tmp );
|
|
|
+ tmp = tmp.substr( 3, tmp.length()-7 ); //remove tags
|
|
|
+ x = atoi ( tmp.c_str() );
|
|
|
+
|
|
|
+ is >> tmp; // <y> ... </y>
|
|
|
+ StringTools::normalize_string( tmp );
|
|
|
+ tmp = tmp.substr( 3, tmp.length()-7 ); //remove tags
|
|
|
+ y = atoi ( tmp.c_str() );
|
|
|
+
|
|
|
+ newPolygon.add( x, y );
|
|
|
+
|
|
|
+ is >> tmp; // </pt>
|
|
|
+ }
|
|
|
+ if ( classno >= 0 ) {
|
|
|
+ ClassificationResult *r = new ClassificationResult ( classno, 1.0, cn->getMaxClassno() );
|
|
|
+ SingleLocalizationResult *sr = new SingleLocalizationResult ( r, newPolygon );
|
|
|
+ push_back ( sr );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fthrow(IOException, "LocalizationResult::restore: InStream not initialized !");
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
fthrow(IOException, "LocalizationResult::restore: file format not yet supported !");
|