two.c

Carlos M., 2012-04-04 06:04 am

Download (556 Bytes)

 
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include "highgui.h"
4
5
int main(int argc, char** argv) {
6
7
  int delay = 33;
8
  if (3==argc) {
9
    delay = atoi(argv[2]);
10
  }
11
  printf("Delay is %d\n", delay);
12
13
  cvNamedWindow("Example 2-2", CV_WINDOW_AUTOSIZE);
14
  CvCapture* capture = cvCreateFileCapture(argv[1]);
15
  IplImage* frame;
16
  while(1) {
17
    frame = cvQueryFrame(capture);
18
    if (!frame) break;
19
    cvShowImage("Example 2-2", frame);
20
    char c = cvWaitKey(delay);
21
    if (27==c) break;
22
  }
23
  cvReleaseCapture(&capture);
24
  cvDestroyWindow("Example 2-2");
25
}
26
27