Ask Your Question

Revision history [back]

OpenCV Error: Assertion failed in matrix.cpp line 522, /matrix.cpp:522: error: (-215)

I am trying to create an ROI above the face detected to place a hat like shown in the image, click here to see the image: The ROI is created above the detected face

I have made sure that the ROI created is withing the bounds of the image. It looks like this:

if (0<=face.x && 0<=face.x-face.width0.08<=image.cols && 0<=face.x+face.width+face.width0.08<=image.cols && 0<=face.y && 0<=face.y-face.height0.28<=image.rows) { Mat ROI_hat = image(Rect(abs(face.x-face.width0.08),abs(face.y-face.height0.28),abs(face.x+face.width+face.width0.08),abs(face.y))); rectangle(image,Point(abs(face.x-face.width0.08),abs(face.y-face.height0.28)),Point(abs(face.x+face.width+face.width*0.08),abs(face.y)),Scalar(255, 0, 0), 1, 4); cout<<"Within the bounds of Image"<<endl; }="" else{="" cout&lt;&lt;"="" out="" of="" bounds="" of="" image="" "&lt;<endl;="" }<="" p="">

There are no negative values and for every frame it says ROI is withing the bounds. But I still get assertion error: OpenCV 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 Mat, file /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp, line 522 terminate called after throwing an instance of 'cv::Exception' what(): /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp:522: error: (-215) 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 function Mat Aborted (core dumped)

Can someone please help me ??

OpenCV Error: Assertion failed in matrix.cpp line 522, /matrix.cpp:522: error: (-215)

I am trying to create an ROI above the face detected to place a hat like shown in the image, click here to see the image: The ROI is created above the detected face

I have made sure that the ROI created is withing the bounds of the image. It looks like this:

if (0<=face.x && 0<=face.x-face.width0.08<=image.cols && 0<=face.x+face.width+face.width0.08<=image.cols && 0<=face.y && 0<=face.y-face.height0.28<=image.rows) { Mat ROI_hat = image(Rect(abs(face.x-face.width0.08),abs(face.y-face.height0.28),abs(face.x+face.width+face.width0.08),abs(face.y))); rectangle(image,Point(abs(face.x-face.width0.08),abs(face.y-face.height0.28)),Point(abs(face.x+face.width+face.width*0.08),abs(face.y)),Scalar(255, 0, 0), 1, 4); cout<<"Within the bounds of Image"<<endl; }="" else{="" cout&lt;&lt;"="" out="" of="" bounds="" of="" image="" "&lt;<endl;="" }<="" p="">

There are no negative values and for every frame it says ROI is withing the bounds. But I still get assertion error: OpenCV 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 Mat, file /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp, line 522 terminate called after throwing an instance of 'cv::Exception' what(): /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp:522: error: (-215) 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 function Mat Aborted (core dumped)

Can someone please help me ??the roi is created above face detected

OpenCV Error: Assertion failed in matrix.cpp line 522, /matrix.cpp:522: error: (-215)

I am trying to create an ROI above the face detected to place a hat like shown in the image, click here to see the image: The ROI is created above the detected face

I have made sure that the ROI created is withing the bounds of the image. It looks like this:

if (0<=face.x && 0<=face.x-face.width0.08<=image.cols && 0<=face.x+face.width+face.width0.08<=image.cols && 0<=face.y && 0<=face.y-face.height0.28<=image.rows) { Mat ROI_hat = image(Rect(abs(face.x-face.width0.08),abs(face.y-face.height0.28),abs(face.x+face.width+face.width0.08),abs(face.y))); rectangle(image,Point(abs(face.x-face.width0.08),abs(face.y-face.height0.28)),Point(abs(face.x+face.width+face.width*0.08),abs(face.y)),Scalar(255, 0, 0), 1, 4); cout<<"Within the bounds of Image"<<endl; }="" else{="" cout&lt;&lt;"="" out="" of="" bounds="" of="" image="" "&lt;<endl;="" }<="" p="">

There are no negative values and for every frame it says ROI is withing the bounds. But I still get assertion error: OpenCV 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 Mat, file /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp, line 522 terminate called after throwing an instance of 'cv::Exception' what(): /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp:522: error: (-215) 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 function Mat Aborted (core dumped)

Can someone please help me ??the roi is created above face detected

click to hide/show revision 4
No.4 Revision

updated 2017-03-31 09:06:09 -0600

berak gravatar image

OpenCV Error: Assertion failed in matrix.cpp line 522, /matrix.cpp:522: error: (-215)

I am trying to create an ROI above the face detected to place a hat like shown in the image, click here to see the image: The ROI is created above the detected face

I have made sure that the ROI created is withing the bounds of the image. It looks like this:

if (0<=face.x && 0<=face.x-face.width0.08<=image.cols && 0<=face.x+face.width+face.width0.08<=image.cols 0<=face.x-face.width*0.08<=image.cols && 0<=face.x+face.width+face.width*0.08<=image.cols 
&& 0<=face.y && 0<=face.y-face.height0.28<=image.rows)
0<=face.y-face.height*0.28<=image.rows)
 {
Mat ROI_hat = image(Rect(abs(face.x-face.width0.08),abs(face.y-face.height0.28),abs(face.x+face.width+face.width0.08),abs(face.y)));
rectangle(image,Point(abs(face.x-face.width0.08),abs(face.y-face.height0.28)),Point(abs(face.x+face.width+face.width*0.08),abs(face.y)),Scalar(255, image(Rect(abs(face.x-face.width*0.08),abs(face.y-face.height*0.28),abs(face.x+face.width+face.width*0.08),abs(face.y)));
rectangle(image,Point(abs(face.x-face.width*0.08),abs(face.y-face.height*0.28)),Point(abs(face.x+face.width+face.width*0.08),abs(face.y)),Scalar(255, 0, 0), 1, 4);
cout<<"Within the bounds of Image"<<endl; }="" else{="" cout&lt;&lt;"="" out="" of="" bounds="" of="" image="" "&lt;<endl;="" }<="" p="">

Image"<<endl; } else{ cout<<" Out of bounds of Image "<<endl; }

There are no negative values and for every frame it says ROI is withing the bounds. But I still get assertion error:

OpenCV 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 Mat, file /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp, line 522 terminate called after throwing an instance of 'cv::Exception' what(): /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp:522: error: (-215) 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 function Mat Aborted (core dumped)

dumped)

Can someone please help me ??the roi is created above face detected

click to hide/show revision 5
No.5 Revision

updated 2017-03-31 09:08:22 -0600

berak gravatar image

OpenCV Error: Assertion failed in matrix.cpp line 522, /matrix.cpp:522: error: (-215)

I am trying to create an ROI above the face detected to place a hat like shown in the image, click here to see the image: The ROI is created above the detected face

I have made sure that the ROI created is withing the bounds of the image. It looks like this:

if (0<=face.x && 0<=face.x-face.width*0.08<=image.cols && 0<=face.x+face.width+face.width*0.08<=image.cols 
         && 0<=face.y && 0<=face.y-face.height*0.28<=image.rows)
    {
      Mat ROI_hat = image(Rect(abs(face.x-face.width*0.08),abs(face.y-face.height*0.28),abs(face.x+face.width+face.width*0.08),abs(face.y)));
      rectangle(image,Point(abs(face.x-face.width*0.08),abs(face.y-face.height*0.28)),Point(abs(face.x+face.width+face.width*0.08),abs(face.y)),Scalar(255, 0, 0), 1, 4);
      cout<<"Within the bounds of Image"<<endl;
    }
    else{
     cout<<" Out of bounds of Image "<<endl;
        }

There are no negative values and for every frame it says ROI is withing the bounds. But I still get assertion error:

OpenCV 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 Mat, file /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp, line 522 terminate called after throwing an instance of 'cv::Exception' what(): /home/user/OpenCV_Installed/opencv-3.2.0/modules/core/src/ma‌​trix.cpp:522: error: (-215) 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 function Mat Aborted (core dumped)

Can someone please help me ??the roi is created above face detected