Browse Source

Update FAQ-ncnn-produce-wrong-result.md (#1947)

Mention jpg decoding & resizing issue

mention keep size unchanged if debug with resize issue
tags/20200727
zchrissirhcz GitHub 5 years ago
parent
commit
534f8da195
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions
  1. +17
    -1
      docs/how-to-use-and-FAQ/FAQ-ncnn-produce-wrong-result.md

+ 17
- 1
docs/how-to-use-and-FAQ/FAQ-ncnn-produce-wrong-result.md View File

@@ -36,6 +36,22 @@ ncnn::Mat in_bgr = ncnn::Mat::from_pixels(rgb_data, ncnn::Mat::PIXEL_RGB2BGR, w,
ncnn::Mat in_rgb = ncnn::Mat::from_pixels(bgr_data, ncnn::Mat::PIXEL_BGR2RGB, w, h);
```


### image decoding

JPEG(`.jpg`,`.jpeg`) is loss compression, people may get different pixel value for same image on same position.

`.bmp` images are recommended instead.

### interpolation / resizing

There are several image resizing methods, which may generate different result for same input image.

Even we specify same interpolation method, different frameworks/libraries and their various versions may also introduce difference.

A good practice is feed same size image as the input layer expected, e.g. read a 224x244 bmp image when input layer need 224x224 size.


### Mat::from_pixels/from_pixels_resize assume that the pixel data is continuous

You shall pass continuous pixel buffer to from_pixels family.
@@ -118,7 +134,7 @@ blob may have gaps between channels if (width x height) can not divided exactly
Prefer using ncnn::Mat::from_pixels or ncnn::Mat::from_pixels_resize for constructing input blob from image data

If you do need a continuous blob buffer, reshape the output.
```
```cpp
// out is the output blob extracted
ncnn::Mat flattened_out = out.reshape(out.w * out.h * out.c);



Loading…
Cancel
Save