Openframeworks, opencv, and third parties respectively provide different type of image (ofxCv, ofxOpenCv, ofImage, cv::Mat, IplImage ...etc). I'm wondering if there is a detailed document on these differences.
Thanks
ofImage is the main image type in OpenFrameworks. Be sure to checkout ofPixels() (used for ofImage pixel access) and ofTexture(used to render an ofImage on screen)
ofOpenCv is the first OpenCV addon for OpenFrameworks and it ships with it. It has it's image format: ofxCvImage which is
made to provide interoperability between the core OF imaging types, ofImage and ofTexture, and OpenCv.
IplImage is a format/structure for OpenCV images, but the older C based API. In OpenCV 2.x and 3.x favours an easier format to work with cv::Mat
The catch is ofxOpenCv was developed quite a while back, when IplImage was more commonly used. If you're working with older OpenCV C api based code and you would like to integrate that into an OpenFrameworks project, use ofxOpenCv and ofxCvImage since they provide a bridge between OpenCV's IplImage and openFrameworks' image format.
If you're getting started with OpenCV and OpenFrameworks now, I recommend using the newer OpenCV API and cv::Mat which ofxCv integrates very nicely. When I use OpenCV in OpenFrameworks I use ofxCv and I tend to do most of the work in cv::Mat format. Only at the last stage, when I need to render the OpenCV image processing results in OpenFrameworks I make use ofxCv's utilties(see Utilities, Wrappers and Helpers) to convert back and forth between the formats. Most commonly I use:
toCv()
to convert from OpenFrameworks to cv::Mat
formattoOf()
rarely to convert from cv::Mat
to ofImage
drawMat()
often to render cv::Mat
results straight into openFrameworksBe sure to go through ofxCv examples. They are fun and there's a lot to learn from them. Have fun!
Update ofBook's Varieties of oF Image Containers (Data Structures) section also provides detailed information on ofImage
, ofCvImage
and cv::Mat
. Be sure to check it out!
To the greatest extent possible, the designers of openFrameworks (and addons for image processing, like ofxOpenCV and Kyle McDonald's ofxCv) have provided simple operators to help make it easy to exchange data between these containers.