#include <stdio.h> #include "cv.h" #include "highgui.h" #define LONGESTPATH 512 /************************* * path : the path of frames * lenPath : how many bytes in path * frameNum : the number of frame you want to load * imageExt : the frame image extension name. e.g. jpg *************************/ IplImage* readframe(char *path, int lenPath, int frameNum, char *imageExt) { IplImage *imgReturn = NULL; char frameName[LONGESTPATH]; sprintf (frameName, "%s%d.%s", path, frameNum, imageExt); imgReturn = cvLoadImage(frameName, CV_LOAD_IMAGE_GRAYSCALE); return imgReturn; } int main(int argc, char **argv) { IplImage* imgInput; int startNum; int numFrames; int iter; if (argc < 5) { fprintf (stdout, "please use: .\\hs.exe path start_number number_of_frames frame_extension\n"); fprintf (stdout, "e.g.: .\\hs.exe ..\\..\\data\\jpeg-20-frames\\ 1 20 jpg\n"); return -1; } startNum = atoi(argv[2]); numFrames = atoi(argv[3]); cvNamedWindow("Image", CV_WINDOW_AUTOSIZE);// for (iter = startNum; iter <= numFrames; iter++ )// { imgInput = readframe(argv[1], strlen(argv[1]), iter, argv[4]); if (NULL == imgInput) { fprintf (stderr, "Can not read the %dth frame in your directory you specified!\n", iter); return -1; } cvShowImage( "Image", imgInput );// cvWaitKey(1000/5); cvReleaseImage( &imgInput ); // } cvDestroyWindow( "Image" );// return 0; }
只有代码。。。。