Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Video element access

Hi,

I am a newbie opencv user, and I wanted to ask how to access the elements of a Mat. This question has been answered before, I am pasting the answer to this which was answered before which is:

You can use template version of Mat:

Mat_<vec3b> bgrMat; bgrMat(y, x) = Vec3b(0,0,0); Vec3b* row = bgrMat[y] // pointer to mat row

However, for this I have to create a template version on Mat. However, I am trying to work on a video streaming problem where I want to operate on 2D images from a video stream as below:

Mat edges;
namedWindow("edges",1);
for(;;)
{
    Mat frame;
    cap >> frame;
    ............ //work on frame element by element.

}

I guess i cant use the template version of Mat in this case. I tried using it and I got compiler errors. I also, tried to follow what was given in the documentation that I can refer to the Mat elements using the .at() function provided I know the type, which I did not know. I tried to use the type() function for that, which returned the value 16 which I was not trying to interpret. The documentation only says type() can be used as in the previous versions with IplImage or CvMat, and assumes the user is acquainted with the older versions of opencv, but unfortunately i am not.

-Bharath