Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
add point wise verification
Browse files Browse the repository at this point in the history
  • Loading branch information
lanking520 committed Mar 20, 2019
1 parent 0f74c5d commit 231312d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ object Image {
* @param transparency The transparency level
* @return Color
*/
private def randomColor(transparency: Float) : Color = {
private def randomColor(transparency: Option[Float] = Some(1.0f)) : Color = {
new Color(
Math.random().toFloat, Math.random().toFloat, Math.random().toFloat,
transparency
).darker()
transparency.get
)
}

/**
Expand Down Expand Up @@ -220,7 +220,7 @@ object Image {
val fm = g2d.getFontMetrics(newFont)
for (idx <- coordinate.indices) {
val map = coordinate(idx)
g2d.setColor(randomColor(transparency.get))
g2d.setColor(randomColor(transparency).darker())
g2d.drawRect(map("xmin"), map("ymin"), map("xmax") - map("xmin"), map("ymax") - map("ymin"))
// Write the name of the bounding box
if (names.isDefined) {
Expand All @@ -234,7 +234,6 @@ object Image {
}
}
g2d.dispose()
src
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object Image {
java.util.Map[java.lang.String, java.lang.Integer]],
names: java.util.List[java.lang.String]): Unit = {
val coord = coordinate.asScala.map(
ele => ele.asScala.map(ele => (ele._1, Integer2int(ele._2))).toMap).toArray
_.asScala.map{case (name, value) => (name, Integer2int(value))}.toMap).toArray
org.apache.mxnet.Image.drawBoundingBox(src, coord, Option(names.asScala.toArray))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ class ImageSuite extends FunSuite with BeforeAndAfterAll {
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(topLeft == downLeft)
require(topRight == downRight)
require(topLeft == downRight)
}
}

}

0 comments on commit 231312d

Please sign in to comment.