Question

I am using Visual Basic 2010 Express, and opencv in c++, and while this line already limits my color to track in the threshold window,

inRange(HSV,Scalar(0,1,170),Scalar(196,137,256),thresholdL);

I am trying to figure out how to also say 'only show pixels(I don't know the proper terminology for it) that lie somewhere from 320 to 640 on the x axis in this threshold window.'

I do have a variable that i use to check the x position, called

int xPos;

but I'm not sure how to take that and funnel the info into my threshold window. Do I modify the line shown? is there a function for this that I just haven't found and can insert underneath? Will I have to set up a whole new class or something?

Thank you in advance.

Was it helpful?

Solution

If you want to work on some specific part of the image OpenCV ROI may help you

You can have something like

Mat HSV; //your source image for inrange
Mat thresholdL//destination image
int xPos= x_starting_point;
int yPos=HSV.rows
width=HSV.cols-xPos;
height=HSV.rows;

cv::Rect roi(xPos, yPos, width, height); // Your ROI rectangle
//Set image ROI
cv::Mat image_roi = HSV(roi);// note: this assignment does not copy data,HSV and image_roi now share data
//Perform your operation
inRange(image_roi,Scalar(0,1,170),Scalar(196,137,256),thresholdL);

// Now dislpay
imshow("out",HSV);

Hope these helpful for you...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top