opencv3.3.0 with deep learning === https://github.com/opencv/opencv/wiki/Deep-Learning-in-OpenCV http://docs.opencv.org/3.3.0/ environment: lenovo x220 laptop OS: ubuntu16.04.2 [build opencv-3.3.0 on raspberry pi3](https://hackmd.io/s/S1oIlawDb#) ### Install dependency ```bash= sudo apt-get update ``` Install dependency ```bash= sudo apt-get install build-essential cmake pkg-config libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk-3-dev libatlas-base-dev gfortran ``` Install python3.5 ```bash= sudo apt-get install python3.5-dev ``` ### opencv-3.3.0 build from source unzip opencv-3.3.0 ```bash= cd opencv-3.3.0 mkdir build cd build ``` CMake will look for CMakeLists.txt and generate Makefile. CMake confoguration (now we are in build/) ```cmake= cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D INSTALL_C_EXAMPLES=OFF \ -D PYTHON_EXECUTABLE=/usr/bin/python3.5 \ -D BUILD_EXAMPLES=ON ..\ -D WITH_IPP=ON .. ``` ```bash= make -j4 sudo make install ``` >mostly we utilize pkg-config to compile openCV code >configure OpenCV. open the opencv.conf file with the command ```bash= sudo gedit /etc/ld.so.conf.d/opencv.conf ``` >/usr/local/lib This set the .so (dynamic link library) searching path. it will search opencv___.so from the path Remember we alread copy .so to /usr/local/lib when typing ***sudo make install*** in previous stage. ![](https://i.imgur.com/PavnvEF.png) configure the library ```bash= sudo ldconfig ``` now, edit ~/.bashrc this would auto load terminal environment for pkg-config ``` sudo vim ~/.bashrc ``` add at the bottom ``` PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH export PYTHONPATH=/usr/local/bin/python3.5:$PYTHONPATH ``` then save it. #### test inside opencv-3.3.0/build/bin/ has executable dnn-... for dl you need to collect 3 file *.cafffemodle* *.prototxt* *weight* for caffe net(zoo) ![](https://i.imgur.com/Grdx5B5.png) for FCN object detection ![](https://i.imgur.com/EyLeR6g.png) caffenet ![](https://i.imgur.com/YnRaH6y.png) FCN object detection(people) ![](https://i.imgur.com/jt0iVS1.png) mobileNetSSD ![](https://i.imgur.com/lnaukVR.png) ```bash= ./example_dnn-ssd_mobilenet_object_detection -video=/dev/video1 -model=MobileNetSSD_train.caffemodel -proto=MobileNetSSD_300x300.prototxt ``` and .zip file include executable and .caffemodel , proto.txt for someone would like to try it. size about 600MB https://drive.google.com/file/d/0BwY-lpO6tzxHRHNCdlRKczIzaEU/view?usp=sharing only contain caffemodel and proto https://drive.google.com/file/d/0BwY-lpO6tzxHVUZqN1pXc0xZdDQ/view?usp=sharing reference: http://www.coldvision.io/2016/07/29/image-classification-deep-learning-cnn-caffe-opencv-3-x-cuda/ https://github.com/opencv/opencv_contrib/issues/830 https://github.com/opencv/opencv_contrib/issues/941 https://github.com/opencv/opencv/issues/9322 ###### tags: `opencv3.3.0`