Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Iam writing a sample code to copy a image to specific folder but it show error at run time?

 #include <stdio.h>
 #include <iostream>
  #include "opencv2/core.hpp"
 #include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/xfeatures2d.hpp"
#include<sstream>
#define _CRT_SECURE_NO_WARNINGS
 using namespace cv;
 using namespace cv::xfeatures2d;
 /* @function main */
 int main(int argc, char** argv)
{

char filename[128];
Mat frame;
cv::VideoCapture cap(0);
if (!cap.isOpened())
{
    std::cerr << "ERROR: Could not open video " << std::endl;
    return 1;
}
cvNamedWindow("MyVideo", CV_WINDOW_AUTOSIZE);
int frame_count = 0;
bool should_stop = false;

while (!should_stop)
{

    cv::Mat frame;
    cap >> frame; //get a new frame from the video
    if (frame.empty())
    {
        should_stop = true; //we arrived to the end of the video
        continue;
    }

    sprintf(filename, "frame_%06d.jpg", frame_count);
    cv::imwrite(filename, frame);
    strcpy("\"E:\"",filename);
    frame_count++;

    if (frame_count == 70)
    {

        break;
    }
}
    /* @function readme */

}

click to hide/show revision 2
retagged

updated 2017-10-06 01:10:37 -0600

berak gravatar image

Iam writing a sample code to copy a image to specific folder but it show error at run time?

 #include <stdio.h>
 #include <iostream>
  #include "opencv2/core.hpp"
 #include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/xfeatures2d.hpp"
#include<sstream>
#define _CRT_SECURE_NO_WARNINGS
 using namespace cv;
 using namespace cv::xfeatures2d;
 /* @function main */
 int main(int argc, char** argv)
{

char filename[128];
Mat frame;
cv::VideoCapture cap(0);
if (!cap.isOpened())
{
    std::cerr << "ERROR: Could not open video " << std::endl;
    return 1;
}
cvNamedWindow("MyVideo", CV_WINDOW_AUTOSIZE);
int frame_count = 0;
bool should_stop = false;

while (!should_stop)
{

    cv::Mat frame;
    cap >> frame; //get a new frame from the video
    if (frame.empty())
    {
        should_stop = true; //we arrived to the end of the video
        continue;
    }

    sprintf(filename, "frame_%06d.jpg", frame_count);
    cv::imwrite(filename, frame);
    strcpy("\"E:\"",filename);
    frame_count++;

    if (frame_count == 70)
    {

        break;
    }
}
    /* @function readme */

}