[php]
#include <cstdio>
#include <opencv2/opencv.hpp>
using namespace cv;
int main( int argc, char** argv )
{
//VideoCapture cam("/Users/powenko/Desktop/靜宜大學/20161001-課程-無人機安全監控/OpenCV/opencv/XCode/01基本/sample04E_PlayAVI/test/VideoTest.mov");
CvCapture *capture;
int key = 0;
// 路徑不能用中文
//char AviFileName[]="/Users/powenko/Desktop/靜宜大學/20161001-課程-無人機安全監控/OpenCV/opencv/XCode/01基本/sample04E_PlayAVI/test/big_buck_bunny_240p_1mb.mp4";
char AviFileName[]="/Users/powenko/Desktop/big_buck_bunny_240p_1mb.mp4";
//char AviFileName[]="big_buck_bunny_240p_1mb.mp4";
capture = cvCaptureFromAVI(AviFileName);
IplImage* frame = cvQueryFrame( capture );
// Check
if ( !capture )
{
fprintf( stderr, "Cannot open AVI!\n" );
return 1;
}
// Get the fps, needed to set the delay
int fps = ( int )cvGetCaptureProperty( capture, CV_CAP_PROP_FPS );
// Create a window to display the video
cvNamedWindow( "video", CV_WINDOW_AUTOSIZE );
while( key != ‘x’ )
{
// get the image frame
frame = cvQueryFrame( capture );
// exit if unsuccessful
if( !frame ) break;
// display current frame
cvShowImage( "video", frame );
// exit if user presses ‘x’
key = cvWaitKey( 1000 / fps );
}
// Tidy up
cvDestroyWindow( "video" );
cvReleaseCapture( &capture );
return 0;
}