Ask Your Question
0

error: no matching member function for call to 'at'

asked 2019-01-17 03:53:57 -0600

mikeitexpert gravatar image

I have this ridiculously simple example ... but It doesn't compile ...

I must be making a stupid mistake.

I am new to C++ opencv ... any clue is much appreciate it.

include <qcoreapplication>

include <opencv2 opencv.hpp="">

int main(int argc, char *argv[])
{
    cv::Mat objp = cv::Mat::zeros( 10, 3 , CV_32FC1);
    //        objp[:,:2] = np.mgrid[0:7,0:6].T.reshape(-1,2)
    for(int i = 0; i < objp.size[0]; i++){
        objp.at<CV_32FC1>(0, 0) = 0;
    }

    std::cout << "I am done";
}

/home/mike/Downloads/TestOpecv/main.cpp:9: error: no matching member function for call to 'at'

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-01-17 04:01:07 -0600

berak gravatar image

you have to use the actual type, not a symbolic integer constant :

objp.at<float>(y,x); // for a single float channel image (CV_32FC1)
objp.at<Vec3b>(y,x); // for 3, uchar channels (CV_8UC3, the most common format here)

please have another look at the tutorials

edit flag offensive delete link more

Comments

1

also, just saying: if you catch yourself using at(), -- with 95% probability you should NOT do it like this !

e.g. to set a Mat to 0, you'd just use: mat=0; , without any loops or problematic per pixel access.

berak gravatar imageberak ( 2019-01-17 04:11:09 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-01-17 03:53:57 -0600

Seen: 6,014 times

Last updated: Jan 17 '19