Skip to content

Latest commit

 

History

History
31 lines (28 loc) · 761 Bytes

视频处理.md

File metadata and controls

31 lines (28 loc) · 761 Bytes

#视频处理

样例:

	// 打开摄像头或者视频文件
    VideoCapture capture = new VideoCapture();
    //capture.open(0);
    capture.open("D:/vcprojects/images/768x576.avi");
    if(!capture.isOpened()) {
        System.out.println("could not load video data...");
        return;
    }
    int frame_width = (int)capture.get(3);
    int frame_height = (int)capture.get(4);
    
    Mat frame = new Mat();
    while(true) {
        boolean have = capture.read(frame);
        Core.flip(frame, frame, 1);// Win上摄像头
        if(!have) break;
        if(!frame.empty()) {
           ...
        }
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }