A machine vision extension to the Ruby programming language using OpenCV and FFI
Aaron Marburg, Michael Hayes, Andrew Bainbridge-Smith · 2013
This paper introduces the OpenCV-FFI software package, which exposes datatypes and functions from the OpenCV computer vision library into the Ruby programming language. OpenCV-FFI uses the foreign function interface (FFI) to produce a Ruby API which mirrors the OpenCV C API; further layers of complexity are then built on that core API. Example code and benchmarking results show the effectiveness of using OpenCV-FFI for scripting OpenCV code within Ruby, as well as demonstrating the pitfalls of incautious use of Ruby iteration. Finally, there is a discussion of the relative advantages and disadvantages of the FFI-based approach versus a bespoke extension library written in Ruby-C or the use of an automatic wrapper generation packages (e.g., SWIG).