Mat::不在OpenCV中工作的

Mat::ones not working in OpenCV

本文关键字:工作 OpenCV 不在 Mat      更新时间:2023-10-16
int main () {    
    Mat A = Mat::ones(100, 100, CV_8U)*3;
    cout << A.at<int>(0,0) << endl;
    return 0;
}

输出是一个非常大的数字::50529027

有人能帮我吗??C++代码

you're casting to the wrong type in A.at<int>() // should be uchar instead of int
so, A.at<int>(0,0) sees 0x03030303, which is, in fact 50529027.
Mat A = Mat::ones(100, 100, CV_8U)*3;
cout << int(A.at<uchar>(0,0)) << endl;

(A.at((周围的强制转换只是显示一个带有cout而不是char的数字(