#include <iostream> #include <opencv/highgui.h> int main(int argc, char** argv){ cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE); CvCapture* capture = cvCreateFileCapture("/Users/apple/Pictures/openCV/video/Andyou.mp4");//这里相当于创建了一个对象 IplImage* frame; while(1) { frame = cvQueryFrame(capture);//frame指向一块已经分配好的内存,所以之后并不用release if(!frame) break; cvShowImage("Example2", frame); char c = cvWaitKey(33); if(c == 27) break; //27是Esc得ASCII值 } cvReleaseCapture(&capture); cvDestroyWindow("Example2"); }
时间: 2024-10-15 06:59:24