Friday, April 8, 2011

Change Array type in OpenCV

Most of the operations in OpenCV require the arrays to be of same type (CV_32FC1 or CV_8U or CV_8S, etc).

Btw, My other programs in OpenCV will be posted here

If you try to operate cvAdd or cvMul, etc on different array types, it would result in compilation error.

In order to change type, one must use
cvConvertScale(CvMat* src, CvMat* dst, double scale, double shift);


src-> source array (with you source type).
dst-> Destination array (with you destination type).


Then the operations. In Matlab it can be achieved quite simply like:
im=double(im);


But cvConvertScale seems to be the only way of changing the type of array in OpenCV

No comments:

Post a Comment