Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can define the follwing ROI?

Hello I have a small problem with my code. I have made the full code to identify a region of interest, but the big problem is .. I have a small static camera who capture empty parking spaces. I need define a static region of the interest, when the camera captures the first image, define the places of interest. The problem I have in my code is I call the function "regionOfInterest()" inside a while loop.

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

How can define the follwing ROI?

Hello I have a small problem with my code. I have made the full code to identify a region of interest, but the big problem is .. I interest.I have a small static camera who which capture empty parking spaces. I need define a static region of the interest, when the camera captures the first image, define the places place of interest. The problem I have in my code is I call the function "regionOfInterest()" inside a while loop.

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

How can define the follwing ROI?

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

How can define the follwing ROI?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];
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); }

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];
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