The OpenCV function cvtColor converts the color space of a matrix (e.g. from RGB to grayscale). The function's C++ signature is
void cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0 )
Can this function be used convert a matrix in place, i.e. with src
the same object as dst
?
cv::Mat mat = getColorImage();
cvtColor(mat, mat, CV_RGB2GRAY);
(I'm aware that either way, as the destination has a different number of channels than the source, it will still need to allocate a new block of memory for the destination.)
More generally, is there a convention within the OpenCV API to determine when a function may be used in this way?