- 首页 > it技术 > >
opencv读取视频及打不开视频的解决方法
sudo apt install ffmpeg
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libavutil-dev
cmake -DCMAKE_BUILD_TYPE=RELEASE -D WITH_FFMPEG=ON ..
make -j4
sudo make install
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"using namespace cv;
int main(int argc, char **argv) {
VideoCapture capture;
Mat frame;
frame = capture.open(argv[1]);
if (!capture.isOpened())
{
return -1;
}
while (capture.read(frame))
{
cv::imshow("res", frame);
int key = waitKey(10) & 0xff;
if(key == 27) {
break;
}
}
destroyAllWindows();
return 0;
}
推荐阅读