First time here? Check out the FAQ!

Ask Your Question
1

Matrix access isn't working correct

asked Apr 2 '13

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

Preview: (hide)

1 answer

Sort by » oldest newest most voted
3

answered Apr 2 '13

Daniil Osokin gravatar image

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

Preview: (hide)

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 (Apr 2 '13)edit
1

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

Daniil Osokin gravatar imageDaniil Osokin (Apr 2 '13)edit

Question Tools

Stats

Asked: Apr 2 '13

Seen: 433 times

Last updated: Apr 02 '13