Reputation: 1254
I am trying to write the recording from my webcam into a file. For this purpose I am using the following code. I am getting an exit code of 2, all the time. Can someone help me figure out what is the problem? I have previously used a similar function call to write frames from one video file into a new one, where it worked. Can't understand what is the problem in this case.
Code Snippet follows:
int main(int argc, char *argv[]){
cv::Mat frame;
cv::VideoCapture cap(0);
cv::BackgroundSubtractorGMG bg;
bg.numInitializationFrames=120;
bg.decisionThreshold = 0.95;
bg.maxFeatures = 10;
double fps = cap.get(CV_CAP_PROP_FPS);
CvSize frameSize;
frameSize.height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
frameSize.width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
VideoWriter VW1("resultbuff.avi",CV_FOURCC('M','P','E','G'), fps, frameSize, 1);
VideoWriter VW2("recordingbuff.avi",CV_FOURCC('M','P','E','G'), fps, frameSize, 1);
VideoWriter VW3("finalResult.avi",CV_FOURCC('M','P','E','G'), fps, frameSize, 1);
if (!VW1.isOpened())
{
std::cout << "!!! Output video could not be opened" << std::endl;
return 2;
}
if (!VW2.isOpened())
{
std::cout << "!!! Output video could not be opened" << std::endl;
return 3;
}
if (!VW3.isOpened())
{
std::cout << "!!! Output video could not be opened" << std::endl;
return 4;
}
As mentioned, the program exits with code 2.
Upvotes: 0
Views: 281
Reputation: 1254
Okay, I found the answer. It was an error with the dlls. I was running the program in debug mode and the openCV dlls linked were for the release mode.
Upvotes: 1