cocoa-xu / evision

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

manually adds `flann/defines.h` to the header list #258

Closed cocoa-xu closed 3 days ago

cocoa-xu commented 3 days ago

This PR should allow the binding code generator to parse and generate flann-related enums.

It checks if modules/flann/include/opencv2/flann.hpp is in the header list, if so (which indicates the user compiles OpenCV with the flann module), it will add modules/flann/include/opencv2/flann/defines.h to the list (if exists, just in case the file is removed or renamed in the future versions of OpenCV).

This should include the following enums and place them in the corresponding modules.

~For example, flann_algorithm_t will be put in Evision.Flann.FlannAlgorithm:~

Actually Evision.Flann.FlannAlgorithm sounds too wordy lets just remove the prefixed Flann in the module name, so it becomes Evision.Flann.Algorithm.

Also, let's not add deprecated ones for each of these enums. (See https://github.com/opencv/opencv/blob/39a7b3d1869d31df92029503b9a8670071eac596/modules/flann/include/opencv2/flann/defines.h#L82)

defmodule Evision.Flann.Algorithm do
  @type enum :: integer()
  @doc enum: true
  def cv_FLANN_INDEX_LINEAR, do: 0
  @doc enum: true
  def cv_FLANN_INDEX_KDTREE, do: 1
  @doc enum: true
  def cv_FLANN_INDEX_KMEANS, do: 2
  @doc enum: true
  def cv_FLANN_INDEX_COMPOSITE, do: 3
  @doc enum: true
  def cv_FLANN_INDEX_KDTREE_SINGLE, do: 4
  @doc enum: true
  def cv_FLANN_INDEX_HIERARCHICAL, do: 5
  @doc enum: true
  def cv_FLANN_INDEX_LSH, do: 6
  @doc enum: true
  def cv_FLANN_INDEX_SAVED, do: 254
  @doc enum: true
  def cv_FLANN_INDEX_AUTOTUNED, do: 255
end