我写了一个示例代码将图像复制到特定文件夹,但它在运行时显示错误? [英] Iam writing a sample code to copy a image to specific folder but it show error at run time?
本文介绍了我写了一个示例代码将图像复制到特定文件夹,但它在运行时显示错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Exception thrown at 0x00007FF7D4631485 in homo_test.exe: 0xC0000005: Access violation writing location 0x00007FF7D4633318.
The program '[8148] homo_test.exe' has exited with code 0 (0x0)
< b>我尝试过的事情:
What I have tried:
#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 */
}
推荐答案
strcpy
调用错误。
函数签名是char * strcpy(char * strDestination,const char * strSource);
你想在这做什么?
如果你想在E:\\创建文件\\,您可以将其添加到文件名 -sprintf(文件名,E:\\frame_%06d.jpg,frame_count);
这篇关于我写了一个示例代码将图像复制到特定文件夹,但它在运行时显示错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文