设为首页 - 加入收藏 焦点技术网
热搜:java
当前位置:首页 >

OpenCV视频播放方法

2014-10-22 13:12:00.0 OpenCV with Linux 图像处理 视频 opencv  
导读:OpenCV视频播放方法今天折腾了一下OpenCV的视频播放功能,希望能对项目又帮助~代码还是很简单的,只是之前遇到点小麻烦,找不到cvCreateFileCapture函数的定义,花了一两个小时Makefile:SOURCE_FILE := play_video.cOBJECT_FILE := play_video.oCFLAGS = -Wall -Wconversion -O3 `pkg-...。。。


OpenCV视频播放方法


今天折腾了一下OpenCV的视频播放功能,希望能对项目又帮助~

代码还是很简单的,只是之前遇到点小麻烦,找不到cvCreateFileCapture函数的定义,花了一两个小时






Makefile:

SOURCE_FILE :=  play_video.cOBJECT_FILE :=  play_video.oCFLAGS = -Wall -Wconversion -O3 `pkg-config --cflags opencv`LIBS = `pkg-config --libs --cflags opencv`complie: gcc $(CFLAGS) -c $(SOURCE_FILE) $(LIBS)link: gcc $(CFLAGS) $(OBJECT_FILE) -o ./a.out $(LIBS)clean: rm -rf ./*.o ./a.out


/**************************************************************************code writer : EOFcode date : 2014.10.22code file : videos.ce-mail  : jasonleaster@gmail.com jasonleaster@163.comcode decription: This is the demo for how to play a vedio by OpenCV. If you find something wrong with my code, please touch me by e-mail.Thank you.****************************************************************************/#include //#include "opencv2/highgui/highgui_c.h"//#include "opencv2/imgproc/imgproc_c.h"#include "highgui.h"int main(int argc,char* argv[]){ CvCapture* capture = cvCreateFileCapture ("./B.avi"); char* win_name = "Hello World"; if(!capture) {  printf("No capture");  return 1; } cvNamedWindow(win_name,CV_WINDOW_AUTOSIZE); IplImage* frame; float ratio = 0; char  temp  = 0; while(1) {  frame = cvQueryFrame(capture);  if(!frame)  {   break;  }  cvShowImage(win_name,frame);  temp = cvWaitKey(33);  if(temp == 27)  {   break;  } } cvReleaseCapture(&capture); cvDestroyWindow(win_name); return 0;}

整体的框架就这样,可以玩视频~\(≧▽≦)/~啦啦啦













(编辑: u011368821)

网友评论