opencv java:图像的读取与保存

import org.opencv.core.*;
import org.opencv.imgcodecs.*;
import org.opencv.imgproc.Imgproc;

public class ReadAndWrite {
	public static void main(String[] args) {
		//加载opencv
		System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
		
		String src = "d:/Java/opencv/example.jpg";
		//读取图像
		Mat srcImage = Imgcodecs.imread(src);
		//读取灰度图像
		srcImage = Imgcodecs.imread(src, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
		
		Mat dstImage = srcImage.clone();
		//保存图像
		Imgcodecs.imwrite("d:/Java/opencv/example_write.jpg", dstImage);
	}
}

你可能感兴趣的:(opencv,java,图像识别)