opencv c++ 질문입니다 VideoWrite 관하여 질문입니다.

조회수 347회
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
int main()
{

    Mat frame1, frame2;
    VideoCapture capture1("video1.mp4");
    VideoCapture capture2("video2.mp4");
    int ex = static_cast<int>(capture1.get(CAP_PROP_FOURCC));

    if ((!capture1.isOpened()) || (!capture2.isOpened()))
    {
        printf("One of the video file can not open.\n");
    }


    std::vector<Mat> imgs;
    Mat temp;

    while (1)
    {
        capture1 >> frame1;
        capture2 >> frame2;

        if (frame1.empty() || frame2.empty())
            break;
        resize(frame1, frame1, Size(540, 270));
        resize(frame2, frame2, Size(540, 270));
        hconcat(frame1, frame2, temp);
        imgs.push_back(temp);
        imshow("video1", frame1);
        imshow("video2", frame2);
        imshow("new", temp);



        if (waitKey(100) > 0)
            break;
    }

    VideoWriter writer;
    writer.open("NewVideo.avi", ex, 30, Size(frame1.cols*2, frame1.rows));
    if(writer.isOpened())
    for (int i = 0; i < imgs.size(); i++)
        writer.write(imgs[i]);

    writer.release();
}

위와 같이 간단한 코드입니다. 단 videowriter가 open 되지 않는 것을 확인하였습니다. 문법상의 오류가 없는 상태로 아무리 검색해도 저와 같은 오류는 보이지 않아 이곳에서 질문드립니다.

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)