Error setting ROI OpenCV Android

一笑奈何 提交于 2019-11-29 11:45:24

OpenCV for Android (and the new Java API) has its own way to create ROI's.

All you have to do is to call the submat method of your Mat object. If I am not mistaken, calling submat does not create a copy of that image region, if you want a copy you can use copyTo on the submat for that purpose.

Mat roi = inputFrame.submat(rowStart, rowEnd, colStart, colEnd);

You can call submat in 3 different ways, check the links for more details:

  • submat(int rowStart, int rowEnd, int colStart, int colEnd)

submat 1

  • submat(Range rowRange, Range colRange)

submat 2

  • submat(Rect roi)

submat 3

The error is stating that you are trying to set a ROI with the same dimensions of the image, so there's no need for a ROI in this case.

To make sure this is the problem, the following should work:

Rect roi = new Rect(0, 0, inputFrame.cols() - 1, inputFrame.rows() - 1);
Mat cropped = new Mat(inputFrame, roi);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!