error "matrix.cpp, line 322" or bug (Bug #2411)
Hi I am developping using opencv in Android. My program works correctly but sometimes I get this error:
Stitching module's ROI issue (Bug #2385) 10-04 16:03:18.989: E/cv::error()(1150): 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 cv::Mat::Mat(const cv::Mat&, const cv::Rect&), file /home/andreyk/OpenCV/opencv/modules/core/src/matrix.cpp, line 322
10-04 16:03:18.999: E/SurfaceTexture(1150): [unnamed-1150-1] dequeueBuffer: no available buffer slots
10-04 16:03:18.999: E/AndroidRuntime(1150): FATAL EXCEPTION: Thread-133
10-04 16:03:18.999: E/AndroidRuntime(1150): CvException [org.opencv.core.CvException: /home/andreyk/OpenCV/opencv/modules/core/src/matrix.cpp:322: 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 cv::Mat::Mat(const cv::Mat&, const cv::Rect&)
My error seems to be the same king of error than "Stitching module's ROI issue (Bug #2385)". I dont know exactly what part of my code is the origine of this error. I think it is related avec Imgproc.resize but I am not sure. Related to the bug 2385 it seems now it works. But I dont understand if it was a mistake of the code or this is an Opencv error. Anyway is there a known solution for this kind of error? Thanks of your answer
Related issues (Add)
I think the error could be in the next lines of code. My code works correctly during a time. I am not sure if dimlado du code has to be always bigger than 160... etc. I have to debug deeply.
*Mat matrixSelec= matrixRgba.submat(0, dimlado,0, dimlado );//A sub matrix: dimlado is changing
Mat matrixSelec_matrixRgba = matrixRgba.submat(0, 160,0, 160 );
Imgproc.resize(matrixSelec, matrixSelec_mRgba, matrixSelec_matrixRgba.size());//New size: to 160x160
Mat RmatrixSeleccionada = matrixRgba.submat(0, dimlado,0, dimlado );
Mat CRmatrixSeleccionada= new Mat(RmatrixSeleccionada.size(), RmatrixSeleccionada.type());
There is a big matrix. I take a submatrix matrixSelec. Then I reside matrixSelec to a matrix 160x160. And then I copy the result to CRMatrixSeleccionada.
I think I have found the problemm... it was before the code I have shown... I use also a submat function and you are right the size of the submat sometimes is out the big matrix... and consecuently I have a Mat size error... Anyway, taking advantage of the code above,do you think the code to resize the submatrix could be done in a better way? Thanks for your support...