旧版本opencv的命令在较新版本中不起作用

时间:2015-05-29 16:45:13

标签: c++ opencv

我目前正在使用OpenCV 3.0.0测试版,但无法识别较早的cv::FOURCCCV_CAP_PROP_FRAME_WIDTHCV_CAP_PROP_FRAME_HEIGHT     版本。我将如何在最新版本中使用它们。这里有一些示例代码,提供了我可能需要它们的示例,并且无法在OpenCV 3.0.0 beta中使用它们。

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/videoio/videoio.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/video.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/core.hpp>

#include <iostream>
#include <sstream>

using namespace cv;
using namespace std;

int main()
{
VideoCapture cap("H:\\images\\v1.mp4");
cv::VideoWriter writer;
string filename = "H:\output_video.avi";
int fcc = cv::FOURCC('D', 'I', 'V', '3'); // Error Shown for this line
int fps = 20;
cv::Size frameSize(cap.get(CV_CAP_PROP_FRAME_WIDTH), 
cap.get(CV_CAP_PROP_FRAME_HEIGHT)); // Error Shown for this line
writer = VideoWriter(filename, fcc, fps, frameSize);

for(;;)
{
    Mat frame;
    cap >> frame;
    writer.write(frame);
    namedWindow("Output Video");
    imshow("Output Video", frame);
    char key = (char)waitKey(50);
    if(key == 'q' || key == 'Q' || key == 27)
    {
        break;
    }
}

return 0;
}

0 个答案:

没有答案