Re: OpenCV and Eu
- Posted by ghaberek (admin) Jan 09, 2012
- 1434 views
Jerome said...
I was thinking about doing a vision project with OpenCV and Eu. I've used OpenCV previously for a small project but have never attempted to wrap it for native use in Euphoria.
Has anyone looked into this before? I didn't find anything in the archives or forum. Also, OpenCV is a fairly large project; what are the important considerations for tackling such a task?
Thanks,
Ira
I don't think anyone's wrapped OpenCV before, but it seems to have a plain old C interface, which should be relatively straight-forward to wrap in Euphoria. Here are a few things to consider when wrapping any C library:
- Get a good overview of what you're wrapping before you start. Look all the data types, functions, and structures to help prevent surprises down the road. Sometimes I run across a structure or function that turns me off of wrapping a library due to extensive and/or nasty C-isms. Matt's been working on "memstructs" for Euphoria, which will almost certainly make wrapping C libraries much easier.
- Collect all the data type definitions and list them next to their Euphoria C_TYPE constants. This will make wrapping easier and more consistent as you move forward. Remember that parameters prefixed with an asterisk (*) are pointers, so you need to use C_POINTER instead of their declared type, and then account for that type in your wrapper function.
- You may want to wrap everything in two stages. A lot of C functions pass return values back via pointers in the parameter of a function, with an error code (or zero) returned directly, whereas Euphoria functions accept parameters and return everything back as one value. So first build a low-level direct wrapping of each function, and then a high-level Euphoria-esque set of functions. This is how libraries like Win32Lib and wxEuphoria work. Given the size, nature, and complexity of OpenCV, this may be a good idea.
Hope that helps. I may come up with more tips. Hopefully others will chime in as well.
-Greg