VideoWriter fails to write

asked 2016-04-29 01:04:59 -0600

vSumit gravatar image

updated 2016-04-29 07:58:26 -0600

The problem what i am facing is that when i try to save the image using Videowriter it creates the video file but the size is 0. I had created a header declaring a function which saves the video and a separate .cpp file which defines the function.When i write the whole code in only one file not in seperate file as before including ViceoCapture and VideoWriter it runs fine and even save the video file with appropriate file size.

When i started to debug i found that every time i receive a frame but VideoWriter.open is null or it says no symbols loaded for opencv_highgui.dll

savevideo.cpp file

#include"SaveVideo.h"
int CSaveVideo::savevideo()//string InpVideo, int pinstatus)
{
    VideoCapture oVcam(0);
    Mat vFrame;
    string OutPath = "C:\\Users\\20080031\\Desktop\\";
    string Filename = "Vout.avi";
    int vfourcc = CV_FOURCC('M', 'J', 'P', 'G');
    int vfps = 20;
    VideoWriter oVWrite;
    oVWrite.open(Filename, vfourcc, vfps, Size(480, 640), true);
    if (!oVcam.isOpened())
    {
        cout << "Camera not opened" << endl;
    }
    while (1)
    {
        oVcam.read(vFrame);
        imshow("Input", vFrame);
        waitKey(1);
       oVWrite.write(vFrame);
    }
}
CSaveVideo::CSaveVideo()
{
    cout << "Inside Constructor" << endl;
}
CSaveVideo::~CSaveVideo()
{
    //VideoCapture Vcam0;
    cout << "Inside Distructor" << endl;
    //Vcam0.release();
}

saveVideo.h

#ifndef SAVEVIDEO_H
#define SAVEVIDEO_H
#include<iostream>
#include<stdio.h>
#include<string>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/core/core.hpp>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;
class CSaveVideo
{
public:
CSaveVideo();
    ~CSaveVideo();

    //string m_sGPIOpinstatus;
    //char m_cSTOP;

    int savevideo();//string PinStatus, char End,  );
};
#endif SAVEVIDEO_H
edit retag flag offensive close merge delete

Comments

try with Size(640,480) and check, (if your frame really has that size)

berak gravatar imageberak ( 2016-04-29 08:10:58 -0600 )edit