Skip to content
Kaiyu Yang edited this page Dec 22, 2015 · 2 revisions

Project structure

OpenCV library consists of several modules: for example, we have to #include <opencv2/imgproc.hpp> in order to use the imgproc module. In our bindings, each module is to be supported with the following files:

  • ./cv/<module-name>/init.lua for final Lua functions to be called by the end user
  • ./src/<module-name>.cpp for C functions that are called by the above Lua funcs
  • ./include/<module-name>.hpp for describing the corresponding .cpp file's signatures

Also, there is some common code:

  • ./cv/constants.lua simply contains OpenCV constant values & enums
  • ./src/Common.cpp and ./include/Common.hpp define wrapper structs for OpenCV classes (Mat, TermCriteria, Point, Size, ...)
  • ./init.lua contains data structures and methods shared by all Lua code, including Lua interfaces to structs and funcs desctibed in ./src/Common.cpp

Once implemented, a <module-name> module can be used by calling

require 'cv.<module-name>'

This will run ./cv/<module-name>/init.lua. Every such file also requires ./init.lua and ./cv/constants.lua for us.