in the lower code section I want to blur the rectangles of a face recognition with the help of the function Gaussianblur(frame(roi)).
void drawPred(int classId, float conf, int left, int top, int right, int bottom, Mat& frame)
{
//Draw a rectangle displaying the bounding box
rectangle(frame, Point(left, top), Point(right, bottom), Scalar(255, 178, 50),LINE_4);
//Bluring RoI
Point leftTop = Point(left, top);
Point rightBottom = Point(right, bottom);
Rect roi = Rect(leftTop, rightBottom);
GaussianBlur(frame(roi), frame(roi), Size(5, 5),0);
//Get the label for the class name and its confidence
string label = format("%.2f", conf);
if (!classes.empty())
{
CV_Assert(classId < (int)classes.size());
label = classes[classId] + ":" + label;
}
//Display the label at the top of the bounding box
int baseLine;
Size labelSize = getTextSize(label, FONT_ITALIC, 0.5, 1, &baseLine);
top = max(top, labelSize.height);
putText(frame, label, Point(left, top), FONT_ITALIC, 0.5, Scalar(255, 255, 255), 1);
}
Successfully I am able to execute this code for around 10-15 frames, later at a certain point the code crashes abruptly with the lower error.
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(3.4.5) Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in cv::Mat::Mat,
file c:\build\3_4_winpack-build-win64-vc15\opencv\modules\core\src\matrix.cpp, line 466
I don't understand what it means and unfortunately don't know how to solve it because my C++ experience isn't good enough. It would help me a lot if you could show me some little tips.
Many thanks and many greetings