OpenCV introduction
1. Install(Unix Like system)
1.1. ffmpeg
$ ./configure --enable-shared $ make $ sudo make install
1.2. OpenCV
$ mkdir release $ cd release $ cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ../ $ make $ sudo make install
2. Introduction
2.1. Show Image
// main.cc #include <opencv2/opencv.hpp> // All OpenCV function's include file int main(int argc, char** argv) { // image read cv::Mat img = cv::imread(argv[1], -1); if (img.empty()) return -1; // if no image, exit with -1 // A window named Example, and with size of image cv::namedWindow( "Example", cv::WINDOW_AUTOSIZE ); // Show img on window named Example cv::imshow( "Example", img ); // Wait any key cv::waitKey(0); // Clean up cv::destroyWindow( "Example" ); }
Compile & Run it.
$ clang++ -std=c++14 main.cc -lopencv_core -lopencv_highgui -lopencv_imgcodecs