Error assertion roi failed
I have an image 640x480 and i need to extract a submatrix with this roi: x="216" y="107" width="423" height="255". I try to this:
Mat frame = imread(path + fileName);
vector<KeyPoint> keyPoint = vector<KeyPoint>();
if (!frame.empty())
{
//prendo il punto del frame dell'evento interessato
int width = itc->width;
int height = itc->height;
int x = itc->x;
int y = itc->y;
Mat bbox = Mat(frame,Rect(itc->x, itc->y, itc->x + itc->width, itc->y + itc->height));
but i have this exception :
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
where is the error? can you help me?