opencv3_java 启动摄像头 VideoCapture Videoio

启动摄像头 VideoCapture Videoio


package opencv_java_demo;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

import java.awt.*;
import java.awt.image.BufferedImage;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.videoio.VideoCapture;
import org.opencv.videoio.Videoio;

public class CaptureBasic extends JPanel {
	private static final long serialVersionUID=1L;
	
	private BufferedImage mImg;
	
	private BufferedImage mat2BI(Mat mat){
		int dataSize =mat.cols()*mat.rows()*(int)mat.elemSize();
		byte[] data=new byte[dataSize];
		mat.get(0, 0,data);
		int type=mat.channels()==1?
				BufferedImage.TYPE_BYTE_GRAY:BufferedImage.TYPE_3BYTE_BGR;
		
		if(type==BufferedImage.TYPE_3BYTE_BGR){
			for(int i=0;i



opencv3_java 启动摄像头 VideoCapture Videoio_第1张图片

你可能感兴趣的:(Opencv3_Java)