It is purely self-entertainment, and does not conduct in-depth learning on the use of opencv. It is also the most basic thing to use opencv to open a video file or enable the camera to collect and save it.
1. Install the configuration Environment
Vs2008 install and configure opencv, 2005, 2010 steps should be similar, Here provide Web site, no more detailed than this http://www.opencv.org.cn/index.php/VC_2008_Express%E4%B8%8B%E5% AE %89%E8%A3%85OpenCV2.3.1
Ii. program code
For Learning opencv, we recommend "opencv tutorial-basics". Chapter 3 describes the video in detail. The following code is provided:
# Include "stdafx. H "# include" CV. H "# include" highgui. H "int main (INT argc, char ** argv) {cvcapture * capture = 0; iplimage * frame = 0; capture = cvcapturefromavi (" video. avi "); // capture = cvcapturefromcam (0); // Replace the double FPS = cvgetcaptureproperty (capture, cv_cap_prop_fps) with the camera ); // video frame rate // int FPS = 25; // capture frame rate, which affects the playback speed of produced files. Frame = cvqueryframe (capture ); // capture a frame first. cvvideowriter * Writer = 0; // Save the frame with int iscolol = 1; // int framew = 640; // int frameh = 480; writer = cvcreatevideowriter ("out. avi ", cv_fourcc ('F', 'l', 'V', '1'), FPS, cvsize (frame-> width, frame-> height), iscolol ); // The size here does not seem to work. // cvnamedwindow ("window", 1); // For (INT I = 0; I <50; I ++) // 2 seconds for (;) // always read {frame = cvqueryframe (capture); cvwriteframe (writer, frame); cvshowimage ("window", frame ); // display the cvwaitkey (1000/FPs) of an image; // video speed} cvreleasevideowriter (& writer); cvreleaseimage (& frame); cvreleasecapture (& capture ); cvdestroywindow ("window"); Return 0 ;}