Trying to determine value of pixels found at certain coordinates [closed]

asked 2017-06-21 13:15:09 -0600

sfdsjkb gravatar image

updated 2017-06-21 16:50:25 -0600

So I found coordinates of pixels based on blob detection, and I need to determine whether or not these pixels are within a certain hsv range. I have done this before with nested for loops successfully, but I can't figure out how to feed the pixels both coordinates instead of just going through every single pixel in the picture.

vector<Point2f> coor;
//populate vector
Vec3b* hsv = output.ptr<Vec3b>(img.rows, img.cols);
for(int I = 0; I < coor.size(); I++) {
   Point2f j = coor[I];
   uchar h = hsv[j][2];
   uchar s = hsv[j][1];
   uchar v = hsv[j][0];
   //check ranges
}

My errors basically just say there's no match for these operands (related to the j). I have had no luck with google or my own ideas.

Update: I have fixed it. Proper context is:

int h = img.at<Vec3b>(j.y, j.x).val[2];
int s = img.at<Vec3b>(j.y, j.x).val[1];
int v = img.at<Vec3b>(j.y, j.x).val[0];
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2017-06-21 20:27:13.328097

Comments

you cannot index a pointer value with a (2d) point (that's a plain c++ problem, not an opencv one)

berak gravatar imageberak ( 2017-06-21 13:19:20 -0600 )edit

again, not an opencv problem, but simply lack of proramming skill

use: output.at<Vec3b>(j) instead.

berak gravatar imageberak ( 2017-06-21 13:23:21 -0600 )edit

Tried that, and I'm not getting any values.

sfdsjkb gravatar imagesfdsjkb ( 2017-06-21 15:47:24 -0600 )edit

also: output.ptr<Vec3b>(img.rows, img.cols); points outside your image.

berak gravatar imageberak ( 2017-06-21 20:28:05 -0600 )edit