import java.util.ArrayList;
import java.util.List;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.MatOfPoint2f;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class ImageOpencv {
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat src = Imgcodecs.imread("E:/work/qqq/a9.jpg");
Imgcodecs.imwrite("E:/work/qqq/hh1.jpg", removeBackground(src));
Mat src2 = Imgcodecs.imread("E:/work/qqq/a3.jpg");
Imgcodecs.imwrite("E:/work/qqq/hh2.jpg", MyThresholdHsv(src2));
Mat src3 = Imgcodecs.imread("E:/work/qqq/e1.jpg");
Imgcodecs.imwrite("E:/work/qqq/hh3.jpg", myGrabCut(src3, new Point(50,0),new Point(300, 250)));
Mat src4 = Imgcodecs.imread("E:/work/qqq/dd.jpg");
Imgcodecs.imwrite("E:/work/qqq/hh4.jpg", MyFindLargestRectangle(src4));
Mat src5 = Imgcodecs.imread("E:/work/qqq/dd.jpg");
Imgcodecs.imwrite("E:/work/qqq/hh5.jpg", MyWatershed(src5));
Mat src6 = Imgcodecs.imread("E:/work/qqq/e1.jpg");
Imgcodecs.imwrite("E:/work/qqq/hh6.jpg", MyCanny(src6, 100));
SkinDetection sd= new SkinDetection(Imgcodecs.imread("E:/work/qqq/e1.jpg"));
Imgcodecs.imwrite("E:/work/qqq/hh7.jpg",sd.GetSkin());
}
// threshold根据反差去掉深色单色背景
public static Mat removeBackground(Mat nat) {
Mat m = new
OpenCV几种常用的切割方法
最新推荐文章于 2024-07-29 16:00:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)