Ask Your Question
0

Question of using CV::MatConstIterator

asked 2018-03-06 07:19:41 -0600

Weifa Gan gravatar image

updated 2018-03-06 07:57:51 -0600

berak gravatar image

I am new learner for opencv,so i wan to ask some question about it. I type some codes, which can find in the book learning opencv3 ,but error has occur when i use the CV::MatConstlerator. The error is that it is not contain a list of template parameters .It make me confused. Pleace help to understand.Thank you very much.

codes are as followed:

#include"iostream"
#include"opencv2/core/core.hpp"
#include"opencv2/highgui/highgui.hpp"

using namespace std;
using namespace cv;
int main()
{

    int sz[3] = { 4,4,4 };
    Mat m(3, sz, CV_32FC3);
    randu(m, -1.0f, 1.0f);

    float mat = 0.0f;
    MatConstIterator<Vec3f>it = m.begin();



    system("pause");
}
edit retag flag offensive close merge delete

Comments

1

thank you for the edit !

the error message is ?

berak gravatar imageberak ( 2018-03-06 07:40:47 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-03-06 08:39:10 -0600

berak gravatar image

looks like a typo, it should be: MatConstIterator_ (with a final underscore)

MatConstIterator_<Vec3f> it = m.begin<Vec3f>();
for (; it != m.end<Vec3f>(); it++) {
     // do something with *it, but remember it's const, read-only !
}
edit flag offensive delete link more

Comments

Yeah.Thank you very much! how do you know typo? and MatConstIterator_<vec3f> it = m.begin<vec3f>() what means? - List item

Weifa Gan gravatar imageWeifa Gan ( 2018-03-06 23:20:43 -0600 )edit

because i looked up the docs .

berak gravatar imageberak ( 2018-03-07 02:35:21 -0600 )edit

thanks your guidance!

Weifa Gan gravatar imageWeifa Gan ( 2018-03-07 02:50:44 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-03-06 07:19:41 -0600

Seen: 226 times

Last updated: Mar 06 '18