hellonico commented on a change in pull request #13813: [WIP] examples with 
opencv4/origami
URL: https://github.com/apache/incubator-mxnet/pull/13813#discussion_r247355292
 
 

 ##########
 File path: 
contrib/clojure-package/examples/infer/objectdetector/src/infer/objectdetector_example.clj
 ##########
 @@ -63,19 +68,34 @@
               (* (aget prob-and-bounds 2) height)
               (* (aget prob-and-bounds 3) width)
               (* (aget prob-and-bounds 4) height))))
-  (println (apply str (repeat 80 "="))))
+  (println (apply str (repeat 80 "=")))))
+
+(defn result->map [result]
+  (let[prob-and-bounds (second result) label (first result)]
+    (hash-map 
+          :label label 
+          :confidence (int (* 100 (aget prob-and-bounds 0)))
+          :top-left [(aget prob-and-bounds 1) (aget prob-and-bounds 2)]
+          :bottom-right [(aget prob-and-bounds 3) (aget prob-and-bounds 4)])))
+
+(defn process-results [images results output-dir]
+  (dotimes [i (count images)]
+    (let [image (nth images i) _results (map result->map (nth results i))]
+      (draw/draw-bounds image _results output-dir))))
 
 (defn detect-single-image
   "Detect objects in a single image and print top-5 predictions"
-  [detector input-image]
+  [detector input-image output-dir]
   (let [image (infer/load-image-from-file input-image)
-        topk 5
-        [predictions] (infer/detect-objects detector image topk)]
-    predictions))
+        topk 5]
+        (process-results 
+        [input-image]
+        (infer/detect-objects detector image topk)
+        output-dir)))
 
 (defn detect-images-in-dir
   "Detect objects in all jpg images in the directory"
-  [detector input-dir]
+  [detector input-dir output-dir]
 
 Review comment:
   "results" it is. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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