#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
VideoCapture capture;
capture.open("./bike.avi");
if(!capture.isOpened())
{
printf("[%s][%d]could not load video data...\n",__FUNCTION__,__LINE__);
return -1;
}
Mat frame;
while(capture.read(frame))
{
imshow("video-demo",frame);
char c = waitKey(100);
if(c == 27)
{
break;
}
}
waitKey(0);
return 0;
}
编译方法:
g++ `pkg-config opencv4 --cflags` *.cpp -o opencv_test `pkg-config opencv4 --libs` -lpthread
环境变量配置:
export PKG_CONFIG_PATH=/home/dtcwyp/opencv/install/lib/pkgconfig
export LD_LIBRARY_PATH=/home/dtcwyp/opencv/install/lib
操作系统:
18.04.1-Ubuntu
查看opencv的版本方法:
pkg-config --modversion opencv4
opencv版本:
4.1.0