当前位置: 首页>>代码示例>>Java>>正文


Java Imgcodecs.imwrite方法代码示例

本文整理汇总了Java中org.opencv.imgcodecs.Imgcodecs.imwrite方法的典型用法代码示例。如果您正苦于以下问题:Java Imgcodecs.imwrite方法的具体用法?Java Imgcodecs.imwrite怎么用?Java Imgcodecs.imwrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opencv.imgcodecs.Imgcodecs的用法示例。


在下文中一共展示了Imgcodecs.imwrite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void run() {
  System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  String base = "C:/Books in Progress/Java for Data Science/Chapter 10/OpenCVExamples/src/resources";
  CascadeClassifier faceDetector = 
          new CascadeClassifier(base + "/lbpcascade_frontalface.xml");
  
  Mat image = Imgcodecs.imread(base + "/images.jpg");

  MatOfRect faceVectors = new MatOfRect();
  faceDetector.detectMultiScale(image, faceVectors);

  out.println(faceVectors.toArray().length + " faces found");

  for (Rect rect : faceVectors.toArray()) {
      Imgproc.rectangle(image, new Point(rect.x, rect.y), 
              new Point(rect.x + rect.width, rect.y + rect.height), 
              new Scalar(0, 255, 0));
  }
  Imgcodecs.imwrite("faceDetection.png", image);
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:21,代码来源:DetectFaceDemo.java

示例2: smoothImage

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void smoothImage() {
    // Smoothing, also called blurring, will make the edges soother.
    Mat source = Imgcodecs.imread("cat.jpg");
    Mat destination = source.clone();
    for (int i = 0; i < 25; i++) {
        Mat sourceImage = destination.clone();
        Imgproc.blur(sourceImage, destination, new Size(3.0, 3.0));
    }
    Imgcodecs.imwrite("smoothCat.jpg", destination);
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:11,代码来源:OpenCVNonMavenExamples.java

示例3: processStillImage

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
private void processStillImage() {
    Mat mat = Imgcodecs.imread("fly.bmp");
    for (int c = 0; c < mat.width() / 2; c++) {
        for (int r = 0; r < mat.height() / 2; r++) {
            double color[] = mat.get(r, c);
            color[0] = 255;
            mat.put(r, c, color);
            //System.out.printf("(%d, %d) = %s\n", r, c, Arrays.toString(color));
        }
    }
    Imgcodecs.imwrite("fly_new.bmp", mat);

    Mat gray = new Mat();
    Imgproc.cvtColor(mat, gray, Imgproc.COLOR_RGB2GRAY);
    Imgcodecs.imwrite("fly_gray.bmp", gray);
}
 
开发者ID:kmhasan-class,项目名称:fall2017ip,代码行数:17,代码来源:OpenCVTest.java

示例4: imwrite

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static void imwrite(List<Mat> mats, String filePath) {
	FileUtils.isExist(filePath);
	for(int i = 0, len = mats.size(); i < len; i ++) {
		Imgcodecs.imwrite(FileUtils.buildFilePath(filePath, i+".jpg"), mats.get(i));
	}
}
 
开发者ID:IaHehe,项目名称:classchecks,代码行数:7,代码来源:ImgprocessUtils.java

示例5: testDetectManyObject

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
@Test
public void testDetectManyObject() {
	String opencvDLL = "G:/java/JavaProjectRelease/classchecks/src/main/webapp/WEB-INF/dll/x64/opencv_java320.dll";
	System.load(opencvDLL);
	
	String haarcascade = "haarcascade_frontalface_alt.xml";
	
	
	CascadeClassifier cascade = new CascadeClassifier(XMLFilePath + haarcascade);
	
	Mat src = Imgcodecs.imread(imageDir + "/split/14.jpg");
	
	MatOfRect objects = new MatOfRect();
	int scaledWidth = src.width();
	
	DetectObject.detectManyObject(src, cascade, objects, scaledWidth);
	
	Rect [] rects = objects.toArray();
	int i = 0;
	for(Rect r : rects) {
		/*Imgproc.rectangle(src, new Point(r.x-100 , r.y-100 ), 
				new Point(r.x + r.width + 80, 
						r.y + r.height + 80), new Scalar(0, 0, 255), 3);*/
		Imgproc.rectangle(src, r.tl(), 
				r.br(), new Scalar(0, 0, 255), 3);
		/*r.width += 120;
		r.height += 120;
		r.x -= 100;
		r.y -= 100;
		System.out.println(r);
		Mat roi = new Mat(src, r);
		Imgcodecs.imwrite("e:/classchecks/2017417/split/"+i+".jpg", roi);
		i ++;*/
	}
	Imgcodecs.imwrite("e:/classchecks/2017417/dectctManyObject.jpg", src);
	//Imgcodecs.imwrite("e:/classchecks/dectctManyObject.jpg", src);
}
 
开发者ID:IaHehe,项目名称:classchecks,代码行数:38,代码来源:DetectObjectTest.java

示例6: canny

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static void canny(String oriImg, String dstImg, int threshold) {
	System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
	final Mat img = Imgcodecs.imread(oriImg);
	Imgproc.cvtColor(img, img, Imgproc.COLOR_BGR2GRAY);
	//
	Imgproc.Canny(img, img, threshold, threshold * 3, 3, true);
	//
	Imgcodecs.imwrite(dstImg, img);
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:10,代码来源:CannyEdgeDetector.java

示例7: saveImage

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
private static void saveImage(Mat mat,VideoEventData ed,String outputDir){
	String imagePath = outputDir+ed.getCameraId()+"-T-"+ed.getTimestamp().getTime()+".png";
	logger.warn("Saving images to "+imagePath);
	boolean result = Imgcodecs.imwrite(imagePath, mat);
	if(!result){
		logger.error("Couldn't save images to path "+outputDir+".Please check if this path exists. This is configured in processed.output.dir key of property file.");
	}
}
 
开发者ID:baghelamit,项目名称:video-stream-analytics,代码行数:9,代码来源:VideoMotionDetector.java

示例8: noiseRemoval

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void noiseRemoval() {
//        Mat Kernel = cv::Mat(cv::Size(Maximum_Width_of_Noise,Maximum_Height_of_noise),CV_8UC1,cv::Scalar(255));        
        Mat Kernel = new Mat(new Size(3, 3), CvType.CV_8U, new Scalar(255));
        Mat source = Imgcodecs.imread("noiseExample.png");
        Mat temp = new Mat();
        Mat topHat = new Mat();
        Mat destination = new Mat();

        Imgproc.morphologyEx(source, temp, Imgproc.MORPH_OPEN, Kernel);
        Imgproc.morphologyEx(temp, destination, Imgproc.MORPH_CLOSE, Kernel);
//        Imgproc.morphologyEx(temp, topHat, Imgproc.MORPH_GRADIENT, Kernel);
//        Imgproc.morphologyEx(topHat, destination, Imgproc.MORPH_CLOSE, Kernel);
        Imgcodecs.imwrite("noiseRemovedExample.png", source);
    }
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:15,代码来源:OpenCVNonMavenExamples.java

示例9: main

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static void main(String[] args)
{
	System.out.println("Hello, OpenCV");
    // Load the native library.
    System.loadLibrary("opencv_java244");

    VideoCapture camera = new VideoCapture(0);
    camera.open(0); //Useless
    if(!camera.isOpened()){
        System.out.println("Camera Error");
    }
    else{
        System.out.println("Camera OK?");
    }

    Mat frame = new Mat();

    //camera.grab();
    //System.out.println("Frame Grabbed");
    //camera.retrieve(frame);
    //System.out.println("Frame Decoded");

    camera.read(frame);
    System.out.println("Frame Obtained");

    /* No difference
    camera.release();
    */

    System.out.println("Captured Frame Width " + frame.width());

    Imgcodecs.imwrite("camera.jpg", frame);
    System.out.println("OK");
}
 
开发者ID:Plasmoxy,项目名称:AquamarineLake,代码行数:35,代码来源:HelloCV.java

示例10: main

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	final String input = "D:/workspace/SpotSpotter/src/pers/zylo117/spotspotter/image/4.jpg";
	final String output = "D:/workspace/SpotSpotter/src/pers/zylo117/spotspotter/image/output4.jpg";

	System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
	final Mat in = Imgcodecs.imread(input);
	if (in.empty()) {
		throw new Exception("no file");
	}
	final Mat out = LSD(in);
	Imgcodecs.imwrite(output, out);
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:13,代码来源:LineDetector.java

示例11: convertImage

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void convertImage() {
    Mat source = Imgcodecs.imread("cat.jpg");
    // The extension determines the format
    Imgcodecs.imwrite("convertedCat.jpg", source);
    Imgcodecs.imwrite("convertedCat.jpeg", source);
    Imgcodecs.imwrite("convertedCat.webp", source);
    Imgcodecs.imwrite("convertedCat.png", source);
    Imgcodecs.imwrite("convertedCat.tiff", source);
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Made-Easy,代码行数:10,代码来源:OpenCVNonMavenExamples.java

示例12: processarAlgoritmo

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void processarAlgoritmo(String diretorioImagem, String nomeDaImagem) {
    Mat imagemOriginal = Imgcodecs.imread(diretorioImagem, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
    Mat imagemTratada = new Mat(imagemOriginal.rows(), imagemOriginal.cols(), imagemOriginal.type());
    imagemTratada = imagemOriginal;
    Imgproc.adaptiveThreshold(imagemOriginal, imagemTratada, 500, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 11, 1);
    Imgcodecs.imwrite(System.getProperty("user.home") + "/Desktop/" + nomeDaImagem + ".png", imagemTratada);
}
 
开发者ID:nbfontana,项目名称:pdi,代码行数:8,代码来源:AlgoritmoLimiar.java

示例13: log

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
private static void log(String filename, Mat im, int level) {
    filename = baseDir + '/' + filename;
    if (level >= logLevel) {
        Imgcodecs.imwrite(filename, im);
    }
}
 
开发者ID:hgs1217,项目名称:Paper-Melody,代码行数:7,代码来源:ImgLogger.java

示例14: resizeImage

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void resizeImage() {
    Mat source = Imgcodecs.imread("cat.jpg");
    Mat resizeimage = new Mat();
    Imgproc.resize(source, resizeimage, new Size(250, 250));
    Imgcodecs.imwrite("resizedCat.jpg", resizeimage);
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:7,代码来源:OpenCVNonMavenExamples.java

示例15: salvarImagem

import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void salvarImagem(String path, Mat img) {
	Imgcodecs.imwrite(path, img);
}
 
开发者ID:mundodehads,项目名称:cc-unespar,代码行数:4,代码来源:manipulacao.java


注:本文中的org.opencv.imgcodecs.Imgcodecs.imwrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。