美文网首页
opencv 视频截图并保存

opencv 视频截图并保存

作者: Caiaolun | 来源:发表于2019-07-16 10:03 被阅读0次
        /*************************************************************************
        * 视频截图并保存   https://docs.opencv.org/3.1.0/d8/dfe/classcv_1_1VideoCapture.html
        *************************************************************************/
        VideoCapture capture;
        capture.open("../../bin/data/Video.avi");
    
        if (!capture.isOpened())  // check if we succeeded
            return -1;
        Mat edges;
        namedWindow("edges", 1);
    
        int i = 0;
        for (;;)
        {
            Mat frame;
            capture >> frame; // get a new frame from camera
            //cvtColor(frame, edges, COLOR_BGR2GRAY);
            //GaussianBlur(edges, edges, Size(7, 7), 1.5, 1.5);
            //Canny(edges, edges, 0, 30, 3);
            Rect rect_plate(40, 30, 800, 400);
            edges = frame(rect_plate);
            imshow("edges", edges);
    
            char image_name[20];
            sprintf_s(image_name, "%d%s%s", i, "image截图", ".jpg");
            std::string str(image_name);
    
            imwrite("../../bin/data/" + str, edges);
    
            if (waitKey(300) >= 0) break;
            //i++;
        }
    

    相关文章

      网友评论

          本文标题:opencv 视频截图并保存

          本文链接:https://www.haomeiwen.com/subject/hwczkctx.html