我有一些代码要从python转换为java才能在我的Android应用程序中使用。
python代码是:
npaROIResized = imgROI.reshape((1, 600))
其中imgROIResized
是一个numpy.ndarray,表示我从图像中找到的轮廓。
我现在尝试的java代码是:
// points is MatOfPoint that I extracted from a contour
Rect rect = Imgproc.boundingRect(points);
// matrixImage is the Mat input image
Mat imgROI = matrixImage.submat(rect);
imgROI.reshape(1, 600);
但我收到了错误:
OpenCV Error: Image step is wrong (The matrix is not continuous,
thus its number of rows can not be changed) in
cv::Mat cv::Mat::reshape(int, int) const, file