0

I will like to split the video into frame of images and then save them into a file. when compiling the code the following error apear: undefined reference to itoa and strcat. Any help?

Thanks

the code is the following:

#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;
}
Hernando
  • 3
  • 2
  • Possible duplicate: http://stackoverflow.com/questions/5428632/c-error-undefined-reference-to-itoa – Cyclonecode Feb 29 '12 at 23:08
  • Thank you very much, that question solved the problem. Now the issue is that the program is not doing what suppose to do. It reads the avi file but it does not split the video into images and save them into the "frameSplit" file. – Hernando Feb 29 '12 at 23:25

1 Answers1

0

you forgot to #include < string.h>

try it:)

Terry
  • 156
  • 1
  • 6