简体   繁体   English

浮点矩阵上的指针被视为* uchar

[英]Pointer on a float matrix is considered as *uchar

I'm trying to iterare trough a cv::Mat with a pointer. 我正在尝试通过指针遍历cv::Mat 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; ). 但是,我在最后一行出现错误( Tout *pointeurOut= oOutput.data; )。

'initializing': cannot convert from 'uchar *' to 'float *' '正在初始化':无法从'uchar *'转换为'float *'

Where does that come from? 那是哪里来的

data is always a uchar* . data 始终是uchar*

You should use 你应该用

oOutput.ptr<Tout>(); 

to get the Tout pointer to the i-th row (by default is the 0-th row, ie the beginning of the image) 获取指向第i行的Tout指针(默认为第0行,即图像的开头)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM