cocoa-xu / evision

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

Evision.FlannBasedMatcher.knnMatch incorrect typespecs #242

Closed davydog187 closed 4 weeks ago

davydog187 commented 1 month ago

I'm getting the following dialyzer error locally

The function call will not succeed.

Evision.FlannBasedMatcher.knnMatch(
  _flann :: {:error, binary()} | %Evision.FlannBasedMatcher{:ref => reference()},
  any(),
  any(),
  2
)

breaks the contract
Contract head:
(
  Evision.DescriptorMatcher.t(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: [[Evision.DMatch.t()]] | {:error, String.t()}

Contract head:
(
  Evision.DescriptorMatcher.t(),
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer()
) :: [[Evision.DMatch.t()]] | {:error, String.t()}

in 1st argument

The issue is that knnMatch/1 expects a Evision.FlannBasedMatcher.t(), but the typespec has a Evisin.DescriptorMatcher.t(), which is not correct

cocoa-xu commented 1 month ago

Ah...it's an inheritance issue as cv::FlannBasedMatcher is a sub-class of cv::DescriptorMatcher. It should be fixed in the next version!

davydog187 commented 1 month ago

@cocoa-xu i saw you released 0.2.1. Once you publish it to hex.pm I'll give it a go!

cocoa-xu commented 1 month ago

@cocoa-xu i saw you released 0.2.1. Once you publish it to hex.pm I'll give it a go!

I'll let you know once it's shipped on hex.pm. I'm finishing some last bits with CUDA modules. It should be available later today if not tomorrow! But this won't be a complete fix until #245 is addressed.

cocoa-xu commented 1 month ago

v0.2.1 is shipped!

davydog187 commented 4 weeks ago

This is now fixed, thanks @cocoa-xu !