@@ -61,8 +61,8 @@ class OR_pascalImp : public OR_pascal
6161
6262private:
6363 void loadDataset (const string &path, const string &nameImageSet, vector< Ptr<Object> > &imageSet);
64- Ptr<Object> parseAnnotation (const string path, const string id);
65- const char * parseNodeText (XMLElement* node, const string nodeName, const string defaultValue);
64+ Ptr<Object> parseAnnotation (const string & path, const string & id);
65+ const char * parseNodeText (XMLElement* node, const string & nodeName, const string & defaultValue);
6666};
6767
6868
@@ -105,17 +105,20 @@ void OR_pascalImp::loadDataset(const string &path, const string &nameImageSet, v
105105 }
106106}
107107
108- const char * OR_pascalImp::parseNodeText (XMLElement* node, const string nodeName, const string defaultValue)
108+ const char * OR_pascalImp::parseNodeText (XMLElement* node, const string & nodeName, const string & defaultValue)
109109{
110- const char * e = node->FirstChildElement (nodeName.c_str ())->GetText ();
110+ XMLElement* child = node->FirstChildElement (nodeName.c_str ());
111+ if ( child == 0 )
112+ return defaultValue.c_str ();
111113
112- if ( e != 0 )
113- return e ;
114- else
114+ const char * e = child->GetText ();
115+ if ( e == 0 )
115116 return defaultValue.c_str ();
117+
118+ return e ;
116119}
117120
118- Ptr<Object> OR_pascalImp::parseAnnotation (const string path, const string id)
121+ Ptr<Object> OR_pascalImp::parseAnnotation (const string & path, const string & id)
119122{
120123 string pathAnnotations (path + " Annotations/" );
121124 string pathImages (path + " JPEGImages/" );
0 commit comments