Skip to content

Commit f162a93

Browse files
committed
Merge pull request #536 from berak:datasets_or_pascal
2 parents 9d12e14 + e4acf5a commit f162a93

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

modules/datasets/src/or_pascal.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class OR_pascalImp : public OR_pascal
6161

6262
private:
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

Comments
 (0)