Raspberry Pi OPENCV 安裝測試 [C++]版

Raspberry Pi OPENCV 安裝測試 [C++]版

Raspberry Pi OPENCV 安裝測試 [C++]版

資料來源: http://atceiling.blogspot.com/2017/02/raspberry-pi-opencv.html

LINUX 安裝 套件 準備/前置 動作

$ sudo rpi-update
$ sudo apt-get update
$ sudo apt-get upgrade


$ sudo apt-get install build-essential cmake cmake-curses-gui pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools libeigen3-dev
$ sudo apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev swig libv4l-0 libv4l-dev python-numpy libpython2.6 python-dev python2.6-dev libgtk2.0-dev

$ wget -O opencv-3.2.0.zip  https://sourceforge.net/projects/opencvlibrary/files/opencv-unix/3.2.0/opencv-3.2.0.zip/download
$ unzip opencv-3.2.0.zip
$ cd opencv-3.2.0

$ mkdir release
$ cd release
$ cmake ../
$ make
$ sudo make install


$ sudo apt-get install libopencv-dev


#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv ) {
    if( argc != 2) {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    Mat image;
    // Read the file
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR);
    if(! image.data ) { // Check for invalid input
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    // Create a window for display.
    namedWindow( "Display window", WINDOW_AUTOSIZE );
    // Show our image inside it.
    imshow( "Display window", image );
    // Wait for a keystroke in the window
    return 0;