From 534f8da195c82e4b5fdb650fbb1db8e2fb576502 Mon Sep 17 00:00:00 2001 From: zchrissirhcz Date: Tue, 21 Jul 2020 18:34:02 +0800 Subject: [PATCH] Update FAQ-ncnn-produce-wrong-result.md (#1947) Mention jpg decoding & resizing issue mention keep size unchanged if debug with resize issue --- .../FAQ-ncnn-produce-wrong-result.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/how-to-use-and-FAQ/FAQ-ncnn-produce-wrong-result.md b/docs/how-to-use-and-FAQ/FAQ-ncnn-produce-wrong-result.md index 6f603627b..526de5ab2 100644 --- a/docs/how-to-use-and-FAQ/FAQ-ncnn-produce-wrong-result.md +++ b/docs/how-to-use-and-FAQ/FAQ-ncnn-produce-wrong-result.md @@ -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);