宣告影像資料結構
- CvCapture capture;
將影片讀進影像資料結構
- char VideoFileName[]="test.mp4";
- capture = cvCaptureFromAVI("檔名.mp4"); (不一定只能mp4檔)
從影像資料結構中得到總共有多少frame
- int frame = cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT);
從影像資料結構中得到 fps: frame per second
- int fps = cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);
宣告視窗準備將frame丟到視窗上,參數0:可以自由調整視窗大小
- cv::namedWindow("Video Player",0);
判斷影像資料結構中是否有frame可以擷取
- cvGrabFrame(capture)-->ture/false
從影像資料結構中擷取一個一個的frame
- frame = cvRetrieveFrame(capture);
擷取到的frame丟到視窗上
- cv::imshow("Video Player",frame);
結束後釋放記憶體
- cvReleaseCapture(&capture);
- cvDestroyWindow("Video Player");
程式碼
- https://drive.google.com/folderview?id=0B3iLa8F71LQwRnBiM1RLQnQ4UWM&usp=sharing
Reference
整理得相當好!
回覆刪除