chaoshengmingyue
潮生明月
2015-10-18 12:07

opencv 摄像头读取视频保存

  • c++
  • opencv
    namedWindow("E1",cv::WINDOW_AUTOSIZE);
    namedWindow("E2",cv::WINDOW_AUTOSIZE);
    VideoCapture capture(0);
    Size size((int)capture.get(CV_CAP_PROP_FRAME_WIDTH ),(int)capture.get(CV_CAP_PROP_FRAME_HEIGHT ));
    VideoWriter writer;
    writer.open("D:\\shipin.avi",CV_FOURCC('M','J','P','G'),12,size);
    Mat log_frame, bgr_frame;
    for(;;)
    {
        capture>>bgr_frame;
        if(bgr_frame.empty()) break;

        imshow("E1",bgr_frame);
        Canny(bgr_frame,log_frame,60,120);
        imshow("E2",log_frame);
        writer<<log_frame;
        char c = waitKey(1);

        if(c == 27) break;
    }

    在上面这段代码中,视频保存在本地,但是只有6K,而且播放有没有东西
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答