|template<class T >|
|OpenCvMat(const T* matOrImg)|
|OpenCvMat(const kuvio_image* img, ColorType colorType)|
|OpenCvMat(kuvio_image* img, ColorType colorType)|
A class that wraps a kuvio_image or a kuvio_matrix to an OpenCV matrix (cv::Mat) so that the C types are usable in OpenCV calls. This is a non-copyable class that is intended to be used as a temporary wrapper in function calls.
Due to the lack of a standard ABI for C++, the implementation of this class cannot be used from a precompiled library but must be compiled into the calling code. To use the class you must thus add OpenCvMat.cc into your project's source files.
- cv::Mat does not implement the copy-on-write paradigm that is the standard convention on reference-counted objects elsewhere. Therefore, the contents of a wrapped image or a matrix may be modified if the called function modifies the data, even though the image or matrix was originally passed as a const pointer. To make things worse, OpenCV function declarations don't use
constto distinguish between input and output data, and the documentation isn't always clear on this either. There is no efficient way around this deficiency, so be careful. Make a deep copy of the kuvio_image or kuvio_matrix if unsure.
Member Enumeration Documentation
OpenCV color types to which automatic conversions from kuvio_image are supported.
Any one-channel (gray level) color type.
24-bit RGB color type (BGR).
32-bit RGB color type (BGRA).
Constructor & Destructor Documentation
Constructs a cv::Mat that contains a reference to the data in matOrImg, which may be either a kuvio_image or any kuvio_matrix type.
Creates a cv::Mat with the specified color type. If the number of color channels in img is not the same as in colorType, a deep copy of the data in img will be created.
Some (but not all) OpenCV functions assume that the input image has three channels instead of four and throw an error if a four-channel image is used. This is unfortunate as it places the responsibility of choosing the correct number of channels to the caller. This constructor can be used in such situations. It can also automatically convert a gray-level image to RGB and vice versa.
Creates a cv::Mat with the specified OpenCV color type. If the number of color channels in img is not the same as in the target color type, a deep copy of the data in img will be created.
When an OpenCvMat is constructed this way, the temporary copy is automatically copied back to img when the OpenCvMat object goes out of scope. Thus, any modifications made to the temporary image in a function call are propagated to img.