Ask Your Question
1

Matrix access isn't working correct

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

I have the following code snippet

Mat label_features(10,1,CV_8UC1);

for(int i = 0; i < 10; i++){
    label_features.at<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
3

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

Daniil Osokin gravatar image

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

edit flag offensive delete link more

Comments

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 -0600 )edit
1

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

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

Question Tools

Stats

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

Seen: 399 times

Last updated: Apr 02 '13