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

[Clojure] - Add Draw Bounding Box to Core Clojure Image namespace #14506

Closed
gigasquid opened this issue Mar 22, 2019 · 2 comments · Fixed by #14533
Closed

[Clojure] - Add Draw Bounding Box to Core Clojure Image namespace #14506

gigasquid opened this issue Mar 22, 2019 · 2 comments · Fixed by #14533

Comments

@gigasquid
Copy link
Member

Context

For Object detection, we were using Origami in the examples to draw bounding boxes. The Scala package has just added this bounding box drawing into the core package with this PR #14474 so it would be better for us to use this through interop to achieve consistency through the JVM packages

Sample Code

Here is some sample interop code that will draw the boxes

  (import '(org.apache.mxnet Image))

  (defn download-image []
  (with-open [in (io/input-stream "https://s3.amazonaws.com/model-server/inputs/Pug-Cookie.jpg")
              out (io/output-stream (io/file image-path))]
    (io/copy in out)))

  (download-image)

  (def my-image (ImageIO/read (new File image-path)))
  (let [box [(util/convert-map {"xmin" (int 190) "xmax" (int 850)
                                "ymin" (int 50) "ymax" (int 450)})
             (util/convert-map {"xmin" (int 200) "xmax" (int 350)
                                "ymin" (int 440) "ymax" (int 530)})]
        names (into-array ["pug" "cookie"])
        font-size-mult (float 1.4)
        stroke (int 3)
        transparency (float 1.0)]
    (Image/drawBoundingBox my-image
                           (into-array box)
                           (util/->option names)
                           (util/->option stroke)
                           (util/->option font-size-mult)
                           (util/->option transparency)))

  (ImageIO/write my-image "png" (io/file tmp-dir "out.png"))

Testing

This should be added as a function to the org.apache.clojure-mxnet.image namespace and also used in the object detection example.

Testing can follow the path in the Scala PR /~https://github.com/apache/incubator-mxnet/pull/14474/files#diff-3b90268bc4fb53edb14b46c46be1cc32

@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Feature, Doc

@Chouffe
Copy link
Contributor

Chouffe commented Mar 26, 2019

Work in Progress here: #14533

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants