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

asked 2019-05-26 14:26:27 -0500

biza gravatar image

updated 2019-05-29 16:53:21 -0500

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];
Mat hueMask;
inRange(hueImage, hueValue - hueRange, hueValue + hueRange, hueMask);

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

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); }

image description

edit retag flag offensive close merge delete

Comments

1

I must admin I do not understand what your problem is.

Witek gravatar imageWitek ( 2019-05-27 06:12:20 -0500 )edit

Can you post image(both car and empty space too)

supra56 gravatar imagesupra56 ( 2019-05-28 08:25:37 -0500 )edit

I only see one good empty parking spot on top. Unfortunately, this not going to help me. Too many cars. You need to take 2 or more pictures.... before and after.

supra56 gravatar imagesupra56 ( 2019-05-31 08:22:41 -0500 )edit