findContours withHierarchy=true segmentation faults on a zeros image
electronicwhisper opened this issue · 2 comments
electronicwhisper commented
When I run findContours withHierarchy=true, it works most of the time but segmentation faults if the image I pass in is all zeros.
Below is a test case that shows this behavior. Note that if you make one of the image pixels white it works.
local cv = require "cv"
require "cv.imgcodecs"
require "cv.imgproc"
local img = torch.ByteTensor(400, 400)
-- Uncomment below and this works.
-- img[20][20] = 255
local contours, hierarchy = cv.findContours{
image=img,
withHierarchy=true,
mode=cv.RETR_CCOMP,
method=cv.CHAIN_APPROX_SIMPLE
}
print(contours)
print(hierarchy)
shrubb commented
Hi, thanks for reporting! This sample works in C++, so there must be a bug in the bindings. Investigating, stay tuned...
shrubb commented
Indeed, there was a (yet another) bug in Tensor conversion. Fixed, thank you.