Commit ad02e95b authored by Quan's avatar Quan

full flow mobile slicing person

parent e8c3439a
......@@ -103,14 +103,14 @@ public class MobilenetDetector {
Mat frameCv = new Mat();
Bitmap frame32 = frame.copy(Bitmap.Config.ARGB_8888, true);
Utils.bitmapToMat(frame32, frameCv);
Mat resizeimage = new Mat();
Size sz = new Size(MODEL_WIDTH,MODEL_HEIGHT);
Imgproc.resize( frameCv, resizeimage, sz );
Imgproc.cvtColor(resizeimage , resizeimage , Imgproc.COLOR_RGBA2RGB);//COLOR_RGBA2RGB
resizeimage.convertTo(resizeimage, CvType.CV_32F);//, 1.0, 0); //convert to 32F
Core.subtract(resizeimage, new Scalar(127.0f, 127.0f, 127.0f), resizeimage);
Core.divide(resizeimage, new Scalar(128.0f, 128.0f, 128.0f), resizeimage);
resizeimage.get(0, 0, inputValues); //image.astype(np.float32)
// Mat resizeimage = new Mat();
// Size sz = new Size(MODEL_WIDTH,MODEL_HEIGHT);
// Imgproc.resize( frameCv, resizeimage, sz );
Imgproc.cvtColor(frameCv , frameCv , Imgproc.COLOR_RGBA2RGB);//COLOR_RGBA2RGB
frameCv.convertTo(frameCv, CvType.CV_32F);//, 1.0, 0); //convert to 32F
Core.subtract(frameCv, new Scalar(127.0f, 127.0f, 127.0f), frameCv);
Core.divide(frameCv, new Scalar(128.0f, 128.0f, 128.0f), frameCv);
frameCv.get(0, 0, inputValues); //image.astype(np.float32)
long preProcessTime = System.currentTimeMillis()- preProcessStart;
Log.d(LOGTAG,"Preprocess_time: "+ preProcessTime);
/**Preprocessing**/
......
package com.qualcomm.qti.snpe.imageclassifiers.thread;
import static com.qualcomm.qti.snpe.imageclassifiers.detector.MobilenetDetector.MODEL_HEIGHT;
import static com.qualcomm.qti.snpe.imageclassifiers.detector.MobilenetDetector.MODEL_WIDTH;
import static com.qualcomm.qti.snpe.imageclassifiers.detector.RetinaDetector.IMG_HEIGHT;
import static com.qualcomm.qti.snpe.imageclassifiers.detector.RetinaDetector.IMG_WIDTH;
......@@ -18,6 +20,7 @@ import android.util.Log;
import com.qualcomm.qti.snpe.imageclassifiers.MainActivity;
import com.qualcomm.qti.snpe.imageclassifiers.R;
import com.qualcomm.qti.snpe.imageclassifiers.detector.Bbox;
import com.qualcomm.qti.snpe.imageclassifiers.detector.MobilenetDetector;
import com.qualcomm.qti.snpe.imageclassifiers.detector.RetinaDetector;
import java.io.ByteArrayOutputStream;
......@@ -37,13 +40,13 @@ public class AiSlicingThread extends Thread{
/** class main attribute */
private LinkedBlockingDeque<ImageSlice> aiSlicesQueue;
private RetinaDetector mDetector;
private MobilenetDetector mDetector;
private AISliceMergingThread aiSliceMergingThread;
private boolean isProcess = true;
private Context mContext;
/** Constructor 1: receive exist detector */
public AiSlicingThread(RetinaDetector mDetector, AISliceMergingThread aiSliceMergingThread) {
public AiSlicingThread(MobilenetDetector mDetector, AISliceMergingThread aiSliceMergingThread) {
this.aiSlicesQueue = new LinkedBlockingDeque<>();
this.aiSliceMergingThread = aiSliceMergingThread;
this.mDetector = mDetector;
......@@ -55,7 +58,7 @@ public class AiSlicingThread extends Thread{
this.aiSlicesQueue = new LinkedBlockingDeque<>();
mContext = context;
this.aiSlicesQueue = new LinkedBlockingDeque<ImageSlice>();
this.mDetector = new RetinaDetector(context, application, R.raw.retina_mb_nosm_h288_w512_quantized);
this.mDetector = new MobilenetDetector(context, application, R.raw.mb1_ssd_sim);
this.setName(AI_SLICING_THREAD);
}
......@@ -83,8 +86,8 @@ public class AiSlicingThread extends Thread{
sliceCropBox.getX(), sliceCropBox.getY(),
sliceCropBox.getWidth(), sliceCropBox.getHeight());
final float scaleX = IMG_WIDTH / (float) (croppedBmp1.getWidth());
final float scaleY = IMG_HEIGHT / (float) (croppedBmp1.getHeight());
final float scaleX = MODEL_WIDTH / (float) (croppedBmp1.getWidth());
final float scaleY = MODEL_HEIGHT / (float) (croppedBmp1.getHeight());
final Matrix scalingMatrix = new Matrix();
scalingMatrix.postScale(scaleX, scaleY);
......@@ -140,7 +143,7 @@ public class AiSlicingThread extends Thread{
return aiSlicesQueue.offerLast(imageSlice);
}
private List<Bbox> startAIFlowDetect(RetinaDetector mDetector, Bitmap bmp, int frameId,float scaleX,float scaleY,int startX,int startY) throws IOException {
private List<Bbox> startAIFlowDetect(MobilenetDetector mDetector, Bitmap bmp, int frameId,float scaleX,float scaleY,int startX,int startY) throws IOException {
List<Bbox> detectedBoxes = new ArrayList<>();
final Bitmap resizedBmpCopy = bmp.copy(Bitmap.Config.ARGB_8888, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment