You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/03/22 17:00:39 UTC

[GitHub] [incubator-mxnet] piyushghai commented on a change in pull request #14474: [MXNET-1285] Draw bounding box with Scala/Java Image API

piyushghai commented on a change in pull request #14474: [MXNET-1285] Draw bounding box with Scala/Java Image API
URL: https://github.com/apache/incubator-mxnet/pull/14474#discussion_r268258062
 
 

 ##########
 File path: scala-package/core/src/test/scala/org/apache/mxnet/ImageSuite.scala
 ##########
 @@ -97,4 +97,25 @@ class ImageSuite extends FunSuite with BeforeAndAfterAll {
     logger.info(s"converted image stored in ${tempDirPath + "/inputImages/out.png"}")
   }
 
+  test("Test draw Bounding box") {
+    val buf = ImageIO.read(new File(imLocation))
+    val box = Array(
+      Map("xmin" -> 190, "xmax" -> 850, "ymin" -> 50, "ymax" -> 450),
+      Map("xmin" -> 200, "xmax" -> 350, "ymin" -> 440, "ymax" -> 530)
+    )
+    val names = Array("pug", "cookie")
+    Image.drawBoundingBox(buf, box, Some(names), fontSizeMult = Some(1.4f))
+    val tempDirPath = System.getProperty("java.io.tmpdir")
+    ImageIO.write(buf, "png", new File(tempDirPath + "/inputImages/out2.png"))
+    logger.info(s"converted image stored in ${tempDirPath + "/inputImages/out2.png"}")
+    for (coord <- box) {
+      val topLeft = buf.getRGB(coord("xmin"), coord("ymin"))
+      val downLeft = buf.getRGB(coord("xmin"), coord("ymax"))
+      val topRight = buf.getRGB(coord("xmax"), coord("ymin"))
+      val downRight = buf.getRGB(coord("xmax"), coord("ymax"))
+      require(downLeft == downRight)
+      require(topRight == downRight)
+    }
 
 Review comment:
   Can we also clean up the file we created in the unit test here ? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services