Ask Your Question

Matrix access isn't working correct

asked 2013-04-02 04:53:48 -0500

I have the following code snippet

Mat label_features(10,1,CV_8UC1);

for(int i = 0; i < 10; i++){<int>(i,0) = 1;

For some reason, this gives a problem when creating and adding values to the matrix. Please ignore the fact that I am adding a '1' value here. It could basically be any value between 0 and 255.

Anyone can tell me why i get the following violation?

image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-04-02 05:05:09 -0500

Daniil Osokin gravatar image

Hi, Steven! For CV_8UC1 type you should use Mat::at<uchar>.

edit flag offensive delete link more


This actually solved my problem :) Thanks. If I want to use int as iterator, what CV type do I instantiate a matrix with then?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-02 05:45:00 -0500 )edit

For Mat of CV_32SC1 type should be used Mat::at<int>.

Daniil Osokin gravatar imageDaniil Osokin ( 2013-04-02 06:26:50 -0500 )edit

Question Tools


Asked: 2013-04-02 04:53:48 -0500

Seen: 206 times

Last updated: Apr 02 '13