Well, I'm new at openCV and image processing and I definitely need help. I need to get every pixel values of the Mat . This image is captured by webcam (real time). I've tried some of the solution from some people's problems, but it's not working on my project. This is some of my code :
Mat blackWhite;
Mat binary;
Mat distanceTr;
cvtColor(frame, blackWhite, CV_BGR2GRAY);
GaussianBlur(blackWhite, blackWhite, Size(15,15), 6.5, 6.5);
threshold(blackWhite, binary, 80, 255, CV_THRESH_BINARY);
Mat invBinary = Scalar(255) - binary;
distanceTransform(invBinary, distanceTr, CV_DIST_L2,3);
And I for the pixel value accessing, I made this :
for(int i = 0; i < distanceTr.rows; i++)
{
for(int j = 0; j < distanceTr.cols; j++)
{
if(distanceTr.at<uchar>(0,0) == 0)
{
cout << 1;
}
}
}
For the webcam show, I use
imshow("Project", distanceTr);
As far as I know, the distanceTr is a grayscale image, so it's a 1-channel image. Based on some answers, I tried the .at<> but it's not working :( I'm doing a test case, if the (0,0) pixel is black, it'll print 1. What I get is an unhandled exception error. Could you give any help, please?
Thank you very much. (Sorry for bad English)
distanceTrandform
is of typeCV_32FC1
, so may be you should do this:if(distanceTr.at<float>(0,0) == 0) cout<<1
– sgarizvi(i,j)
– a-Jays