Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging 在调试模式和发布模式下运行opencd函数(VideoWriter)_Debugging_Opencv_Release - Fatal编程技术网

Debugging 在调试模式和发布模式下运行opencd函数(VideoWriter)

Debugging 在调试模式和发布模式下运行opencd函数(VideoWriter),debugging,opencv,release,Debugging,Opencv,Release,我试图在Visual Studio 2013下面构建和运行代码。构建很好,但代码仅在调试模式下运行,但在发布模式下失败。我可以看到,当代码试图调用VideoWriter函数时,代码停止了,我假设它可能与文件权限有关。但是,为什么在调试模式下可以呢?这有点令人困惑。。有人能告诉我这里发生了什么,或者我能进一步设法解决这个问题吗? 谢谢 #include <opencv2/opencv.hpp> using namespace cv; using namespace std; int m

我试图在Visual Studio 2013下面构建和运行代码。构建很好,但代码仅在调试模式下运行,但在发布模式下失败。我可以看到,当代码试图调用VideoWriter函数时,代码停止了,我假设它可能与文件权限有关。但是,为什么在调试模式下可以呢?这有点令人困惑。。有人能告诉我这里发生了什么,或者我能进一步设法解决这个问题吗? 谢谢

#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
    VideoCapture cap(0);

    // Get size of frames
    Size S = Size((int)cap.get(CV_CAP_PROP_FRAME_WIDTH), (int)
        cap.get(CV_CAP_PROP_FRAME_HEIGHT));

    // Make a video writer object and initialize it at 30 FPS
    VideoWriter put("output.mpg", CV_FOURCC('M', 'P', 'E', 'G'), 30, S);

    if (!put.isOpened())
    {
        cout << "File could not be created for writing. Check permissions" << endl;
        return -1;
    }
    namedWindow("Video");

    // Play the video in a loop till it ends
    while (char(waitKey(1)) != 'q' && cap.isOpened())
    {
        Mat frame;
        cap >> frame;
        // Check if the video is over
        if (frame.empty())
        {
            cout << "Video over" << endl;
            break;
        }
        imshow("Video", frame);
        put << frame;
    }

    return 0;
}