user2758510
user2758510

Reputation: 159

error in using Mat type in opencv

How can I search into a Mat type in opencv to find some spesific value?

This is what I have done until now:

Mat L;

for(int i=0; i<height; i++){
for(int j=0; j<width; j++){
    if( L[i][j]> 0){
       Index.push_back(std::make_pair(i,j));
    }
   }
}

Upvotes: 0

Views: 184

Answers (1)

berak
berak

Reputation: 39806

L[i][j] is invalid, as you probably found out already ;)

you have to know the type of the Mat to access its elements:

Mat L(8,8,CV_8U);
uchar elm = L.at<uchar>(i,j);

alternatively, there's

Mat_<uchar> L(8,8);
uchar elm = L(i,j);

Upvotes: 1

Related Questions