herisson
Evision.moments(contour) returns empty map
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
Most Liked
mortenlund
This is my experience as well.
If I cannot make it work I will make an issue for this in the Evision repo, he was very helpful to fix issues! ![]()
1
Popular in Questions
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
I would like to know what is the best IDE for elixir development?
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Other popular topics
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I'm writing a test for one of t...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lis...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New








