cocoa-xu / evision

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

NIF error returned from Evision.VideoIORegistry.getBackendName/1 #158

Closed kipcole9 closed 1 year ago

kipcole9 commented 1 year ago

When looking to identify the configured VideoCapture backends it seems there is a documentation mismatch or API error in Evision.VideoIORegistry.getBackendName/1.

The spec for Evision.VideoIORegistry.getBackendName/1 reads:

@spec getBackendName([number()]) :: binary() | {:error, String.t()}

So I expected that passing the output of Evision.VideoIORegistry.getBackends/0 would be acceptable. I also tried a single backend number like [1900] with the same error result:

iex> Evision.VideoIORegistry.getBackends
[1900, 1800, 2300, 1200, 2000, 2200, 2500]
iex> Evision.VideoIORegistry.getBackends() |> Evision.VideoIORegistry.getBackendName()
** (ArgumentError) argument error
    (evision 0.1.25) :evision_nif.videoio_registry_getBackendName([api: [1900, 1800, 2300, 1200, 2000, 2200, 2500]])
    (evision 0.1.25) lib/generated/evision_videoioregistry.ex:56: Evision.VideoIORegistry.getBackendName/1
    iex:11: (file)
cocoa-xu commented 1 year ago

I'll check Evision.VideoIORegistry related functions. getBackendName and hasBackend shouldn't be expecting a list as their input.

kipcole9 commented 1 year ago

I did try with a single integer argument with a different error result:

iex> Evision.VideoCapture.getBackendName 1900
{:error,
 "cannot get `Ptr<cv::VideoCapture>` from `self`: mismatched type or invalid resource?"}
cocoa-xu commented 1 year ago

Evision.VideoCapture.getBackendName returns the backend name that is currently used by an Evision.VideoCapture instance. It's an instance method so you need to pass in an Evision.VideoCapture.t()