我想将视频分割成图像帧,然后将它们保存到文件中。 在编译代码时出现以下错误: 对itoa和strcat的未定义引用。 有什么帮助吗?
由于
代码如下:
#include <stdio.h>
#include <stdlib.h>
#include "cv.h"
#include <highgui.h>
#include "cxcore.h"
int main( int argc, char** argv )
{
CvCapture *capture = cvCaptureFromAVI("xyz.avi");
if(!capture)
{
printf("!!! cvCaptureFromAVI failed (file not found?)\n");
return -1;
}
int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
printf("* FPS: %d\n", fps);
IplImage* frame = NULL;
int frame_number = 0;
char key = 0;
while (key != 'q')
{
// get frame
frame = cvQueryFrame(capture);
if (!frame)
{
printf("!!! cvQueryFrame failed: no frame\n");
break;
}
char filename[100];
strcpy(filename, "frameSplit");
char frame_id[30];
itoa(frame_number, frame_id, 10);
strcat(filename, frame_id);
strcat(filename, ".png");
printf("* Saving: %s\n", filename);
if (!cvSaveImage(filename, frame,0))
{
printf("!!! cvSaveImage failed\n");
break;
}
frame_number++;
// quit when user press 'q'
key = cvWaitKey(1000 / fps);
}
// free resources
cvReleaseCapture(&capture);
return 0;
}
答案 0 :(得分:0)
你忘了#include&lt; string.h中&GT;
尝试一下:)