I'm trying to get every circle in a new window, however I get this error; the error
I don't know why that happends. The Rect object gives normal values: rect values
Code:
void scanCircle(int x, int y, int h, Mat src, int rad) {
try {
Rect region = Rect(x, y, x + h, y + h);
Mat roi = src(region).clone();
}
catch (...) {
cout << "Error";
}
}
With Google I found this one: OpenCv assertion failed
However I don't see whats wrong.
The error means that your rectangle region
goes out of the bounds of the image src
.
In fact you're constructing the rectangle with wrong values, it should be:
Rect region(x, y, h, h);
since 3rd and 4th arguments are width and height, not the coordinates of the bottom right point.
Or you can use the constructor that accepts top-left and bottom-right points:
Rect region(Point(x,y), Point(x+h, y+h));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.