3 ## import the necessary things for OpenCV
4 addpath("/home/x/opencv2/interfaces/swig/octave");
5 source("/home/x/opencv2/interfaces/swig/octave/PKG_ADD_template");
7 debug_on_warning(true);
8 crash_dumps_octave_core (0)
12 ## the codec existing in cvcapp.cpp,
13 ## need to have a better way to specify them in the future
14 ## WARNING: I have see only MPEG1VIDEO working on my computer
17 MSMPEG4V3 = 0x33564944;
19 MSMPEG4V2 = 0x3234504D;
21 MPEG1VIDEO = 0x314D4950;
26 #############################################################################
27 ## so, here is the main part of the program
30 printf("OpenCV Octave capture video\n");
32 ## first, create the necessary window
33 highgui.cvNamedWindow ('Camera', highgui.CV_WINDOW_AUTOSIZE);
35 ## move the new window to a better place
36 #highgui.cvMoveWindow ('Camera', 10, 10);
39 ## try to get the device number from the command line
40 device = int32 (argv(){1});
42 ## no device number on the command line, assume we want the 1st device
46 ## no argument on the command line, try to use the camera
47 capture = highgui.cvCreateCameraCapture (device);
49 ## check that capture device is OK
50 if (!swig_this(capture))
51 printf("Error opening capture device\n");
55 ## capture the 1st frame to get some propertie on it
56 frame = highgui.cvQueryFrame (capture);
58 ## get size of the frame
59 frame_size = cv.cvGetSize (frame);
61 ## get the frame rate of the capture device
62 fps = highgui.cvGetCaptureProperty (capture, highgui.CV_CAP_PROP_FPS);
64 ## no fps getted, so set it to 30 by default
69 writer = highgui.cvCreateVideoWriter ("captured.mpg", MPEG1VIDEO,
70 fps, frame_size, true);
72 ## check the writer is OK
73 if (!swig_this(writer))
74 printf("Error opening writer\n");
81 ## 1. capture the current image
82 frame = highgui.cvQueryFrame (capture);
83 if (swig_this(frame) == 0)
84 ## no image captured... end the processing
88 ## write the frame to the output file
89 highgui.cvWriteFrame (writer, frame);
91 ## display the frames to have a visual output
92 highgui.cvShowImage ('Camera', frame);
95 k = highgui.cvWaitKey (5);
98 ## user has press the ESC key, so exit
104 ## end working with the writer
105 ## not working at this time... Need to implement some typemaps...
106 ## but exiting without calling it is OK in this simple application
107 ##highgui.cvReleaseVideoWriter (writer)