ankandrew commited on
Commit
23f8648
·
1 Parent(s): 484275c

fix(demo): update prerpocess in android code of ncnn (#704)

Browse files
demo/ncnn/android/app/src/main/jni/yoloXncnn_jni.cpp CHANGED
@@ -353,10 +353,6 @@ JNIEXPORT jobjectArray JNICALL Java_com_megvii_yoloXncnn_YOLOXncnn_Detect(JNIEnv
353
  const float prob_threshold = 0.3f;
354
  const float nms_threshold = 0.65f;
355
  std::vector<int> strides = {8, 16, 32}; // might have stride=64
356
- // python 0-1 input tensor with rgb_means = (0.485, 0.456, 0.406), std = (0.229, 0.224, 0.225)
357
- // so for 0-255 input image, rgb_mean should multiply 255 and norm should div by std.
358
- const float mean_vals[3] = {255.f * 0.485f, 255.f * 0.456, 255.f * 0.406f};
359
- const float norm_vals[3] = {1 / (255.f * 0.229f), 1 / (255.f * 0.224f), 1 / (255.f * 0.225f)};
360
 
361
  int w = width;
362
  int h = height;
@@ -374,7 +370,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_megvii_yoloXncnn_YOLOXncnn_Detect(JNIEnv
374
  w = w * scale;
375
  }
376
 
377
- ncnn::Mat in = ncnn::Mat::from_android_bitmap_resize(env, bitmap, ncnn::Mat::PIXEL_RGB, w, h);
378
 
379
  // pad to target_size rectangle
380
  int wpad = target_size - w;
@@ -388,8 +384,6 @@ JNIEXPORT jobjectArray JNICALL Java_com_megvii_yoloXncnn_YOLOXncnn_Detect(JNIEnv
388
  std::vector<Object> objects;
389
  {
390
 
391
- in_pad.substract_mean_normalize(mean_vals, norm_vals);
392
-
393
  ncnn::Extractor ex = yoloX.create_extractor();
394
 
395
  ex.set_vulkan_compute(use_gpu);
 
353
  const float prob_threshold = 0.3f;
354
  const float nms_threshold = 0.65f;
355
  std::vector<int> strides = {8, 16, 32}; // might have stride=64
 
 
 
 
356
 
357
  int w = width;
358
  int h = height;
 
370
  w = w * scale;
371
  }
372
 
373
+ ncnn::Mat in = ncnn::Mat::from_android_bitmap_resize(env, bitmap, ncnn::Mat::PIXEL_RGB2BGR, w, h);
374
 
375
  // pad to target_size rectangle
376
  int wpad = target_size - w;
 
384
  std::vector<Object> objects;
385
  {
386
 
 
 
387
  ncnn::Extractor ex = yoloX.create_extractor();
388
 
389
  ex.set_vulkan_compute(use_gpu);