Skip to content

Commit b4e516a

Browse files
committed
Add copyMakeBorder
1 parent 9763873 commit b4e516a

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

cv/core/init.lua

+18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ ffi.cdef[[
88
int getNumThreads();
99

1010
void setNumThreads(int nthreads);
11+
12+
struct TensorWrapper copyMakeBorder(struct TensorWrapper src, struct TensorWrapper dst, int top,
13+
int bottom, int left, int right, int borderType,
14+
struct ScalarWrapper value);
1115
]]
1216

1317
local C = ffi.load(cv.libPath('core'))
@@ -25,4 +29,18 @@ function cv.setNumThreads(t)
2529
return C.setNumThreads(cv.argcheck(t, argRules))
2630
end
2731

32+
function cv.copyMakeBorder(t)
33+
local argRules = {
34+
{"src", required = true, operator = cv.wrap_tensor},
35+
{"dst", default = nil, operator = cv.wrap_tensor},
36+
{"top", required = true},
37+
{"bottom", required = true},
38+
{"left", required = true},
39+
{"right", required = true},
40+
{"borderType", required = true},
41+
{"value", default = {0,0,0,0} , operator = cv.Scalar}
42+
}
43+
return cv.unwrap_tensors(C.copyMakeBorder(cv.argcheck(t, argRules)))
44+
end
45+
2846
return cv

include/core.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ int getNumThreads();
77

88
void setNumThreads(int nthreads);
99

10+
struct TensorWrapper copyMakeBorder(struct TensorWrapper src, struct TensorWrapper dst, int top,
11+
int bottom, int left, int right, int borderType,
12+
struct ScalarWrapper value);
1013
}

src/core.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@ void setNumThreads(int nthreads)
1313
cv::setNumThreads(nthreads);
1414
}
1515

16+
struct TensorWrapper copyMakeBorder(struct TensorWrapper src, struct TensorWrapper dst, int top,
17+
int bottom, int left, int right, int borderType,
18+
struct ScalarWrapper value)
19+
{
20+
MatT dstMat = dst.toMatT();
21+
cv::copyMakeBorder(src.toMat(), dstMat, top, bottom, left, right, borderType, value);
22+
return TensorWrapper(dstMat);
23+
}
24+
1625
} // extern "C"

0 commit comments

Comments
 (0)