|template<class T >|
|OpenCvMat(const T* matOrImg)|
|OpenCvMat(const va_image* img, ColorType colorType)|
|OpenCvMat(va_image* img, ColorType colorType)|
A class that wraps a va_image or a va_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.
- OpenCV's cv::Mat class 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 va_image or va_matrix if unsure.
Member Enumeration Documentation
OpenCV color types to which automatic conversions from va_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 va_image or any va_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.