Click here to Skip to main content
15,921,454 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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)


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 */
}
Posted
Updated 5-Oct-17 20:37pm

1 solution

strcpy call is wrong.
The function signature is char *strcpy(char *strDestination, const char *strSource);
What are you trying to do here?

If you want to create the file at E:\, you can add that to the filename - sprintf(filename, "E:\\frame_%06d.jpg", frame_count);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900