參考資訊:
https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
main.cpp
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using std::string;
int main(int argc, char **argv)
{
Mat frame;
VideoCapture cap("main.avi");
if (!cap.isOpened()) {
printf("failed to load avi");
return -1;
}
int cnt = cap.get(CAP_PROP_FRAME_COUNT);
printf("total frame: %d\n", cnt);
cap.set(CV_CAP_PROP_POS_FRAMES, 100);
cap >> frame;
imwrite("1.jpg", frame);
waitKey(3000);
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(main)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(main main.cpp)
target_link_libraries(main ${OpenCV_LIBS})