فهرست منبع

fixed loading of image label info created by the ImageLabeler (note: xml image info load and save code of ImageLabeler and NICE are not entirely the same. this redundancy should be fixed)

Johannes Ruehle 14 سال پیش
والد
کامیت
3c9a469747
3فایلهای تغییر یافته به همراه15 افزوده شده و 13 حذف شده
  1. 2 1
      cbaselib/BoundingBox.cpp
  2. 12 11
      cbaselib/ImageInfo.cpp
  3. 1 1
      cbaselib/ImageInfo.h

+ 2 - 1
cbaselib/BoundingBox.cpp

@@ -132,6 +132,7 @@ BoundingBox::setID(const int &anID)
 		return;
 		return;
 		/* NOTREACHED */
 		/* NOTREACHED */
 	}
 	}
+	id_ = anID;
 }
 }
 
 
 //! returns top left coordinate of the bounding box
 //! returns top left coordinate of the bounding box
@@ -191,7 +192,7 @@ BoundingBox::isValid() const
 		bottom_right_.x < 0 ||
 		bottom_right_.x < 0 ||
 		bottom_right_.y < 0 ||
 		bottom_right_.y < 0 ||
 		bottom_right_.y <= top_left_.y ||
 		bottom_right_.y <= top_left_.y ||
-		top_left_.x <= bottom_right_.x)
+		top_left_.x >= bottom_right_.x)
 	{
 	{
 		return false;
 		return false;
 		/* NOTREACHED */
 		/* NOTREACHED */

+ 12 - 11
cbaselib/ImageInfo.cpp

@@ -99,20 +99,18 @@ ImageInfo::loadImageInfo(const string &aFilename)
 			/* path to the segmented image */
 			/* path to the segmented image */
 			if (element.tagName() == "segmented") {
 			if (element.tagName() == "segmented") {
 				string_buffer = element.text();
 				string_buffer = element.text();
-				if (string_buffer.isEmpty()) {
-					continue;
+				if ( !string_buffer.isEmpty() ) {
+					QByteArray array = string_buffer.toAscii();
+					segmented_image_path_ = string(array.data());
 				}
 				}
-				QByteArray array = string_buffer.toAscii();
-				segmented_image_path_ = string(array.data());
 			}
 			}
 			/* image description */
 			/* image description */
 			else if (element.tagName() == "description") {
 			else if (element.tagName() == "description") {
 				string_buffer = element.text();
 				string_buffer = element.text();
-				if (string_buffer.isEmpty()) {
-					continue;
+				if ( !string_buffer.isEmpty()) {
+					QByteArray array = string_buffer.toAscii();
+					image_description_ = string(array.data());
 				}
 				}
-				QByteArray array = string_buffer.toAscii();
-				image_description_ = string(array.data());
 			}
 			}
 			/* tags */
 			/* tags */
 			else if (element.tagName() == "tags") {
 			else if (element.tagName() == "tags") {
@@ -157,8 +155,8 @@ ImageInfo::loadImageInfo(const string &aFilename)
 					string_buffer = subElement.text();
 					string_buffer = subElement.text();
 
 
 					if (subElement.tagName() == "bbox") {
 					if (subElement.tagName() == "bbox") {
-						BoundingBox bbox = BBoxFromData(&string_buffer);
-						bbox.setID(id);
+						BoundingBox bbox = BBoxFromData(&string_buffer, id);
+						//bbox.setID(id);
 						bboxes_.push_back(bbox);
 						bboxes_.push_back(bbox);
 					}
 					}
 					if (subElement.tagName() == "poly") {
 					if (subElement.tagName() == "poly") {
@@ -320,10 +318,13 @@ ImageInfo::loadCategoryInfo(QDomElement *anElement)
  */
  */
 BoundingBox
 BoundingBox
 ImageInfo::BBoxFromData(
 ImageInfo::BBoxFromData(
-	QString *aBBoxData
+	QString *aBBoxData,
+	int &id
 )
 )
 {
 {
 	BoundingBox bbox;
 	BoundingBox bbox;
+	bbox.setID(id);
+
 	QString buffer;
 	QString buffer;
 	int startPos = 0;
 	int startPos = 0;
 	bool ok = 1;
 	bool ok = 1;

+ 1 - 1
cbaselib/ImageInfo.h

@@ -40,7 +40,7 @@ class ImageInfo
 #ifdef NICE_USELIB_QT4_XML
 #ifdef NICE_USELIB_QT4_XML
 
 
     Polygon polyFromData ( QString *aPolyData );
     Polygon polyFromData ( QString *aPolyData );
-    BoundingBox BBoxFromData ( QString *aBBoxData );
+    BoundingBox BBoxFromData ( QString *aBBoxData, int &id );
     void loadLegendFromElement ( QDomElement *anElement );
     void loadLegendFromElement ( QDomElement *anElement );
     bool loadCategoryInfo ( QDomElement *anElement );
     bool loadCategoryInfo ( QDomElement *anElement );
     NICE::ImageT< unsigned int > imageTFromData (
     NICE::ImageT< unsigned int > imageTFromData (