gigasquid opened a new issue #14506: [Clojure] - Add Draw Bounding Box to Core 
Clojure Image namespace
URL: https://github.com/apache/incubator-mxnet/issues/14506
 
 
   ## 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  https://github.com/apache/incubator-mxnet/pull/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
   
   ```clojure
     (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

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to