cocoa-xu / evision

Evision: An OpenCV-Erlang/Elixir binding
https://evision.app
Apache License 2.0
337 stars 22 forks source link

segmentation fault #120

Closed sanjaykv02 closed 1 year ago

sanjaykv02 commented 1 year ago

Respected Ma'am \ Sir, After updating evision, segmentation fault happened in the function Evision.findContours(Evision.mat, method, mode ).

code snippet:-

  iex(1)> path = "images/grid_1.png"
  "images/grid_1.png"
  iex(2)> {_, img_mat} = Evision.imread path
  {:ok,
       %Evision.Mat{
           channels: 3,
           dims: 2,
           raw_type: 16,
           ref: #Reference<0.2914473186.3120168976.115461>,
           shape: {1080, 1080, 3},
           type: {:u, 8}
  }}
  iex(3)> Evision.findContours(img_mat, 1, 1)
  Segmentation fault (core dumped)
cocoa-xu commented 1 year ago

Hi, the first thing is that please update your dependencies, {:evision, "~> 0.1.14"}, because based on the return value, you're using an outdated version. This will solve the segmentation fault issue, and an error message will be returned if you use the same code.

Secondly, and to solve the real issue, OpenCV findContours expects a binary image instead of a 3-channel BGR image. Please see the online docs or OpenCV's tutorial.