I try to split .avi video into frame of images using this code :
#include <stdio.h>
#include < string.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;
}
when i try to compile this program using :
g++ -O2 -Wall -o VideoToImages VideoToImages.cpp pkg-config --cflags --libs opencv
i got this error : fatal error: string.h:no such file or directory compilation terminated
Any idea please Thanks