Olivier Grech Olivier Grech - 17 days ago 4
C++ Question

Pointer on a float matrix is considered as *uchar

I'm trying to iterare trough a

with a pointer.
So I did the following in my function:

template<typename Tin=uchar,typename Tout=float>
inline cv::Mat_<Tout> dct(const cv::Mat_<Tin>& oBlock) {

cv::Mat_<Tout> oOutput(oBlock.size());
Tout *pointeurOut= oOutput.data;


However, I'm getting an error at the last line (
Tout *pointeurOut= oOutput.data;

'initializing': cannot convert from 'uchar *' to 'float *'

Where does that come from?


data is always a uchar*.

You should use


to get the Tout pointer to the i-th row (by default is the 0-th row, i.e. the beginning of the image)