Skip to content

Commit

Permalink
Add copyMakeBorder
Browse files Browse the repository at this point in the history
  • Loading branch information
shrubb committed Apr 14, 2018
1 parent 9763873 commit b4e516a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cv/core/init.lua
Expand Up @@ -8,6 +8,10 @@ ffi.cdef[[
int getNumThreads();

void setNumThreads(int nthreads);

struct TensorWrapper copyMakeBorder(struct TensorWrapper src, struct TensorWrapper dst, int top,
int bottom, int left, int right, int borderType,
struct ScalarWrapper value);
]]

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

function cv.copyMakeBorder(t)
local argRules = {
{"src", required = true, operator = cv.wrap_tensor},
{"dst", default = nil, operator = cv.wrap_tensor},
{"top", required = true},
{"bottom", required = true},
{"left", required = true},
{"right", required = true},
{"borderType", required = true},
{"value", default = {0,0,0,0} , operator = cv.Scalar}
}
return cv.unwrap_tensors(C.copyMakeBorder(cv.argcheck(t, argRules)))
end

return cv
3 changes: 3 additions & 0 deletions include/core.hpp
Expand Up @@ -7,4 +7,7 @@ int getNumThreads();

void setNumThreads(int nthreads);

struct TensorWrapper copyMakeBorder(struct TensorWrapper src, struct TensorWrapper dst, int top,
int bottom, int left, int right, int borderType,
struct ScalarWrapper value);
}
9 changes: 9 additions & 0 deletions src/core.cpp
Expand Up @@ -13,4 +13,13 @@ void setNumThreads(int nthreads)
cv::setNumThreads(nthreads);
}

struct TensorWrapper copyMakeBorder(struct TensorWrapper src, struct TensorWrapper dst, int top,
int bottom, int left, int right, int borderType,
struct ScalarWrapper value)
{
MatT dstMat = dst.toMatT();
cv::copyMakeBorder(src.toMat(), dstMat, top, bottom, left, right, borderType, value);
return TensorWrapper(dstMat);
}

} // extern "C"

0 comments on commit b4e516a

Please sign in to comment.