當前位置: 首頁>>代碼示例>>Java>>正文


Java Highgui.imwrite方法代碼示例

本文整理匯總了Java中org.opencv.highgui.Highgui.imwrite方法的典型用法代碼示例。如果您正苦於以下問題:Java Highgui.imwrite方法的具體用法?Java Highgui.imwrite怎麽用?Java Highgui.imwrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.opencv.highgui.Highgui的用法示例。


在下文中一共展示了Highgui.imwrite方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: btnTomarFotoActionPerformed

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
private void btnTomarFotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTomarFotoActionPerformed
    // TODO add your handling code here:
    FileNameExtensionFilter filtro = new FileNameExtensionFilter("Formatos de Archivo JPEG(*.JPG;*.JPEG)","jpg","jpeg");
    jFileChooser1.addChoosableFileFilter(filtro);
    jFileChooser1.setFileFilter(filtro);
    File Nombre =new File(txtNombre.getText()+" "+txtApellido.getText()+".jpg");
    jFileChooser1.setSelectedFile(Nombre);
    jFileChooser1.setDialogTitle("Guardar Imagen");
    File ruta = new File("C:/Imagenes");
    jFileChooser1.setCurrentDirectory(ruta);
   int returnVal = jFileChooser1.showSaveDialog(null);
    if (returnVal == jFileChooser1.APPROVE_OPTION) {
    File file = jFileChooser1.getSelectedFile();
    Highgui.imwrite(file.getPath(), frame);
} else {
    System.out.println("File access cancelled by user.");
}
}
 
開發者ID:JuanJoseFJ,項目名稱:ProyectoPacientes,代碼行數:19,代碼來源:JDIngresarPaciente.java

示例2: main

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
/**
 * Command-line interface.
 * 
 * <p>This example tests the OpenCV installation
 * and takes a picture with this OpenCV tool.</p>
 * 
 * @param args unused here.
 */
public static void main(String[] args) {
    // Load the native library.
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    Tools.log(Core.NATIVE_LIBRARY_NAME);
    VideoCapture camera = new VideoCapture(0);
    Tools.sleepMilliseconds(1000);
    
    if(!camera.isOpened())
        Tools.log("Video capturing hasn't been correctly initialized.");
    else
        Tools.log("The camera has been correctly initialized.");
    
    Mat frame = new Mat();
    camera.read(frame);
    Highgui.imwrite("capture.jpg", frame);
}
 
開發者ID:Raspoid,項目名稱:raspoid,代碼行數:25,代碼來源:TestOpenCVInstallation.java

示例3: main

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
public static void main(String[] args) {
	
	// ָ��������ͼƬ·����������ļ�
    String inputImagePath = identificate.class.getClassLoader().getResource("hf.jpg").getPath().substring(1);
    String outputImageFile = "identificate.png";
    
    String xmlPath = identificate.class.getClassLoader().getResource("cascade_storage.xml").getPath().substring(1);
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    CascadeClassifier faceDetector = new CascadeClassifier(xmlPath);
    Mat image = Highgui.imread(inputImagePath);
    MatOfRect faceDetections = new MatOfRect();
    faceDetector.detectMultiScale(image, faceDetections);
    
    // ���������
    for (Rect rect : faceDetections.toArray()) {
        Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 0, 255));
    }

    // д�뵽�ļ�
    Highgui.imwrite(outputImageFile, image);
    
    System.out.print("\nOK!");
}
 
開發者ID:nthf,項目名稱:yourface,代碼行數:24,代碼來源:identificate.java

示例4: preProcessFrame

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
public Mat preProcessFrame(final Mat mat) {
	if (mat.channels() == 1) return mat.clone();

	final Mat newMat = new Mat(mat.rows(), mat.cols(), CvType.CV_8UC1);

	Imgproc.cvtColor(mat, newMat, Imgproc.COLOR_BGR2GRAY);

	if (logger.isTraceEnabled()) {
		String filename = String.format("grayscale.png");
		final File file = new File(filename);
		filename = file.toString();
		Highgui.imwrite(filename, newMat);
	}

	return newMat;
}
 
開發者ID:phrack,項目名稱:ShootOFF,代碼行數:17,代碼來源:AutoCalibrationManager.java

示例5: blankRotatedRect

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
private void blankRotatedRect(Mat mat, final RotatedRect rect) {
	final Mat tempMat = Mat.zeros(mat.size(), CvType.CV_8UC1);

	final Point points[] = new Point[4];
	rect.points(points);
	for (int i = 0; i < 4; ++i) {
		Core.line(tempMat, points[i], points[(i + 1) % 4], new Scalar(255, 255, 255));
	}

	final Mat tempMask = Mat.zeros((mat.rows() + 2), (mat.cols() + 2), CvType.CV_8UC1);
	Imgproc.floodFill(tempMat, tempMask, rect.center, new Scalar(255, 255, 255), null, new Scalar(0, 0, 0),
			new Scalar(254, 254, 254), 4);

	if (logger.isTraceEnabled()) {
		String filename = String.format("poly.png");
		final File file = new File(filename);
		filename = file.toString();
		Highgui.imwrite(filename, tempMat);
	}

	mat.setTo(new Scalar(0, 0, 0), tempMat);
}
 
開發者ID:phrack,項目名稱:ShootOFF,代碼行數:23,代碼來源:AutoCalibrationManager.java

示例6: LoadImage

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
public LoadImage(String imgStr,Mat m) {

	Highgui.imwrite(imgStr,m);
	JFrame frame = new JFrame("My GUI");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	 
	frame.setResizable(true);
	frame.setLocationRelativeTo(null);
	 
	// Inserts the image icon
	ImageIcon image = new ImageIcon(imgStr);
	frame.setSize(image.getIconWidth()+10,image.getIconHeight()+35);
	// Draw the Image data into the BufferedImage
	JLabel label1 = new JLabel(" ", image, JLabel.CENTER);
	frame.getContentPane().add(label1);
	 
	frame.validate();
	frame.setVisible(true);}
 
開發者ID:Spartronics4915,項目名稱:2015-Recycle-Rush,代碼行數:19,代碼來源:LoadImage.java

示例7: main

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
public static void main(String[] args) {
	System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
	
	String imagePath = "C:\\Users\\admin\\Desktop\\a.png";
	
	FaceDetector faceDetector = new FaceDetector();
	Mat[] mats = faceDetector.snipFace(imagePath, new Size(90, 90));
	
	int i=0;
	for(Mat mat: mats){
		Highgui.imwrite(imagePath.substring(0, imagePath.length()-4)+"Snipped"+i+imagePath.substring(imagePath.length()-4),
				mat);
		
		i++;
	}

	System.out.println("Done!!!");
}
 
開發者ID:MinhasKamal,項目名稱:GenderRecognizer,代碼行數:19,代碼來源:FaceDetector.java

示例8: saveImage

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
private void saveImage(Mat mat) {
    File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "MyAppDir");

    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.e("bifrostcore", "failed to create directory");
            return;
        }
    }

    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File mediaFile;
    mediaFile = new File(mediaStorageDir.getPath() + File.separator + "bifrostcore_" + timeStamp + ".png");
    Log.w("bifrostcore", "save image to " + mediaFile.toString());
    Highgui.imwrite(mediaFile.toString(), mat);
}
 
開發者ID:jmtrivial,項目名稱:bifrost,代碼行數:17,代碼來源:ImageToColor.java

示例9: getFrames

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
private static File[] getFrames(VideoCapture video, int frameFrequency) {
    int frameNumber = 1;
    Mat frame = new Mat();
    File videoFramesDir = Files.createTempDir();
    while(video.read(frame)){
        if(frameNumber % frameFrequency == 0) {
            String res = videoFramesDir.getAbsolutePath() + "/" +
                    String.format("%08d", frameNumber / frameFrequency) + ".jpg";
            Highgui.imwrite(res, frame);
        }
        frameNumber ++;
    }
    File [] frames = videoFramesDir.listFiles();
    Arrays.sort(frames);
    return frames;
}
 
開發者ID:yurinnick,項目名稱:hadoop-video-ocr,代碼行數:17,代碼來源:VideoProcessing.java

示例10: saveTo

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
public void saveTo(String path) {
    if (mBitmap != null) {
        try {
            mBitmap.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(path));
        } catch (FileNotFoundException e) {
            throw new UncheckedIOException(e);
        }
    } else {
        Highgui.imwrite(path, mMat);
    }
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:12,代碼來源:ImageWrapper.java

示例11: surroundFaces

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
/**
 * Creates a new output image from the input image with faces surrounded with green boxes.
 * @param image the input image previously analyzed.
 * @param faces array of coordinates corresponding to the previously detected faces.
 * @param outputFilename the output file name.
 * @return true in cas of success when creating the output file. False in case of failure.
 */
public static boolean surroundFaces(Mat image, Rect[] faces, String outputFilename) {
    if(outputFilename == null || outputFilename.isEmpty())
        throw new RaspoidException("The output filename can't be empty.");
    
    for(Rect face : faces)
        Core.rectangle(image,
                new Point(face.x, face.y),
                new Point(face.x + face.width, face.y + face.height),
                new Scalar(0, 255, 0));
    
    return Highgui.imwrite(outputFilename, image);
}
 
開發者ID:Raspoid,項目名稱:raspoid,代碼行數:20,代碼來源:FaceDetector.java

示例12: addShot

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
private void addShot(Frame workingFrame, PixelCluster pc) {
	final Optional<ShotColor> color = pc.getColor(workingFrame.getOriginalMat(), colorDistanceFromRed);

	if (!color.isPresent()) {
		if (logger.isDebugEnabled()) logger.debug("Processing Shot: Shot Rejected By Lack Of Color Density");
		return;
	}

	final double x = pc.centerPixelX;
	final double y = pc.centerPixelY;

	if (super.addShot(color.get(), x, y, workingFrame.getTimestamp(), true)
			&& Configuration.getConfig().isDebugShotsRecordToFiles()) {
		final Mat debugFrame = new Mat();
		Imgproc.cvtColor(workingFrame.getOriginalMat(), debugFrame, Imgproc.COLOR_HSV2BGR);

		String filename = String.format("shot-%d-%d-%d_orig.png",
				cameraManager.cameraTimeToShotTime(workingFrame.getTimestamp()), (int) pc.centerPixelX,
				(int) pc.centerPixelY);
		final File file = new File(filename);
		filename = file.toString();
		Highgui.imwrite(filename, debugFrame);

		for (final Pixel p : pc) {
			if (javafx.scene.paint.Color.GREEN.equals(color.get())) {
				final double[] greenColor = { 0, 255, 0 };
				debugFrame.put(p.y, p.x, greenColor);
			} else {
				final double[] redColor = { 0, 0, 255 };
				debugFrame.put(p.y, p.x, redColor);
			}
		}

		final File outputfile = new File(
				String.format("shot-%d-%d-%d.png", cameraManager.cameraTimeToShotTime(workingFrame.getTimestamp()),
						(int) pc.centerPixelX, (int) pc.centerPixelY));
		filename = outputfile.toString();
		Highgui.imwrite(filename, debugFrame);
	}
}
 
開發者ID:phrack,項目名稱:ShootOFF,代碼行數:41,代碼來源:JavaShotDetector.java

示例13: findPatterns

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
private List<MatOfPoint2f> findPatterns(Mat mat, boolean findMultiple) {
	final List<MatOfPoint2f> patternList = new ArrayList<>();

	int count = 0;
	while (true) {
		final Optional<MatOfPoint2f> boardCorners = findChessboard(mat);

		if (boardCorners.isPresent()) {
			patternList.add(boardCorners.get());

			if (!findMultiple) break;

			final RotatedRect rect = getPatternDimensions(boardCorners.get());

			blankRotatedRect(mat, rect);

			if (logger.isTraceEnabled()) {
				String filename = String.format("blanked-box-%d.png", count);
				final File file = new File(filename);
				filename = file.toString();
				Highgui.imwrite(filename, mat);

			}

			// Shortcut to not try to find three+ patterns
			// We never should see more than two but maybe that'll change
			// in the future
			findMultiple = false;

		} else {
			break;
		}
		count++;
	}
	return patternList;
}
 
開發者ID:phrack,項目名稱:ShootOFF,代碼行數:37,代碼來源:AutoCalibrationManager.java

示例14: main

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
public static void main(String[] args) {
	
	System.out.println(System.getProperty("java.class.path"));
 System.out.println(System.getProperty("java.library.path"));
 
 
	System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
	VideoCapture camera = new VideoCapture("data/bike.avi");
	MatOfByte frame = new MatOfByte();
	int i = 0;
	
 
	while(true){
        if (camera.read(frame)){
            System.out.println("Frame Obtained");
            System.out.println("Captured Frame Width " +
            frame.width() + " Height " + frame.height());
            System.out.println(frame.dump());
            Highgui.imwrite("tmp\\image\\camera"+(i++)+".jpg", frame);
            //Highgui.imencode(ext, img, buf)
        }else{
        	break;
        }
    }
	camera.release();
	
}
 
開發者ID:OpenVMC,項目名稱:HadoopCV,代碼行數:28,代碼來源:VideoReaderTest.java

示例15: run

import org.opencv.highgui.Highgui; //導入方法依賴的package包/類
public void run() {
  System.out.println("\nRunning CopyImage");

  // Create a face detector from the cascade file in the resources
  // directory.
  //CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("/lbpcascade_frontalface.xml").getPath());

  // For now, just read the image that is in the directory with our java project file
  Mat image = Highgui.imread("C:lena.jpg", Highgui.CV_LOAD_IMAGE_COLOR);	    
  //Mat image = Highgui.imread("yellow-tote-top.jpg", Highgui.CV_LOAD_IMAGE_COLOR);	    
  int srcRows = image.rows();
  int srcCols = image.cols();
  long imgData = image.dataAddr();
  System.out.println("Source rows = " + srcRows + " Src columns = " + srcCols);
  new LoadImage("C:dst1.jpg",image);
  int loadedRows = image.rows();
  int loadedCols = image.cols();
  System.out.println("Loaded rows = " + loadedRows + " Loaded columns = " + loadedCols);
  	// Detect faces in the image.
  	// MatOfRect is a special container class for Rect.
  	// MatOfRect faceDetections = new MatOfRect();
  	//faceDetector.detectMultiScale(image, faceDetections);

  	//System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));

  	// Draw a bounding box around each face.
  	//for (Rect rect : faceDetections.toArray()) {
  	//    Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));
  	//}

  	// Save the visualized detection.
  	//String filename = "faceDetection.png";
  
  	// For now, just save a copy of the original image.  
  	// Note: that this is also done in the LoadImage function.
  	String filename = "imageCopy.jpg";
  	System.out.println(String.format("Writing %s", filename));
  	Highgui.imwrite(filename, image);
}
 
開發者ID:Spartronics4915,項目名稱:2015-Recycle-Rush,代碼行數:40,代碼來源:Hello.java


注:本文中的org.opencv.highgui.Highgui.imwrite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。