Browse Source

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 13 năm trước cách đây
mục cha
commit
3c9a469747
3 tập tin đã thay đổi với 15 bổ sung13 xóa
  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;
 		/* NOTREACHED */
 	}
+	id_ = anID;
 }
 
 //! returns top left coordinate of the bounding box
@@ -191,7 +192,7 @@ BoundingBox::isValid() const
 		bottom_right_.x < 0 ||
 		bottom_right_.y < 0 ||
 		bottom_right_.y <= top_left_.y ||
-		top_left_.x <= bottom_right_.x)
+		top_left_.x >= bottom_right_.x)
 	{
 		return false;
 		/* NOTREACHED */

+ 12 - 11
cbaselib/ImageInfo.cpp

@@ -99,20 +99,18 @@ ImageInfo::loadImageInfo(const string &aFilename)
 			/* path to the segmented image */
 			if (element.tagName() == "segmented") {
 				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 */
 			else if (element.tagName() == "description") {
 				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 */
 			else if (element.tagName() == "tags") {
@@ -157,8 +155,8 @@ ImageInfo::loadImageInfo(const string &aFilename)
 					string_buffer = subElement.text();
 
 					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);
 					}
 					if (subElement.tagName() == "poly") {
@@ -320,10 +318,13 @@ ImageInfo::loadCategoryInfo(QDomElement *anElement)
  */
 BoundingBox
 ImageInfo::BBoxFromData(
-	QString *aBBoxData
+	QString *aBBoxData,
+	int &id
 )
 {
 	BoundingBox bbox;
+	bbox.setID(id);
+
 	QString buffer;
 	int startPos = 0;
 	bool ok = 1;

+ 1 - 1
cbaselib/ImageInfo.h

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