cocoa-xu / evision

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

[Possible bug] Wrong typespec for the color parameter in drawContours() #183

Closed tusqasi closed 1 year ago

tusqasi commented 1 year ago
  @spec drawContours(Evision.Mat.maybe_mat_in(), list(Evision.Mat.maybe_mat_in()), integer(), {number()} | {number(), number()} | {number() | number() | number()} | {number(), number(), number(), number()}, [{atom(), term()},...] | nil) :: Evision.Mat.t() | {:error, String.t()}
  def drawContours(image, contours, contourIdx, color, opts) when (is_struct(image, Evision.Mat) or is_struct(image, Nx.Tensor)) and is_list(contours) and is_integer(contourIdx) and is_tuple(color) and (opts == nil or (is_list(opts) and is_tuple(hd(opts))))

Looking at the type of color {number(), number()} | {number() | number() | number()} | {number(), number(), number(), number()}

And looking closer, the second one is {number() | number() | number()}, which probably doesn't make sense.

I asked around in the elixir discord wether this was as dialyzer issue or something else.

It seems that it is wrong from here https://github.com/cocoa-xu/evision/blob/e697d9701a9a280855a305734457612323848c89/py_src/helper.py#L1089

Thank you nicd for finding this.

tusqasi commented 1 year ago

https://github.com/cocoa-xu/evision/pull/182

cocoa-xu commented 1 year ago

Hi @tusqasi thanks for report this issue! I'm still waiting for the CI, and once it's finished, I'll ship out a new version, v0.1.29.