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..4cc1358fd4e5 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