From 858d88101e4acd30d92bf5f966164f70839964b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E5=B0=8F=E5=87=A1?= <2672931+whyb@users.noreply.github.com> Date: Tue, 18 Nov 2025 18:44:14 +0800 Subject: [PATCH 1/2] Add copyMakeBorder function in simpleocv --- src/simpleocv.cpp | 24 ++++++++++++++++++++++++ src/simpleocv.h | 13 +++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/simpleocv.cpp b/src/simpleocv.cpp index f2a68f6cb525..9220d8ddc100 100644 --- a/src/simpleocv.cpp +++ b/src/simpleocv.cpp @@ -339,6 +339,30 @@ void resize(const Mat& src, Mat& dst, const Size& size, float sw, float sh, int dst = tmp; } + +void copyMakeBorder(const Mat& src, Mat& dst, int top, int bottom, int left, int right, BorderType borderType, const Scalar& value = Scalar()) +{ + ncnn::BorderType ncnn_border_type; + switch (borderType) + { + case BORDER_CONSTANT: + ncnn_border_type = ncnn::BORDER_CONSTANT; + break; + case BORDER_REPLICATE: + ncnn_border_type = ncnn::BORDER_REPLICATE; + break; + case BORDER_REFLECT: + ncnn_border_type = ncnn::BORDER_REFLECT; + break; + case BORDER_TRANSPARENT: + ncnn_border_type = ncnn::BORDER_TRANSPARENT; + break; + default: + ncnn_border_type = ncnn::BORDER_CONSTANT; + break; + } + ncnn::copy_make_border(src, dst, top, bottom, left, right, ncnn_border_type, value[0]); +} #endif // NCNN_PIXEL #if NCNN_PIXEL_DRAWING diff --git a/src/simpleocv.h b/src/simpleocv.h index 650e5203de61..155f0782f773 100644 --- a/src/simpleocv.h +++ b/src/simpleocv.h @@ -452,6 +452,19 @@ NCNN_EXPORT int waitKey(int delay = 0); #if NCNN_PIXEL NCNN_EXPORT void resize(const Mat& src, Mat& dst, const Size& size, float sw = 0.f, float sh = 0.f, int flags = 0); +enum BorderType +{ + BORDER_CONSTANT = 0, + BORDER_REPLICATE = 1, + BORDER_REFLECT = 2, + BORDER_WRAP = 3, + BORDER_REFLECT_101 = 4, + BORDER_TRANSPARENT = 5, + BORDER_REFLECT101 = BORDER_REFLECT_101, + BORDER_DEFAULT = BORDER_REFLECT_101, + BORDER_ISOLATED = 16 +}; +NCNN_EXPORT void copyMakeBorder(const Mat& src, Mat& dst, int top, int bottom, int left, int right, BorderType borderType, const Scalar& value = Scalar()); #endif // NCNN_PIXEL #if NCNN_PIXEL_DRAWING From 05392226021c74628c589e7581e1ad40cda398a5 Mon Sep 17 00:00:00 2001 From: whyb <2672931+whyb@users.noreply.github.com> Date: Tue, 18 Nov 2025 10:49:24 +0000 Subject: [PATCH 2/2] apply code-format changes --- src/simpleocv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simpleocv.h b/src/simpleocv.h index 155f0782f773..4cc1358fd4e5 100644 --- a/src/simpleocv.h +++ b/src/simpleocv.h @@ -462,7 +462,7 @@ enum BorderType BORDER_TRANSPARENT = 5, BORDER_REFLECT101 = BORDER_REFLECT_101, BORDER_DEFAULT = BORDER_REFLECT_101, - BORDER_ISOLATED = 16 + BORDER_ISOLATED = 16 }; NCNN_EXPORT void copyMakeBorder(const Mat& src, Mat& dst, int top, int bottom, int left, int right, BorderType borderType, const Scalar& value = Scalar()); #endif // NCNN_PIXEL