Skip to content

Commit a9a7be0

Browse files
authored
c_api: expose Mat border processing api (#4855)
1 parent e8645e9 commit a9a7be0

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/c_api.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,30 @@ int ncnn_extractor_extract_index(ncnn_extractor_t ex, int index, ncnn_mat_t* mat
14171417
return ret;
14181418
}
14191419

1420+
void ncnn_copy_make_border(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, int type, float v, const ncnn_option_t opt)
1421+
{
1422+
const Option _opt = opt ? *((const Option*)opt) : Option();
1423+
copy_make_border(*(const Mat*)src, *(Mat*)dst, top, bottom, left, right, type, v, _opt);
1424+
}
1425+
1426+
void ncnn_copy_make_border_3d(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, int front, int behind, int type, float v, const ncnn_option_t opt)
1427+
{
1428+
const Option _opt = opt ? *((const Option*)opt) : Option();
1429+
copy_make_border_3d(*(const Mat*)src, *(Mat*)dst, top, bottom, left, right, front, behind, type, v, _opt);
1430+
}
1431+
1432+
void ncnn_copy_cut_border(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, const ncnn_option_t opt)
1433+
{
1434+
const Option _opt = opt ? *((const Option*)opt) : Option();
1435+
copy_cut_border(*(const Mat*)src, *(Mat*)dst, top, bottom, left, right, _opt);
1436+
}
1437+
1438+
void ncnn_copy_cut_border_3d(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, int front, int behind, const ncnn_option_t opt)
1439+
{
1440+
const Option _opt = opt ? *((const Option*)opt) : Option();
1441+
copy_cut_border_3d(*(const Mat*)src, *(Mat*)dst, top, bottom, left, right, front, behind, _opt);
1442+
}
1443+
14201444
#ifdef __cplusplus
14211445
} /* extern "C" */
14221446
#endif

src/c_api.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,16 @@ NCNN_EXPORT int ncnn_extractor_extract(ncnn_extractor_t ex, const char* name, nc
327327
NCNN_EXPORT int ncnn_extractor_input_index(ncnn_extractor_t ex, int index, const ncnn_mat_t mat);
328328
NCNN_EXPORT int ncnn_extractor_extract_index(ncnn_extractor_t ex, int index, ncnn_mat_t* mat);
329329

330+
/* mat process api */
331+
#define NCNN_BORDER_CONSTANT 0
332+
#define NCNN_BORDER_REPLICATE 1
333+
#define NCNN_BORDER_REFLECT 2
334+
#define NCNN_BORDER_TRANSPARENT -233
335+
NCNN_EXPORT void ncnn_copy_make_border(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, int type, float v, const ncnn_option_t opt);
336+
NCNN_EXPORT void ncnn_copy_make_border_3d(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, int front, int behind, int type, float v, const ncnn_option_t opt);
337+
NCNN_EXPORT void ncnn_copy_cut_border(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, const ncnn_option_t opt);
338+
NCNN_EXPORT void ncnn_copy_cut_border_3d(const ncnn_mat_t src, ncnn_mat_t dst, int top, int bottom, int left, int right, int front, int behind, const ncnn_option_t opt);
339+
330340
#ifdef __cplusplus
331341
} /* extern "C" */
332342
#endif

0 commit comments

Comments
 (0)