Hi!
I’m currently trying to implement a simple point detection pipeline in order to get the points positions in an image :
For that, I start by finding contours in the image, then try to use the cv.moments(contour) function to find their centroid.
img = Evision.imread("***/elixir/membrane/points-img.png")
bw = Evision.imread("***/elixir/membrane/points-img.png", flags: Evision.Constant.cv_IMREAD_GRAYSCALE())
|> Evision.threshold(50, 255, Evision.Constant.cv_THRESH_BINARY())
|> then(fn {_, mat} -> mat end)
{contours, _ } = Evision.findContours(bw, Evision.Constant.cv_RETR_TREE(), Evision.Constant.cv_CHAIN_APPROX_SIMPLE())
contours
|> Enum.map(fn c ->
moments = Evision.moments(c, binaryImage: true)
IO.inspect(Evision.contourArea(c), label: "Contour area")
moments
end)
|> IO.inspect()
However, the Evision.moments function always returns an empty map. (I tried contourArea just to debug)
output:
Contour area: 193.0
Contour area: 197.5
Contour area: 110.0
[%{}, %{}, %{}]
Am I doing something wrong, or is this an issue on the bindings side?
Thanks for the help !
EDIT:
changing binaryImage to false did not change anything