OpenCV是在VS2005下配置的,新建的项目添加静态库highgui.lib即可。 如果打不开视频,安装解码器试试,如Xvid。 // 基于OpenCV的视频播放器(播放AVI格式) #include <stdio.h> #include <highgui.h> int g_slider_position = 0; CvCapture *g_capture = NULL; // 回调函数 void OnTrackbarSlide(int pos) { cvSetCaptureProperty(g_capture, CV_CAP_PROP_POS_FRAMES, pos); } int main(int argc, char *argv[]) { IplImage *pFrame = NULL; int nFrames = 0; char c; double fps = 0; // 帧率 int spf = 0; // 1/fps if (argc != 2) { printf("Usage: VideoPlayer.exe filename/n"); exit(1); } cvNamedWindow("VideoPlayer", 0); // 可改变窗口大小 g_capture = cvCreateFileCapture(argv[1]); if (!g_capture) { printf("Count not open video file/n"); exit(1); } // 获取视频帧率 fps &#