Forums - Including Preprocessing of image file in SNPE

4 posts / 0 new
Last post
Including Preprocessing of image file in SNPE
ashishku
Join Date: 27 Sep 17
Posts: 4
Posted: Sat, 2017-12-02 08:33

Hello All,

Platform: Snapdragon 820 ( OpenQ-820 from Intrinsyc) Andriod API24

SNPE Version : 1.8.0

I was able to run and profile on time it takes for CPU/DSP/GPU to load DLC,build Network  and Execute network using Inception_V3. However the precprocessing of images is being done offline ( .jpg to .raw ) using python script. I have a requirement of using preprocessing of images  within the application (android apk ) as I will be getting images on my platform continously and need to process those as soon as they come.

How to go ahead with such requirement. Any pointers? Is there any tweak in SNPE 1.8?

 

Thanks

AK

  • Up0
  • Down0
bspinar
Join Date: 4 Feb 15
Posts: 21
Posted: Thu, 2017-12-07 12:16

Hi. Here are a couple thoughts. If you're using Caffe as your training framework, SNPE supports some image pre-processing options with Caffe (e.g. color space conversion and scaling). This is explained in detail in the SDK documentation. If not, you might look into using something like OpenCV to do the image pre-processing on device before passing images to SNPE.

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Tue, 2019-09-24 03:32

Hi,
Yes, Image pre-processing can be done within the Android Application. 
Here is the sample code(https://github.com/globaledgesoft/AIML-DashCam-App) for an Android Application using Mobilenet SSD for object detection. The model is provided with the pre-processed images where the input is received from the camera feed.

Steps followed for pre-processing the image in Android App:
1. Resize the image/bitmap size according to the input size required by the model.
2. Convert Bitmap to buffer(RGBA byte array)
3. Process pixels RGBA(0..255) to BGR(-1..1)
This will convert Bitmap (300,300,4 ints) to Float Input Tensor (300,300,3 floats)

For code reference for the above steps, please follow this java file https://github.com/globaledgesoft/AIML-DashCam-App/blob/master/app/src/main/java/com/qc/dashcam/Helpers/BitmapToFloatArrayHelper.java

Hope this helps!
Thanks

  • Up0
  • Down0
robel
Join Date: 12 Mar 21
Posts: 1
Posted: Wed, 2021-04-21 00:51

Thanks, gesqdn-forum. You saved me.

Unfortunately, Qualcomm documentation for C++ usage is very premature.
It needs a huge update and review.

 

 

  • 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.