2014-10-07 94 views
0

我有一個由opencv + java + android繪製的矩形。現在我需要裁剪並顯示在我的imagviwe中如何裁剪它。子方法只允許int值。但是rect.tl().x值是雙倍的。鑄造不是一個好的解決方案。它會犯錯誤。如何使用android在opencv中裁剪圖像

Core.rectangle(ImageMatin, rect.tl(), rect.br(), new Scalar(255, 0, 0),1); // works Mat cropped = ImageMatin.submat(rect.tl().x, rect.height, rect.tl().x, rect.width); //error

+0

我覺得你可以試試cropimage庫.https://github.com/biokys/cropimage – LvN 2014-10-07 10:10:54

回答

0

我推薦這個庫從GitHub:https://github.com/edmodo/cropper,它甚至有一個樣品,所以如果你卡住你可以隨時參考。另外這個庫是非常適合種植的目的和輕便爲好,我自己有一個或兩個應用程序

用它
0

您可以通過底肥此命令農作物墊圖片:

Mat croppedImg = new Mat (sourceMat, ROI);