Cvcreatefilecapture (file path)
Create a video recorder with a return value of cvcapture type for reading
Cvquerframe (VIDEO)
The next frame video file is loaded into memory, and when Cvcapture is released, the corresponding memory of each frame is freed, so Cvreleaseimage (&frame) is not required;
Cvreleasecapture (VIDEO)
Frees the memory space of the cvcapture result, and also closes all open video file related handles.
#include "highgui.h" int main (int argc, char** argv) {char c;iplimage* frame; cvcapture* Capture;cvnamedwindow ("Hello", cv_window_autosize); capture = Cvcreatefilecapture (argv[1]); while (1) { frame = Cvqueryframe (capture); if (!frame) {break;} Cvshowimage ("Hello", frame), C = Cvwaitkey (), if (c = =) { //escbreak;}} Cvreleaseimage (&frame); Adding this sentence will result in an error: Segment error (Core dump) cvreleasecapture (&capture), Cvdestroywindow ("Hello"); return 0;}
[Learn OpenCV Introduction] [004] [Play AVI Video]