# How can define a region of interest in empty parking spaces?

Hello I have a small problem with my code. I have made the full code to identify a region of interest.I have a small static camera which capture empty parking spaces. I need define a static region of the interest, when the camera captures the first image, define the place of interest.

void regionOfInterest(Mat& frame){

Mat hsvImage;
cvtColor(frame,hsvImage,COLOR_RGB2HSV);
vector<Mat>HSV_CHANNELS;
split(hsvImage, HSV_CHANNELS);

Mat hueImage = HSV_CHANNELS[0];
inRange(hueImage, hueValue - hueRange, hueValue + hueRange, hueMask);

if (hueValue - hueRange < 0 || hueValue + hueRange > 180){
int upperHueValue = hueValue + 180;
inRange(hueImage, upperHueValue - hueRange, upperHueValue + hueRange, hueMaskUpper);
}
Mat saturationMask = HSV_CHANNELS[1] > minSaturation;
Mat valueMask = HSV_CHANNELS[2] > minValue;

vector<Vec4i> lines;
HoughLinesP(hueMask, lines, 1, CV_PI/360, 50, 50, 10);

for (unsigned int i = 0; i < lines.size(); ++i){
Point(lines[i][0], lines[i][1]);
Point(lines[i][2], lines[i][3]);
}
vector<Point>pts;
for(unsigned int i = 0; i < lines.size(); i++){
pts.push_back(Point(lines[i][0],lines[i][1]));
pts.push_back(Point(lines[i][2],lines[i][3]));

}
/*GET THE PREVIOUS POINTS DETECTED IN THE IMAGE*/
Rect box = boundingRect(pts);
/*DRAW RECTANGLE REGION OF INTEREST*/
rectangle(frame, box.tl(), box.br(), Scalar(0, 255, 0), 2); }


edit retag close merge delete

1