opencv 读取摄像头数据

阅读更多

opencv 读取摄像头数据代码:

package openvc;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.videoio.VideoCapture;

public class ShowCameraMain {

	public static void main(String[] args) {
		try {
			System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

			VideoCapture vc = new VideoCapture(0);

			HighGui.namedWindow("video");
			Mat pic = new Mat();

			while (true) {
				vc.read(pic);
				if (pic.empty()) {
					break;
				}
				HighGui.imshow("video", pic);
				HighGui.waitKey(30);

			}

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

 

备注: 环境搭建参考其他文章

你可能感兴趣的:(openvc)