在這種方法中得四點的原稿板,那麼你可以用下面的方法削減這一形象:
public Bitmap warpDisplayImage(Mat inputMat) {
List<Point> newClockVisePoints = new ArrayList<>();
int resultWidth = inputMat.width();
int resultHeight = inputMat.height();
Mat startM = Converters.vector_Point2f_to_Mat(orderRectCorners(Previes method four poit list(like : List<Point> points)));
Point ocvPOut4 = new Point(0, 0);
Point ocvPOut1 = new Point(0, resultHeight);
Point ocvPOut2 = new Point(resultWidth, resultHeight);
Point ocvPOut3 = new Point(resultWidth, 0);
ocvPOut3 = new Point(0, 0);
ocvPOut4 = new Point(0, resultHeight);
ocvPOut1 = new Point(resultWidth, resultHeight);
ocvPOut2 = new Point(resultWidth, 0);
}
Mat outputMat = new Mat(resultWidth, resultHeight, CvType.CV_8UC4);
List<Point> dest = new ArrayList<Point>();
dest.add(ocvPOut3);
dest.add(ocvPOut2);
dest.add(ocvPOut1);
dest.add(ocvPOut4);
Mat endM = Converters.vector_Point2f_to_Mat(dest);
Mat perspectiveTransform = Imgproc.getPerspectiveTransform(startM, endM);
Imgproc.warpPerspective(inputMat, outputMat, perspectiveTransform, new Size(resultWidth, resultHeight), Imgproc.INTER_CUBIC);
Bitmap descBitmap = Bitmap.createBitmap(outputMat.cols(), outputMat.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(outputMat, descBitmap);
return descBitmap;
}
你什麼錯誤?請同時打印這兩個集合的內容。 – iiro
收藏基本上是向左,向右,bottomright,bottomleft與一個得到的X位置和另一個Y位置,我只是想得到一個粗糙的矩形我想看到的。我使用模板匹配來獲得點,所以我只是使用左上角的點作爲起點,然後使用排序獲得圖像的最長寬度和高度 –
錯誤:斷言失敗(src.dims == 2 && info.height ==(uint32_t)src.rows && info.width ==(uint32_t)src.cols)void Java_org_opencv_android_Utils)_nMatToBitmap2(JNIEnv *,jclass,jlong,jobject,jboolean,file/home/reports/ci/slave/opencv/modules/java/generator/src/cpp/util.cpp,第107行 nMatToBitmap catched cv :: Exception:/home/report/ci/slave/opencv/modules/java/generator/src/utils.cpp:107:error: (-215)src.dims == 2 && info.height ==(uint32_t)src.rows && info.width ==(uint32_t)src.cols在函數中void Java_org)opencv_android_Utils_nMatToBitmap2(KNIENV *,jclass,jlong,jobject,jboolean) –