Forums - how to get object's coordinate and draw the box?

4 posts / 0 new
Last post
how to get object's coordinate and draw the box?
harpper
Join Date: 27 Jul 17
Posts: 1
Posted: Mon, 2017-07-31 20:50

dear all,

 

how to use SNPE API to get object's coordinate and draw the box when classifying the objects?

thanks

  • Up0
  • Down0
moljaca moderator
Join Date: 25 Jul 17
Location: San Diego
Posts: 40
Posted: Tue, 2017-08-01 18:13

Hi, 

This question is outside of SNPE API scope and is more in application domain. It is a function of the DL model that you load and run through SNPE. In this particualr case you seem to be interested in DL models designed to do object detection, like SSD or Faster RCNN. Interpreting object coordinates is very much dependent on the DL model used, so you would need to understand that from the model output format. Drawing bounding boxes is largely target platform dependent, and requires some image manipulation support, like openCV for example. There are many ways to do it. Probably best to search online based on your setup.

Hope this helps.

Best regards.

  • Up0
  • Down0
piyalgeorge
Join Date: 29 Apr 20
Posts: 5
Posted: Thu, 2020-05-07 01:58

Is it possible to get Detection coordinates/Bounding boxes as output when using Mobilenet-ssd on snpe ?

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Wed, 2020-05-13 00:31

Kindly read the date from the raw file generated with the following python code and find the explanation below on how to parse the output.

$ python3.5
>>import numpy as np
>>res = np.fromfile('detection_out.raw', dtype="float32")
>>print(res)
[[0.,         6.,         0.99923944, 0.05772871 0.1193189,  0.9643268, 0.8045521 ]]

Explanation:
res[0, 1] will be ID for the label, as it was trained on VOC Label 6 which belongs to the bus.
res[0, 2] represent the probability of the predicted object, it is 0.9992 here
res[0, 3:7] are the scaled X1, Y1 & X2, Y2 Values respectively.
For re-scaling it Multiply X1 & X2 with Width of image & Y1 & Y2 with the Height of the image, and cast it to the Integer.
This gives the bounding box for the object predicted.

Command to convert the caffe model to dlc:
$ snpe-caffe-to-dlc --input_network MobileNetSSD_deploy.prototxt --caffe_bin MobileNetSSD_deploy.caffemodel --output_path caffe_mobilenet_ssd.dlc

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.