網頁

顯示具有 OpenCV 標籤的文章。 顯示所有文章
顯示具有 OpenCV 標籤的文章。 顯示所有文章

2023年3月7日 星期二

install opencv4.6.0 with CUDA for Jetson

參考 https://forums.developer.nvidia.com/t/best-way-to-install-opencv-with-cuda-on-jetpack-5-xavier-nx-opencv-for-tegra/222777
下載 install_opencv4.6.0_jetson.sh 備份如下
#!/bin/bash
#
# Copyright (c) 2022, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#

version="4.6.0"
folder="workspace"

for (( ; ; ))
do
    echo "Do you want to remove the default OpenCV (yes/no)?"
    read rm_old

    if [ "$rm_old" = "yes" ]; then
        echo "** Remove other OpenCV first"
        sudo apt -y purge *libopencv*
break
    elif [ "$rm_old" = "no" ]; then
break
    fi
done


echo "------------------------------------"
echo "** Install requirement (1/4)"
echo "------------------------------------"
sudo apt-get update
sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install -y python3.8-dev python-dev python-numpy python3-numpy
sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp
sudo apt-get install -y curl


echo "------------------------------------"
echo "** Download opencv "${version}" (2/4)"
echo "------------------------------------"
mkdir $folder
cd ${folder}
curl -L https://github.com/opencv/opencv/archive/${version}.zip -o opencv-${version}.zip
curl -L https://github.com/opencv/opencv_contrib/archive/${version}.zip -o opencv_contrib-${version}.zip
unzip opencv-${version}.zip
unzip opencv_contrib-${version}.zip
rm opencv-${version}.zip opencv_contrib-${version}.zip
cd opencv-${version}/


echo "------------------------------------"
echo "** Build opencv "${version}" (3/4)"
echo "------------------------------------"
mkdir release
cd release/
cmake -D WITH_CUDA=ON -D WITH_CUDNN=ON -D CUDA_ARCH_BIN="7.2,8.7" -D CUDA_ARCH_PTX="" -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${version}/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j$(nproc)


echo "------------------------------------"
echo "** Install opencv "${version}" (4/4)"
echo "------------------------------------"
sudo make install
echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export PYTHONPATH=/usr/local/lib/python3.8/site-packages/:$PYTHONPATH' >> ~/.bashrc
source ~/.bashrc


echo "** Install opencv "${version}" successfully"
echo "** Bye :)"

將 cv2 加到 python3 中
$ export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.8/site-packages
$ python3
>>> import cv2
>>> cnt = cv2.cuda.getCudaEnabledDeviceCount()
>>> cnt
1 表示有 CUDA

2021年9月22日 星期三

安裝 labelImg

參考 LabelImg GitHub

正常時
sudo apt-get install pyqt5-dev-tools
sudo pip3 install -r requirements/requirements-linux-python3.txt
make qt5py3
python3 labelImg.py

但是安裝 pyqt5-dev-tools 會造成版本衝突
所以到 https://download.qt.io/archive/qt 下載 qt-opensource-linux-x64-5.x.x.run
chmod +x qt-opensource-linux-x64-5.x.x.run
sudo ./qt-opensource-linux-x64-5.x.x.run
安裝到 /opt/Qt5.x.x
移除時使用 /opt/Qt5.x.x/MaintenanceTool
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qt5.10.1/5.10.1/gcc_64/lib

參考 OpenCV 安裝部分 qt5 不要安裝
sudo apt-get install qt5-default
sudo apt-get install qtcreator
cmake 增加
-D Qt5_DIR=/opt/Qt5.x.x/5.x.x/gcc_64/lib/cmake/Qt5 \


另外 安裝除錯時使用命令
apt list --installed
sudo apt-get install qt5-default
sudo apt-get purge -y qt5-default
pip install opencv-python
pip uninstall opencv-python
pip install -r requirements/requirements-linux-python3.txt
pip uninstall -r requirements/requirements-linux-python3.txt
安裝指定版本
pip install pyqt5==5.14.2
查詢可用版本
pip install pyqt5==
查詢 QT 的執行錯誤
export QT_DEBUG_PLUGINS=1


2021年1月11日 星期一

Ubuntu 18.04 重灌

依據 https://developer.nvidia.com/deepstream-getting-started
選擇各個版本

https://docs.nvidia.com/metropolis/deepstream/dev-guide/index.html

sudo apt-get install ssh
sudo apt install python3-pip
sudo ln -s /usr/bin/python3 /usr/bin/python

安裝 NVIDIA Driver
https://www.linuxbabe.com/ubuntu/install-nvidia-driver-ubuntu-18-04
sudo lshw -c display
sudo lshw -c video
sudo ubuntu-drivers devices
sudo ubuntu-drivers autoinstall
sudo reboot
sudo lshw -c display

安裝 CUDA Toolkit
https://developer.nvidia.com/cuda-downloads
請選擇 CUDA Toolkit 10.2
Linux/x86_64/Ubuntu/18.04/deb(local)
vi ~/.bashrc
export PATH=/usr/local/cuda-10.2:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH

安裝 CUDNN
https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html
https://developer.nvidia.com/cudnn
選擇 cuDNN v8.0.5 for CUDA 10.2
選擇 cuDNN Library for Linux (x86)
tar -xzvf cudnn-10.2-linux-x64-v8.0.5.39.tgz
sudo cp cuda/include/cudnn*.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
sudo ldconfig
/sbin/ldconfig.real: /usr/local/cuda-10.2/targets/x86_64-linux/liblibcudnn.so.8 is not a symbolic link
cd /usr/local/cuda-10.2/targets/x86_64-linux/lib
sudo rm liblibcudnn.so.8 liblibcudnn.so
sudo ln -s libcudnn.so.8.0.5 libcudnn.so.8
sudo ln -s libcudnn.so.8 libcudnn.so
sudo ldconfig

安裝 TensorRT
下載 TensorRT binary
https://developer.nvidia.com/nvidia-tensorrt-7x-download
選擇 TensorRT 7.1.3.4 for Ubuntu 18.04 and CUDA 10.2 TAR package
version="7.1.3.4"
os="Ubuntu-18.04"
arch=$(uname -m)
cuda="cuda-10.2"
cudnn="cudnn8.0"
tar -xvzf TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0.tar.gz
vi ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/Data/TensorRT/TensorRT-7.1.3.4/lib
source ~/.bashrc
cd TensorRt-7.1.3.4/python
sudo pip3 install tensorrt-7.1.3.4-cp36-none-linux_x86_64.whl
cd ../uff
sudo pip3 install uff-0.6.9-py2.py3-none-any.whl
cd ../graphsurgeon/
sudo pip3 install graphsurgeon-0.4.5-py2.py3-none-any.whl

安裝 GStreamer
https://yingrenn.blogspot.com/2020/09/gstreamer.html

安裝 DeepStream
https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html#dgpu-setup-for-ubuntu
sudo apt install \
 libssl1.0.0 \
 libgstreamer1.0-0 \
 gstreamer1.0-tools \
 gstreamer1.0-plugins-good \
 gstreamer1.0-plugins-bad \
 gstreamer1.0-plugins-ugly \
 gstreamer1.0-libav \
 libgstrtspserver-1.0-0 \
 libgstrtspserver-1.0-dev \
 libjansson4
git clone https://github.com/edenhill/librdkafka.git
cd librdkafka
git reset --hard 7101c2310341ab3f4675fc565f64f0967e135a6a
./configure
make
sudo make install
sudo mkdir -p /opt/nvidia/deepstream/deepstream-5.0/lib
sudo cp /usr/local/lib/librdkafka* /opt/nvidia/deepstream/deepstream-5.0/lib
下載 DeepStream
https://developer.nvidia.com/assets/Deepstream/5.0/ga/secure/deepstream_sdk_5.0.1_x86_64.tbz2
sudo tar -xvf deepstream_sdk_v5.0.1_x86_64.tbz2 -C /
cd /opt/nvidia/deepstream/deepstream-5.0/
sudo ./install.sh
sudo ldconfig

安裝 CMake v3.13
wget http://www.cmake.org/files/v3.13/cmake-3.13.5.tar.gz
tar xpvf cmake-3.13.5.tar.gz cmake-3.13.5
cd cmake-3.13.5
sudo apt-get install zlib1g-dev
sudo apt-get install curl
sudo apt-get install libcurl3
sudo apt-get install libcurl4 libcurl4-openssl-dev
./bootstrap --system-curl
make -j$(nproc)
sudo make install

安裝 Docker
https://docs.docker.com/engine/install/ubuntu/
sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

安裝 NVIDIA Docker
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker
curl https://get.docker.com | sh \
  && sudo systemctl start docker \
  && sudo systemctl enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
   && curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
   && curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
sudo groupadd docker
sudo usermod -a -G docker $USER
sudo reboot

若 sudo apt update 出現
W: Target CNF (stable/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:52 and /etc/apt/sources.list.d/docker.list:1
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4773BD5E130D1D45
sudo rm /etc/apt/sources.list.d/docker.list

安裝 TensorRT 7.1 OSS
https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html
https://github.com/NVIDIA/TensorRT/tree/master
從 master 切換到 release/7.1
下載 TensorRT OSS
TensorRT OSS: 包含 TensorRT plugins, Caffe 和 ONNX parsers 等
git clone -b master https://github.com/nvidia/TensorRT TensorRT
cd TensorRT
git submodule update --init --recursive
參考之前的 TensorRT binary
cd TensorRT-7.1.3.4
export TRT_RELEASE=`pwd`
cd $TRT_SOURCE
./docker/build.sh --file docker/ubuntu.Dockerfile --tag tensorrt-ubuntu --os 18.04 --cuda 10.2
./docker/launch.sh --tag tensorrt-ubuntu --gpus all --release $TRT_RELEASE --source $TRT_SOURCE
cd $TRT_SOURCE
mkdir -p build && cd build
cmake .. -DTRT_LIB_DIR=$TRT_RELEASE/lib -DTRT_OUT_DIR=`pwd`/out
make -j$(nproc)
exit
mkdir backup
mv $TRT_RELEASE/targets/x86_64-linux-gnu/lib/libnvinfer_plugin.so.7.1.3 backup
cp $TRT_SOURCE/build/out/libnvinfer_plugin.so.7.2.1 $TRT_RELEASE/targets/x86_64-linux-gnu/lib/libnvinfer_plugin.so.7.1.3

安裝 OpenCV 4.4
git clone https://github.com/opencv/opencv.git opencv-4.4.0 -b 4.4.0 --depth 1
git clone https://github.com/opencv/opencv_contrib.git opencv_contrib-4.4.0 -b 4.4.0 --depth 1
sudo apt-get update
sudo add-apt-repository ppa:alex-p/tesseract-ocr
sudo apt install tesseract-ocr libtesseract-dev
sudo apt-get install libleptonica-dev
sudo apt-get install qt5-default
sudo apt-get install qtcreator
sudo apt-get install build-essential cmake unzip pkg-config
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install libhdf5-dev
sudo apt-get install python3-dev
mkdir build; cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D WITH_TBB=ON \
-D BUILD_opencv_cudacodec=OFF \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUDA=ON \
-D WITH_CUBLAS=ON \
-D WITH_LIBV4L=ON \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_java=OFF \
-D WITH_V4L=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D WITH_GSTREAMER=ON \
-D WITH_GTK=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv.pc \
-D OPENCV_ENABLE_NONFREE=OFF \
-D OPENCV_EXTRA_MODULES_PATH=/your_path_to/opencv/opencv_contrib-4.4.0/modules \
-D BUILD_EXAMPLES=ON \
-D WITH_CUDNN=ON \
-D CUDNN_VERSION="8.0.5" \
-D OPENCV_DNN_CUDA=ON \
-D CUDNN_INCLUDE_DIR=/usr/local/cuda/include \
-D CUDNN_LIBRARY=/usr/local/cuda/lib64/libcudnn.so.8.0.5 \
-D CUDA_ARCH_BIN=7.5 \
../opencv-4.4.0
#-D OPENCV_ENABLE_NONFREE=ON \
#-D OpenGL_GL_PREFERENCE=LEGACY \

make -j$(nproc)
sudo make install
sudo ldconfig
opencv_version -v

下載 Tesseract 的中文字 chi_tra.traineddata, chi_tra_vert.traineddate
https://github.com/tesseract-ocr/tessdata
放至 /usr/share/tesseract-ocr/4.00/tessdata

安裝 Xpra
https://www.xpra.org/trac/wiki/Building/Debian
sudo apt-get install libx11-dev libxtst-dev libxcomposite-dev libxdamage-dev \
 libxkbfile-dev python-all-dev
sudo apt-get install libgtk-3-dev python3-dev python3-cairo-dev python-gi-dev cython3
sudo apt-get install xauth x11-xkb-utils
sudo apt-get install libx264-dev libvpx-dev yasm
sudo apt-get install libnvidia-encode-440
sudo apt-get install libavformat-dev libavcodec-dev libswscale-dev
sudo apt-get install libturbojpeg-dev
sudo apt-get install libwebp-dev
sudo apt-get install uglifyjs brotli libjs-jquery libjs-jquery-ui gnome-backgrounds
sudo apt-get install python3-opengl python3-numpy python3-pil
sudo apt-get install python3-rencode python3-lz4 python3-dbus python3-cryptography \
 python3-netifaces python3-yaml
sudo apt-get install python3-setproctitle python3-xdg python3-pyinotify python3-opencv
sudo apt-get install libpam-dev quilt xserver-xorg-dev xutils-dev xvfb keyboard-configuration
sudo apt-get install python3-kerberos python3-gssapi
sudo apt-get install gstreamer1.0-pulseaudio gstreamer1.0-alsa \
 gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
 gstreamer1.0-plugins-ugly
sudo apt-get install cups-filters cups-common cups-pdf python3-cups
sudo apt-get install openssh-client sshpass python3-paramiko
sudo apt-get install devscripts build-essential lintian debhelper
wget https://www.xpra.org/src/xpra-4.0.4.tar.xz
tar -xf xpra-4.0.6.tar.xz
cd xpra-4.0.6
vi setup.py
#!/usr/bin/env python3
sudo ./setup.py install

安裝 frp
https://yingrenn.blogspot.com/2020/03/frp.html
vi frps.ini
[common]
bind_port = 7000
dashboard_port = 7001
dashboard_user = user
dashboard_pwd = password

vi /etc/systemd/system/frps.service
[Unit]
Description=FRP Server Daemon

[Service]
Type=simple
ExecStartPre=-/usr/sbin/setcap cap_net_bind_service=+ep /home/mark/Data/frp/frp_0.34.3_linux_amd64/frps
ExecStart=/path_to_frp/frp_0.34.3_linux_amd64/frps -c /path_to_frp/frp_0.34.3_linux_amd64/frps.ini
Restart=always
RestartSec=20s
User=nobody
PermissionsStartOnly=true
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target

sudo systemctl start frps
sudo systemctl enable ftps

安裝 Gitea Tomcat Nginx
https://yingrenn.blogspot.com/2019/11/gitea-in-ubuntu.html
https://yingrenn.blogspot.com/search/label/tomcat

安裝 x11vnc
因為 Ubuntu 18.04 改 LightDM 到 GDM3, 所以要在 console login 後,才能動作
sudo apt install x11vnc
sudo x11vnc -storepasswd
sudo chown mark.mark ~/.vnc/passwd
sudo vi /etc/systemd/system/x11vnc.service
# Description: Custom Service Unit file
# File: /etc/systemd/system/x11vnc.service
[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -loop -nopw -xkb -repeat -noxrecord -noxfixes -noxdamage -forever -rfbport 5900 -display :1 -auth /run/user/1000/gdm/Xauthority -rfbauth /home/mark/.vnc/passwd
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
RestartSec=2

[Install]
WantedBy=multi-user.target

安裝 VirtualBox
https://www.virtualbox.org/wiki/Downloads
到官網下載
virtualbox-6.1_6.1.16-140961~Ubuntu~bionic_amd64.deb
Oracle_VM_VirtualBox_Extension_Pack-6.1.16.vbox-extpack
sudo dpkg -i virtualbox-6.1_6.1.16-140961~Ubuntu~bionic_amd64.deb
sudo groupadd win10disk
sudo usermod -a -G win10disk youruser
sudo udevadm info /dev/sdX | grep UUID
E: ID_PART_TABLE_UUID=01234567-89ab-cdef-0123-456789abcde
vi /etc/udev/rules.d/99-win10disk.rules
ENV{ID_PART_TABLE_UUID}=="1234567-89ab-cdef-0123-456789abcde", GROUP="win10disk"
ls -l /dev/sdb
brw-rw---- 1 root win10disk 8, 16 Nov 4 23:33 /dev/sdb
VBoxManage internalcommands createrawvmdk -filename .VirtualBox/Crucial1T.vmdk -rawdisk /dev/sda
sudo usermod -a -G vboxusers youruser
拷貝舊的 VM, 修改 win10.vbox, win10.vbox-prev 內的 uuid
與 .VirtualBox/Crucial1T.vmdk 的 uuid 一致
開啟 VirtualBox
File/Preferences...
Extensions 按 +
選擇剛下載的 Oracle_VM_VirtualBox_Extension_Pack-6.1.16.vbox-extpack


只有登入畫面無法使用滑鼠和鍵盤,其餘正常
sudo apt-get instll xserver-xorg-input-all

2020年8月25日 星期二

Build OpenCV on Jetson NANO with CUDA CUDNN

參考 How to configure your NVIDIA Jetson Nano for Computer Vision and Deep Learning

make 時出現下列錯誤
error: 'CUDNN_CONVOLUTION_FWD_PREFER_FASTEST' was not declared in this scope
error: 'CUDNN_CONVOLUTION_BWD_PREFER_FASTEST' was not declared in this scope
原因為 OpenCV 4.4 以前,並不支援 CUDNN8.0

CUDNN 8.0 只能在 OpenCV 4.4 才能 build 成功
$ git clone https://github.com/opencv/opencv.git -b 4.4.0 --depth 1
$ git clone https://github.com/opencv/opencv_contrib.git -b 4.4.0 --depth 1


刪除舊的安裝
$ sudo apt purge libopencv-dev libopencv-python libopencv-samples libopencv*
$ sudo apt update

參考 Any OCR model run in Jetson Nano
參考 Installing tesseract 4.0 on Ubuntu 16.04
$ sudo apt install tesseract-ocr libtesseract-dev


$ sudo add-apt-repository ppa:alex-p/tesseract-ocr
$ sudo apt-get update
$ sudo apt-get install libleptonica-dev
$ sudo apt-get install qt5-default
$ sudo apt-get install qtcreator

cmake \
 -D CMAKE_BUILD_TYPE=RELEASE \
 -D CMAKE_INSTALL_PREFIX=/usr/local \
 -D WITH_CUDA=ON \
 -D WITH_CUDNN=ON \
 -D WITH_CUBLAS=ON \
 -D WITH_V4L=ON \
 -D CUDNN_VERSION='8.0' \
 -D CUDNN_INCLUDE_DIR='/usr/include' \
 -D OPENCV_DNN_CUDA=ON \
 -D WITH_GTK=ON \
 -D WITH_QT=ON \
 -D INSTALL_C_EXAMPLES=OFF \
 -D WITH_GSTREAMER=ON \
 -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.4.0/modules/ \
 -D OPENCV_ENABLE_NONFREE=ON \
 -D BUILD_TESTS=OFF \
 -D BUILD_PERF_TESTS=OFF \
 -D BUILD_EXAMPLES=OFF \
 -D INSTALL_PYTHON_EXAMPLES=ON \
 -D PYTHON_EXECUTABLE=$(which python3) \
 -D BUILD_opencv_python2=OFF \
 -D BUILD_opencv_python3=ON \
 -D BUILD_opencv_java=OFF \
 -D PYTHON3_EXECUTABLE=$(which python3) \
 -D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
 -D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
 -D Tesseract_INCLUDE_DIR=/usr/include/tesseract \
 -D Tesseract_LIBRARY=/usr/lib/aarch64-linux-gnu/libtesseract.so \
 -D Lept_LIBRARY=/usr/lib/aarch64-linux-gun/liblept.so \
 -D CUDA_ARCH_PTX="" \
 -D CUDA_ARCH_BIN="5.3,6.2,7.2" \
 -D OPENCV_GENERATE_PKGCONFIG=YES ..

$ make -j4
$ sudo make install
$ sudo ldconfig


$ opencv_version -v

安裝於 python 的 virtualenv 中
nano@nano-desktop:~/envs/py3cv4/lib/python3.6/site-packages$ ln -s /usr/lib/python3/dist-packages/cv2/python-3.6/cv2.cpython-36m-aarch64-linux-gnu.so cv2.so


在 mainwindow.cpp 檔內增加
#include <opencv2/opencv.hpp>
#include <opencv2/cudaimgproc.hpp>


SSD 測試
(py3cv4) nano@nano-desktop:~/Data/opencv/opencv-dnn-gpu-examples$ python opencv-ssd-cuda/ssd_object_detection.py --prototxt opencv-ssd-cuda/MobileNetSSD_deploy.prototxt --model opencv-ssd-cuda/MobileNetSSD_deploy.caffemodel --input example_videos/guitar.mp4 --display 0 --use-gpu=1
[INFO] setting preferable backend and target to CUDA...
[INFO] accessing video stream...
[INFO] elasped time: 34.94
[INFO] approx. FPS: 7.07
(py3cv4) nano@nano-desktop:~/Data/opencv/opencv-dnn-gpu-examples$ python opencv-ssd-cuda/ssd_object_detection.py --prototxt opencv-ssd-cuda/MobileNetSSD_deploy.prototxt --model opencv-ssd-cuda/MobileNetSSD_deploy.caffemodel --input example_videos/guitar.mp4 --display 0
[INFO] accessing video stream...
[INFO] elasped time: 81.08
[INFO] approx. FPS: 3.05

Yolo 測試
(py3cv4) nano@nano-desktop:~/Data/opencv/opencv-dnn-gpu-examples$ python3 opencv-yolo-cuda/yolo_object_detection.py -y opencv-yolo-cuda/yolo-coco -i example_videos/guitar.mp4 --display=0 --use-gpu=0
[INFO] loading YOLO from disk...
[INFO] setting preferable backend and target to CUDA...
[INFO] accessing video stream...
[INFO] elasped time: 212.71
[INFO] approx. FPS: 1.16
(py3cv4) nano@nano-desktop:~/Data/opencv/opencv-dnn-gpu-examples$ python3 opencv-yolo-cuda/yolo_object_detection.py -y opencv-yolo-cuda/yolo-coco -i example_videos/guitar.mp4 --display=0
[INFO] loading YOLO from disk...
[INFO] accessing video stream...
[INFO] elasped time: 1275.95
[INFO] approx. FPS: 0.19

Mask R-CNN 測試
(py3cv4) nano@nano-desktop:~/Data/opencv/opencv-dnn-gpu-examples$ python3 opencv-mask-rcnn-cuda/mask_rcnn_segmentation.py --mask-rcnn opencv-mask-rcnn-cuda/mask-rcnn-coco/ --input example_videos/guitar.mp4 --display=0 --use-gpu=1
[INFO] loading Mask R-CNN from disk...
[INFO] setting preferable backend and target to CUDA...
[INFO] accessing video stream...
[INFO] elasped time: 445.18
[INFO] approx. FPS: 0.55
(py3cv4) nano@nano-desktop:~/Data/opencv/opencv-dnn-gpu-examples$ python3 opencv-mask-rcnn-cuda/mask_rcnn_segmentation.py --mask-rcnn opencv-mask-rcnn-cuda/mask-rcnn-coco/ --input example_videos/guitar.mp4 --display=0
[INFO] loading Mask R-CNN from disk...
[INFO] accessing video stream...
[INFO] elasped time: 4512.29
[INFO] approx. FPS: 0.05

2019年8月24日 星期六

Build OpenCV 3.4 with CUDA

Build OpenCV 3.4 on NVIDIA Jetson AGX Xavier Developer Kit

原先內建的 OpenCV 放在 /usr
心建立的會放在 /usr/local

$ git clone https://github.com/jetsonhacks/buildOpenCVXavier.git
$ cd buildOpenCVXavier
$ git checkout v1.0
$ ./buildOpenCV.sh

sudo ln -s /usr/local/lib/python3.6/dist-packages/cv2.cpython-36m-aarch64-linux-gnu.so envs/OpenAiGym/lib/python3.6/site-packages/



2018年11月17日 星期六

Build python from source

原先是為了要準備重建 OpenCV with CUDA
所以要準備 debug 版本的 python library
但是玩到後面發現,目前不需要了
費了我好多時間,所以要記錄下過程

VS2017 安裝時要選擇 Python 開發
下載安裝 Windows 10 SDK
https://www.python.org/downloads/source/
Python 3.6.7 - 2018-10-20 失敗
Python 3.6.7rc2 - 2018-10-13 選擇 Download XZ compressed source tarball
下載後解壓縮置於 D:\OpenCV_4\Python-3.6.7
開啟 powershell
到 D:\OpenCV_4\Python-3.6.7rc2\PCbuild 目錄
./build.bat -c Debug -p x64
./build.bat -c Debug -p Win32
./build.bat -t CleanAll

編譯過程會失敗,解決方法為
VS2017 開啟 D:\OpenCV_4\Python-3.6.7\PCbuild\pcbuild.sln
Property Pages/Configuration Properties/General/Windows SDK Version
10.0.17763.0
Property Pages/Configuration Properties/C/C++/Preprocessor
_X86_ 32位元
_AMD64_ 64位元



2018年11月6日 星期二

OpenCV Tesseract sample

samples/text/(sample)webcam_demo
Configuration Properties/Debugging/Environment
PATH=C:\Program Files\tesseract\bin;D:\TensorFlow\OCR\tesseract\win64\bin\Debug;D:\Anaconda3\Library\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin;%PATH%
QT_PLUGIN_PATH=D:\Anaconda3\Library\plugins

修改 webcam_demo.cpp 指定下列檔案的路徑
D:/OpenCV_4/build34/testdata/contrib/text/trained_classifierNM1.xml
D:/OpenCV_4/build34/testdata/contrib/text/trained_classifierNM2.xml
D:/OpenCV_4/build34/testdata/contrib/text/OCRHMM_knn_model_data.xml.gz

OpenCV DNN Sample Text Detection

An Efficient and Accurate Scene Text Detector
有效又精確的文字檢測

參考 EAST text detector
下載 frozen_east_text_detection.pb

samples/dnn/(sample)text_detection

Configuration Properties/Debugging/Command Arguments
--model="D:\OpenCV_4\OpenCV OCR\opencv-text-detection\frozen_east_text_detection.pb" --width=640 --height=480

Configuration Properties/Debugging/Environment
PATH=D:\TensorFlow\OCR\tesseract\win64\bin\Debug;D:\Anaconda3\Library\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin;%PATH%
QT_PLUGIN_PATH=D:\Anaconda3\Library\plugins

Edit text_detection.cpp 使用 OPENCL 加快速度(只能用 Intel, 不能使用 NVIDIA GPU)
    Net net = readNet(model);
    net.setPreferableTarget(DNN_TARGET_OPENCL);


2018年11月1日 星期四

Build OpenCV v4

目前最新的版本為 4.0.0, 穩定版本 3.4.3
查詢 opencv 版本
opencv_src\modules\core\include\opencv2\core\version.hpp
查詢 python 版本
(base) D:\OpenCV_4>python --version
Python 3.6.4 :: Anaconda, Inc.

CUDA 使用 10 版,9 or 9.1 都不行

下載 OpenCV 最新版本
(base) D:\OpenCV_4>git clone https://github.com/opencv/opencv opencv
下載指定版本
(base) D:\OpenCV_4>git clone https://github.com/opencv/opencv --branch 3.4 opencv34
更新之前下載的程式 到 遠端的最新版本
(base) D:\OpenCV_4\opencv>git pull origin master

Eigen 是一個 C++ 程式庫,支持線性代數,矩陣,向量運算
http://eigen.tuxfamily.org
解壓縮後移至 D:\OpenCV_4\dep

Intel TBB Library 不需安裝
用 Intel IPP 即可

MikTex 排版軟體
http://miktex.org/

(base) D:\OpenCV_4>python -m pip install --upgrade pip
Sphinx Python文件生成工具,支持 LaTeX(可以產生PDF)
(base) D:\OpenCV_4>pip install sphinx
NumPy 是Python語言的一個擴充程式庫。支援高階大量的維度陣列與矩陣運算。
(base) D:\OpenCV_4>pip install numpy

Visual Studio Installer 安裝
個別元件/VC++ 2017 v141 工具組

OpenCV 的額外模組
git clone https://github.com/opencv/opencv_contrib open_contrib
git clone https://github.com/opencv/opencv_contrib --branch 3.4 open_contrib_3.4

CMake
D:/OpenCV_4/opencv
D:/OpenCV_4/build_64
Visual Studio 14 2015 Win64
EIGEN_INCLUDE_PATH=D:/OpenCV_4/dep/eigen-eigen-b3f3d4950030
OPENCV/OPENCV_EXTRA_MODULES_PATH=D:\OpenCV_4\opencv34\modules
BUILD/BUILD_EXAMPLES checked

opencv_cudev 專案出現 LNK2019 cv::__termination 錯誤
修改 modules/opencv_cudev/CMakeLists.txt, 在
set(the_description "CUDA device layer")
增加下一行
set(OPENCV_SKIP_DLLMAIN_GENERATION ON)

opencv_cvv 專案 stringutils.cpp 出現 C2001, C2143, C2146 等錯誤
是因為檔案字元集的問題,開啟 stringutils.cpp, 重新存檔成
UTF-8 with signature

以下增加 Tesseract 功能,參考 Tesseract OCR 安裝
修改 modules/opencv_text/CMakeLists.txt, 增加下一行
set(Tesseract_FOUND 1)
if(NOT CMAKE_CROSSCOMPILING OR OPENCV_FIND_TESSERACT)

修改 opencv_text Property Pages/Configuration Properties/
C/C++/General/Additional Include Directories 增加
C:\Program Files\tesseract\include
Linker/General/Additional Library Directories 增加
D:\TensorFlow\OCR\tesseract\win64\Debug
C:\Program Files\tesseract\lib
Linker/Input/Additional Dependencies 增加
tesseract40d.lib (Debug)
tesseract40.lib (Release)

2017年8月29日 星期二

Raspberry OPENSSL 根證書 伺服端 客戶端

準備設定檔
pi@raspberrypi:~/OpenSSL/openssl $ cp /etc/ssl/openssl.cnf .
pi@raspberrypi:~/OpenSSL/openssl $ mkdir ca server client
pi@raspberrypi:~/OpenSSL/openssl $
產生根私鑰
pi@raspberrypi:~/OpenSSL/openssl $ openssl genrsa -out ca/ca.key 2048
Generating RSA private key, 2048 bit long modulus
..............................................................................................+++
......+++
e is 65537 (0x10001)
產生根證書
pi@raspberrypi:~/OpenSSL/openssl $ openssl req -new -x509 -key ca/ca.key -out ca
/ca.crt -days 3650
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:TW
State or Province Name (full name) [Some-State]:Taiwan
Locality Name (eg, city) []:Taichung
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SDL
Organizational Unit Name (eg, section) []:R&D
Common Name (e.g. server FQDN or YOUR name) []:PiCA
Email Address []:
pi@raspberrypi:~/OpenSSL/openssl $ ls ca
ca.crt  ca.key
pi@raspberrypi:~/OpenSSL/openssl $
產生伺服端私鑰
pi@raspberrypi:~/OpenSSL/openssl $ openssl genrsa -out server/server.key 2048
Generating RSA private key, 2048 bit long modulus
.............................+++
..............+++
e is 65537 (0x10001)
產生伺服端需求證書
pi@raspberrypi:~/OpenSSL/openssl $ openssl req -new -key server/server.key -out server/server.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:TW
State or Province Name (full name) [Some-State]:Taiwan
Locality Name (eg, city) []:Taichung
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SDL
Organizational Unit Name (eg, section) []:R&D
Common Name (e.g. server FQDN or YOUR name) []:PiServer
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
pi@raspberrypi:~/OpenSSL/openssl $ ls server/
server.csr  server.key
pi@raspberrypi:~/OpenSSL/openssl $
產生客戶端私鑰
pi@raspberrypi:~/OpenSSL/openssl $ openssl genrsa -out client/client.key 2048
Generating RSA private key, 2048 bit long modulus
..............................................+++
....................................+++
e is 65537 (0x10001)
產生客戶端需求證書
pi@raspberrypi:~/OpenSSL/openssl $ openssl req -new -key client/client.key -out
client/client.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:TW
State or Province Name (full name) [Some-State]:Taiwan
Locality Name (eg, city) []:Taichung
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SDL
Organizational Unit Name (eg, section) []:R&D
Common Name (e.g. server FQDN or YOUR name) []:PiClient
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
pi@raspberrypi:~/OpenSSL/openssl $ ls client/
client.csr  client.key
pi@raspberrypi:~/OpenSSL/openssl $
修改 dir 目錄
pi@raspberrypi:~/OpenSSL/openssl $ vi openssl.cnf
[ CA_default ]

#dir            = ./demoCA              # Where everything is kept
dir             = .             # Where everything is kept
certs           = $dir/certs            # Where the issued certs are kept
crl_dir         = $dir/crl              # Where the issued crl are kept
database        = $dir/index.txt        # database index file.
#unique_subject = no                    # Set to 'no' to allow creation of
pi@raspberrypi:~/OpenSSL/openssl $
簽署證書環境準備
pi@raspberrypi:~/OpenSSL/openssl $ touch index.txt
pi@raspberrypi:~/OpenSSL/openssl $ echo "01">serial
pi@raspberrypi:~/OpenSSL/openssl $ mkdir newcerts
簽署伺服端證書
pi@raspberrypi:~/OpenSSL/openssl $ openssl ca -in server/server.csr -out server/server.crt -days 3650 -cert ca/ca.crt -keyfile ca/ca.key -config openssl.cnf
Using configuration from openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Aug 29 02:08:38 2017 GMT
            Not After : Aug 27 02:08:38 2027 GMT
        Subject:
            countryName               = TW
            stateOrProvinceName       = Taiwan
            organizationName          = SDL
            organizationalUnitName    = R&D
            commonName                = PiServer
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:FALSE
            Netscape Comment:
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
                4D:26:A0:55:4D:37:58:EE:10:D3:A0:8E:B8:93:35:E9:E5:84:1F:BC
            X509v3 Authority Key Identifier:
                keyid:F4:6D:3E:3D:93:2A:4A:81:85:62:C3:D7:4B:70:F9:28:F6:E6:A4:F4

Certificate is to be certified until Aug 27 02:08:38 2027 GMT (3650 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
pi@raspberrypi:~/OpenSSL/openssl $ ls server/
server.crt  server.csr  server.key
pi@raspberrypi:~/OpenSSL/openssl $
簽署客戶端證書
pi@raspberrypi:~/OpenSSL/openssl $ openssl ca -in client/client.csr -out client/
client.crt -days 3650 -cert ca/ca.crt -keyfile ca/ca.key -config openssl.cnf
Using configuration from openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 2 (0x2)
        Validity
            Not Before: Aug 29 02:12:26 2017 GMT
            Not After : Aug 27 02:12:26 2027 GMT
        Subject:
            countryName               = TW
            stateOrProvinceName       = Taiwan
            organizationName          = SDL
            organizationalUnitName    = R&D
            commonName                = PiClient
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:FALSE
            Netscape Comment:
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
                45:1F:CC:47:19:FF:37:04:7A:8D:40:B8:1E:CA:08:11:36:E0:E7:EF
            X509v3 Authority Key Identifier:
                keyid:F4:6D:3E:3D:93:2A:4A:81:85:62:C3:D7:4B:70:F9:28:F6:E6:A4:F4

Certificate is to be certified until Aug 27 02:12:26 2027 GMT (3650 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
pi@raspberrypi:~/OpenSSL/openssl $ ls client/
client.crt  client.csr  client.key
pi@raspberrypi:~/OpenSSL/openssl $
pi@raspberrypi:~/OpenSSL/openssl $ ls
ca      index.txt       index.txt.attr.old  newcerts     serial      server
client  index.txt.attr  index.txt.old       openssl.cnf  serial.old
pi@raspberrypi:~/OpenSSL/openssl $


2016年11月22日 星期二

Cascade Classifier Training

開啟命令提示字元

set PATH=D:\OpenCV\build_64\install\x64\vc12\bin;%PATH%
set PATH=D:\OpenCV\dep\tbb2017_20160916oss\bin\intel64\vc12;%PATH%
set PATH=D:\Qt\Qt5.7.0_64\5.7\msvc2013_64\bin;%PATH%

cd neg
dir/b>neg.txt
編輯 neg.txt 加入檔案路徑

標註 正樣本
使用 opencv_annotation.exe
"D:\OpenCV\build_64\install\x64\vc12\bin\opencv_annotation.exe" --annotations=20160615.txt --images=20160615\*.jpg
c: add rectangle to current image
n: save added rectangles and show next image
d: delete the last annotation made
<ESC>: exit program(無法使用,請參考下列修正方式)

編輯 opencv_annotation.cpp
case 27
  //destroyWindow(window_name);
  stop = true;
  break;
不然無法用 ESC 結束程式

產生 pos.vec
"D:\OpenCV\build_64\install\x64\vc12\bin\opencv_createsamples.exe" -info pos.txt -vec pos.vec -w 50 -h 25

產生 xml
mkdir xml
"D:\OpenCV\build_64\install\x64\vc12\bin\opencv_traincascade.exe" -data xml -vec pos.vec -bg neg.txt -numPos 150 -numNeg 20 -numStages 20 -maxFalseAlarmRate 0.45 -featureType LBP -w 50 -h 25

-numPos 每級分類器訓練時所用正樣本數目
-numNeg 每級分類器訓練時所用負樣本數目,可大於 -bg 指定的圖片數目
-featureType: HAAR
-featureType: LBP
-mode BASIC 直立
-mode ALL
-minHitRate 0.999 正樣本被判成正樣本的比例
-maxFalseAlarmRate 0.5 負樣本被判成正樣本的比例

錯誤 Required leaf false alarm rate achieved. Branch training terminated.
預設 -maxFalseAlarmRate 0.5

2016年11月7日 星期一

OpenCV statusbar & mouse position

症狀:setMouseCallback 回傳函式的滑鼠位置錯誤,狀態烈沒有顯示滑鼠位置,顏色資訊
對策:開啟 modules/highgui/src/window_QT.h 將下一行增加 virtual 宣告
    void icvmouseProcessing(QPointF pt, int cv_event, int flags);
    virtual void icvmouseProcessing(QPointF pt, int cv_event, int flags);


OpenCV release 版本無法執行

症狀:debug 版本正常,release 版本的程式無法執行,出現如下錯誤
This application failed to start because it could not find or load the Qt platform plugin "windows"
in "".
原因:因為 PATH 環境變數設定錯誤,使用到錯誤的 Qt library
對策:修正 Project Property Pages/Coniguration Properties/Debugging/Environment 的 PATH
PATH=%PATH%;D:\Qt\Qt5.7.0_64\5.7\msvc2013_64\bin;
PATH=D:\Qt\Qt5.7.0_64\5.7\msvc2013_64\bin;%PATH%


除錯路上拾遺

查詢載入 plugin 的過程
設定環境變數 QT_DEBUG_PLUGINS=1
下列兩個環境變數皆可設定 plugin 的路徑
QT_QPA_PLATFORM_PLUGIN_PATH=D:\Qt\Qt5.7.0_64\5.7\msvc2013_64\plugins
QT_PLUGIN_PATH=D:\Qt\Qt5.7.0_64\5.7\msvc2013_64\plugins

編譯 Qt source
1. 新版的 Qt 編譯不能使用 vs2013,要使用 Visual C++ Build Tools(Visual Studio 2015)
2. 編譯需要跳過一些模組
configure.bat -release -nomake examples -skip qtscript

2016年10月26日 星期三

findContours, drawContours

findContours
Non-zero pixels are treated as 1's. Zero pixels remain 0's, so the image is treated as binary.
0: 黑, 255(白)
以黑為背景,尋找灰白的前景邊界

hierarchy
the elements hierarchy[i][0] , hiearchy[i][1] , hiearchy[i][2] , and hiearchy[i][3] are set to 0-based indices in contours of the next and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively.
0: 下一個
1: 上一個
2: 第一個兒子
3: 父親
If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.
沒有就是 -1

RETR_EXTERNAL
It sets hierarchy[i][2]=hierarchy[i][3]=-1 for all the contours.

RETR_CCOMP
所有邊界分為兩層, 白的外圈, 和內圈
hierarchy[i][3]=-1 for all the contours.

drawContours


2016年10月25日 星期二

Build OpenCV v3

下載安裝 git for windows

下載安裝 TortoiseGit, 設定 git for windows 的位置

建立目錄 D:/OpenCV
Clone the repository to D:\OpenCV from https://github.com/Itseez/opencv.git

下載安裝 CMake

除了分別下載安裝 python35_32, python35_64, 也要下載 Source

安裝 Setuptools
下載 ez_setup.py 置於 D:\Python35 下
執行 D:\Python35>python ez_setup.py

Install Sphinx via the command:
D:\Python35\Scripts\easy_inatall.exe sphinx

安裝 NumPy
cd D:\Python35\Scripts
pip install numpy

用 VS2013 開啟 PCbuild/pcbuild.sln, 主要建立 python 專案
可以建立出32位元 PCbuild/win32/python35_d.lib並且拷貝至 Python35_32/libs 下
64位元 PCbuild/amd64/python35_d.lib並且拷貝至 Python35_64/libs 下

Download and install Miktex: http://miktex.org/.
At the fourth step make sure you select for the "Install missing packages" the Yes option.
Miktex 只使用 64位元

Download the Intel TBB library: https://www.threadingbuildingblocks.org/, 選擇 Windows 版本
Extract it.
Create a dep directory in your OpenCV folder.
And copy the extracted files here.

Do the same with the eigen files: eigen.tuxfamily.org

下載 CUDA Toolkit 8.0 選擇 Windows 版本

安裝32和64位元的 Qt5.7 for VS2013, 於不同目錄

開啟 CMake
Where is the source code: D:/OpenCV/opencv
Where to build the binaries: D:.OpenCV/build_64
按 Configure 選擇 Visual Studio 12 2013 Win64
按 Generate, 此時會產生錯誤, 需要設定下列目錄
EIGEN_INCLUDE_PATH=D:\OpenCV\dep\eigen
開啟 PYTHON3 設定正確的版本位置
PYTHON3_EXECUTABLE=D:/Python35_32/python.exe
PYTHON3_INCLUDE_DIR=D:/Python35_32/include
PYTHON3_LIBRARY=D:/Python35_32/libs/python35.lib
PYTHON3_LIBRARY_DEBUG=D:/Python35_32/libs/python35_d.lib
PYTHON3_NUMPY_INCLUDE_DIRS=D:/Python35_32/Lib/site-packages/numpy/core/include
PYTHON3_PACKAGES_PATH=D:/Python35_32/Lib/site-packages
開啟 WITH_QT, WITH_TBB, WITH_CUDA
按 Generate, 此時會產生錯誤, 需要設定下列目錄
QT_QMAKE_EXECUTABLE=D:/Qt/Qt5.7.0_64/5.7/msvc2013/bin/qmake.exe
Qt5Concurrent_DIR=D:/Qt/Qt5.7.0_64/5.7/msvc2013/lib/cmake/Qt5Concurrent
Qt5Core_DIR=D:/Qt/Qt5.7.0_64/5.7/msvc2013/lib/cmake/Qt5Core
Qt5Gui_DIR=D:/Qt/Qt5.7.0_64/5.7/msvc2013/lib/cmake/Qt5Gui
Qt5OpenGL_DIR=D:/Qt/Qt5.7.0_64/5.7/msvc2013/lib/cmake/Qt5OpenGL
Qt5Test_DIR=D:/Qt/Qt5.7.0_64/5.7/msvc2013/lib/cmake/Qt5Test
Qt5Widgets_DIR=D:/Qt/Qt5.7.0_64/5.7/msvc2013/lib/cmake/Qt5Widgets
TBB_INCLUDE_DIRS=D:/OpenCV/dep/tbb2017_20160916oss/include

開啟 CMake
Where is the source code: D:/OpenCV/opencv
Where to build the binaries: D:.OpenCV/build_32
按 Configure 選擇 Visual Studio 12 2013
按 Generate, 此時會產生錯誤, 需要設定下列目錄
EIGEN_INCLUDE_PATH=D:\OpenCV\dep\eigen
開啟 PYTHON3 設定正確的版本位置
開啟 WITH_QT, WITH_TBB
關閉 WITH_CUDA, 因為 CUDA 沒有 32 位元版本
按 Generate, 此時會產生錯誤, 需要設定下列目錄
QT_QMAKE_EXECUTABLE=D:/Qt/Qt5.7.0_32/5.7/msvc2013/bin/qmake.exe
Qt5Concurrent_DIR=D:/Qt/Qt5.7.0_32/5.7/msvc2013/lib/cmake/Qt5Concurrent
Qt5Core_DIR=D:/Qt/Qt5.7.0_32/5.7/msvc2013/lib/cmake/Qt5Core
Qt5Gui_DIR=D:/Qt/Qt5.7.0_32/5.7/msvc2013/lib/cmake/Qt5Gui
Qt5OpenGL_DIR=D:/Qt/Qt5.7.0_32/5.7/msvc2013/lib/cmake/Qt5OpenGL
Qt5Test_DIR=D:/Qt/Qt5.7.0_32/5.7/msvc2013/lib/cmake/Qt5Test
Qt5Widgets_DIR=D:/Qt/Qt5.7.0_32/5.7/msvc2013/lib/cmake/Qt5Widgets
TBB_INCLUDE_DIRS=D:/OpenCV/dep/tbb2017_20160916oss/include

用 VisualStudio2013 開啟 D:\OpenCV\Builds\OpenCV.sln
選擇 ALL_BUILD, Build Debug 和 Release
選擇 INSTALL, Build Debug 和 Release



2016年10月19日 星期三

OpenCV 之 waitKey 使用

waitKey 除了不能區分大小寫,最慘的是和中文輸入法打架
使用 ImmDisableIME(-1); 關閉輸入法

2016年6月3日 星期五

安裝 OpenCV 應用程式紀錄

32位元和64位元要分開使用 InstallShield

InstallShield Limited Edition Project

Project Assistant/Application Files
按 Add Project Outputs,勾選 Primary Output
64位元安裝要領
在 Destination Computer 上按滑鼠右鍵選 Show Predefined Folder/ProgramFiles64Folder
再將 ProgramFilesFolder 下的資料拖到 ProgramFiles64Folder

Specify Application Data/Redistributables
32位元勾選
Visual C++ 12.0 MFC (x86)
Visual C++ 12.0 CRT (x86)
64位元勾選
Visual C++ 12.0 MFC (x64)
Visual C++ 12.0 CRT (x64)

Configure the Target System/Shortcuts/folders
新增捷徑,注意在專案中增加一個 ico 檔
在捷徑的選項內選擇該檔案

除了安裝主程式外
有用vlc3.0, 所以要複製
OpenCV 的 build/install
OpenCV 相依(dep)的 tbb, qt5
下載安裝 CUDA Toolkit

PATH 環境變數加上下列路徑
C:\VLC-3.0.0\vlc-3.0.0-win64
C:\OpenCV\build_64\install\x64\vc12\bin
C:\OpenCV\dep\qt5_64\qtbase\bin
C:\OpenCV\dep\tbb43_20140724oss\bin\intel64\vc12
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin

2014年9月2日 星期二

Build OpenCV v2

使用 Python 2.7, 不要用 Python 3.4, 雖然只是無法Build OpenCV documents
Python有32和64位元, 要分別安裝
Python的debug版本, 要下載 Python 的 source, 用 VS2013 開啟 PCbuild/pcbuild.sln
可以建立出32位元 PCbuild/python27_d.dll並且拷貝至 Python27/libs 下
64位元會置於 PCbuild/amd64/python27_d.dll 下

因為 Intel IPP 會 Build 進 OpenCV 的 library
所以在安裝 Intel IPP 之前,可先建立一版沒有 Intel Ipp 的 OpenCV Library

  1. Microsoft Visual Studio
  2. Download CMake: www.cmake.org
    ... and install it.
    選 Do not add Cmake to system PATH
  3. Download msysgit and install it.
    msysgit 已經改成 git for windows
    Download TortoiseGit: http://code.google.com/p/tortoisegit/
    ... and install it.
    Note: After this you may need to restart your system.
  4. 建立目錄 C:/OpenCV
    Clone the repository to C:\OpenCV from https://github.com/Itseez/opencv.git
    1. Download Python: https://www.python.org/downloads/ and install it.
      若是使用 Python34 版本,會在建立文件時出錯,為了確認這一點,花了不少時間。
      下載x86(32位元)和amd64(64位元)版本,分別安裝於不同目錄。
      安裝 Setuptools
      下載 ez_setup.py 置於 C:\Python27_32 下
      執行 C:\Python27_32>python ez_setup.py
    2. Start up a command window and navigate to your Python install Scripts folder.
      Install Sphinx via the command:
      C:\Python27_32\Scripts\easy_inatall.exe sphinx
    3. Download and install Numpy: http://sourceforge.net/projects/numpy/files/NumPy/1.8.2/
      注意相對 Python 的版本, 只能下載到32位元, 所以一定會找 Python 32位元版
    4. Download and install Miktex: http://miktex.org/.
      At the fourth step make sure you select for the "Install missing packages" the Yes option.
    5. Download the Intel TBB library: https://www.threadingbuildingblocks.org/, 選擇 Windows 版本
      Extract it.
      Create a dep directory in your OpenCV folder.
      And copy the extracted files here.
    6. Do the same with the eigen files: eigen.tuxfamily.org
    7. And again with the OpenEXR source files: http://www.openexr.com/
      這個好像不用裝。
    8. For OpenNI first download and install the binaries:
      http://www.openni.org/downloadfiles/opennimodules
      Then the PrimeSensor moudle (OpenNI Compliant Hardware Binaries).
      我沒有這個東西。
    9. 從 https://developer.nvida.com/cuda-downloads 下載 CUDA Toolkit
      它有分成Notebook, Desktop, 32/64 等四個版本,請選一個
    10. Qt - You first need to download the source files: http://qt-project.org/
      Then extract them to a final path (should be a short one).
      When finished start up a Visual Studio Command Prompt (2013) from the start menu.
      Navigate to your Qt folder.
      Now enter the command: configure.exe -release -no-webkit -no-phonon -no-phorion -backend -no-script -no-scripttools -no-qt3support -no-multimedia -no-itcg
      Answer to the license agreement.
      Then wait as it could easily take up to a half hour to finish.
      Once finished just enter the nmake command.
      Building the library will take a lot longer then the previous step...
      QT5 64bit 參考如下:
      add C:\Python27_64 to PATH
      開啟 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts\VS2013 x64 Native Tools Command Prompt
      set QMAKESPEC=C:\OpenCV\dep\qt5_64\qtbase\mkspecs\win32-msvc2013
      configure.bat -debug-and-release -platform win32-msvc2013 -nomake examples
      nmake
      若是失敗要重來,就整個目錄刪除比較快。
      add C:\OpenCV\dep\qt5_64 to QTDIR
      add C:\OpenCV\dep\qt5_64\qtbase\bin to PATH
      QT5 32bit 參考如下:
      add C:\Python27_32 to PATH
      開啟 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts\VS2013 x86 Native Tools Command Prompt
      set QMAKESPEC=C:\OpenCV\dep\qt5_32\qtbase\mkspecs\win32-msvc2013
      configure.bat -debug-and-release -platform win32-msvc2013 -nomake examples
      nmake
      若是失敗要重來,就整個目錄刪除比較快。
      add C:\OpenCV\dep\qt5_32 to QTDIR
      add C:\OpenCV\dep\qt5_32\qtbase\bin to PATH
  5. Now we can build the OpenCV library.
    First start the CMake Gui from the start menu.
    Then select where your source files are and where your want your build files to be.
    Choose the compiler (IDE) you use.
    Note: They are different compiler for 32 and 64 bit.
    CMake will try to search for as many libraries as possible.
    For the ones he cannot find a NOTFOUND constant is set.
    You need to specify these manually.
    Under the WITH group you can select which 3th party libraries to use for the build.
    Under the BUILD group you can specify which extra OpenCV parts to build.
    Set all not found constant to the correct path.
    In ENABLE group enable the solution folders in order to make an organized Visual Studio solution.
    Look arund the items and set any further not found constants.
    Then press the configure button to test them.
    This will bring up some new not found constants. specify them manually.
    Then press again the configure for validation.
    Repeat this procedure until all the entries are accepted.
    Then press the Generate to make the solution and project files.
    Now in the build directory you have the OpenCV solution. Open it.
    Then Build the ALL_BUILD project.
    Do it for both the Debug and Release configuration.
    Depanding on just how much of OpenCV you are building this can take quite long...
    If you haven't yet you might need to add the Intel TBB bin folders content to the system path. Again use the Path Editor.
    To test if your build works start up the generated exe files from your build directory.
    For example contours.exe...
    To collect the built binary files into a single folder built the install project.
    In the install folder you will have all the files of OpenCV that you will use inside your projects.
    That's it. You are done!
    以下步驟紀錄:
    Visual Studio 12 ==> VS2013 x86
    Visual Studio 12 Win64 ==> VS2013 x64
    勾選 Grouped 和 Advanced
    SPHINX_BUILD=C:/Python27/Scripts/sphinx-build.exe
    EIGEN_INCLUDE_PATH=C:/OpenCV/dep/eigen
    選 WITH_QT
    QT_QMAKE_EXECUTABLE=C:/OpenCV/dep/qt5_64/qtbase/qmake/qmake.exe
    Qt5OpenGL_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5OpenGL
    Qt5Concurrent_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Concurrent
    Qt5Core_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Core
    Qt5Gui_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Gui
    Qt5Test_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Gui
    Qt5Widgets_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Widgets
    選 WITH_TBB, 不選 BUILD_TBB
    TBB_INCLUDE_DIRS=C:/OpenCV/dep/tbb42_20140122oss/include
    TBB_LIB_DIR=C:/OpenCV/dep/tbb42_20140122oss/lib/ia32/vc12
    TBB_STDDEF_PATH=C:/OpenCV/dep/tbb42_20140122oss/include/tbb/tbb_stddef.h
    選 WITH_IPP, WITH_IPP_A
    IPP_A_INCLUDE_DIR=C:/Program Files (x86)/Intel/IPP Preview 2014 February/ipp/include
    IPP_A_LIBRARIES=C:/Program Files (x86)/Intel/IPP Preview 2014 February/ipp/lib/intel64/ipp_async_preview.lib
    PYTHON_INCLUDE_DIR=C:/Python27/include
    PYTHON_LIBRARY=C:/Python27/libs/python27.lib
    PYTHON_LIBRARY_RELEASE=C:/Python27/libs/python27.lib
  6. 用 VisualStudio2013 開啟 C:\OpenCV\Builds\OpenCV.sln
    Build Debug 會有一個失敗,因為缺少 python27_d.lib
    Build Release
    Build documentation/docs or documentation/html_docs 單獨的
    Build CMakeTargets/INSTALL 單獨的
  7. 設定下列環境變數以便 VisualStudio2013專案 使用
    TBB_DIR_32=C:\OpenCv\dep\tbb43_20140724oss\bin\ia32\vc12
    TBB_DIR_32_ui=C:\OpenCv\dep\tbb43_20140724oss\bin\ia32\vc12_ui
    TBB_DIR_64=C:\OpenCv\dep\tbb43_20140724oss\bin\intel64\vc12
    TBB_DIR_64_ui=C:\OpenCv\dep\tbb43_20140724oss\bin\intel64\vc12_ui
    OPENCV_BIN_32=C:\OpenCv\build_32\install\x86\vc12\bin
    OPENCV_BIN_32_IPP=C:\OpenCv\build_32_ipp\install\x86\vc12\bin
    OPENCV_BIN_64=C:\OpenCv\build_64\install\x64\vc12\bin
    OPENCV_BIN_64_IPP=C:\OpenCv\build_64_ipp\install\x64\vc12\bin
    OPENCV_INC_32=C:\OpenCv\build_32\install\include
    OPENCV_INC_32_IPP=C:\OpenCv\build_32_ipp\install\include
    OPENCV_INC_64=C:\OpenCv\build_64\install\include
    OPENCV_INC_64_IPP=C:\OpenCv\build_64_ipp\install\include
    OPENCV_LIB_32=C:\OpenCv\build_32\install\x86\vc12\lib
    OPENCV_LIB_32_IPP=C:\OpenCv\build_32_ipp\install\x86\vc12\lib
    OPENCV_LIB_64=C:\OpenCv\build_64\install\x64\vc12\lib
    OPENCV_LIB_64_IPP=C:\OpenCv\build_64_ipp\install\x64\vc12\lib
    刪除Path內的C:\OpenCV\dep\qt5_64\qtbase\bin, 另外新增下列兩環境變數
    QT5_32=C:\OpenCV\dep\qt5_32\qtbase\bin
    QT5_64=C:\OpenCV\dep\qt5_64\qtbase\bin
    32/64位元,且有無IPP一樣 Debug Additional Dependencies
    opencv_calib3d300d.lib
    opencv_core300d.lib
    opencv_features2d300d.lib
    opencv_flann300d.lib
    opencv_highgui300d.lib
    opencv_imgcodecs300d.lib
    opencv_imgproc300d.lib
    opencv_ml300d.lib
    opencv_objdetect300d.lib
    opencv_photo300d.lib
    opencv_shape300d.lib
    opencv_stitching300d.lib
    opencv_superres300d.lib
    opencv_ts300d.lib
    opencv_video300d.lib
    opencv_videoio300d.lib
    opencv_videostab300d.lib
    32/64位元,且有無IPP一樣 Release Additional Dependencies
    opencv_calib3d300.lib
    opencv_core300.lib
    opencv_features2d300.lib
    opencv_flann300.lib
    opencv_highgui300.lib
    opencv_imgcodecs300.lib
    opencv_imgproc300.lib
    opencv_ml300.lib
    opencv_objdetect300.lib
    opencv_photo300.lib
    opencv_shape300.lib
    opencv_stitching300.lib
    opencv_superres300.lib
    opencv_ts300.lib
    opencv_video300.lib
    opencv_videoio300.lib
    opencv_videostab300.lib

2014年6月3日 星期二

OpenCV 開發

執行時會出現 Cannot find or open the PDB file 錯誤
開啟 Tools -> Options -> Debugging -> symbols 並且勾選 "Microsoft Symbol Servers"
程式執行一遍,這次速度會很慢,因為要下載 .pdb 檔
此時再取消 Microsoft Symbol Servers
程式再執行一遍,若是還有找不到 PDB 檔,則輸入在 Specify excluded modules

執行時出現 無法找到程序輸入點 InitializeCriticalSectionEx (在動態連結程式庫 KERNEL32.dll)。錯誤
是因為Intel TBB在XP上產生的錯


2014年5月23日 星期五

Build OpenCV

  1. Microsoft Visual Studio
  2. Download CMake: www.cmake.org
    ... and install it.
    選 Do not add Cmake to system PATH
  3. Download msysgit and install it.
    msysgit 已經改成 git for windows
    Download TortoiseGit: http://code.google.com/p/tortoisegit/
    ... and install it.
    Note: After this you may need to restart your system.
  4. 建立目錄 C:/OpenCV
    Clone the repository to C:\OpenCV from https://github.com/Itseez/opencv.git
    1. Download Python: https://www.python.org/downloads/ and install it.
      若是使用 Python34 版本,會在建立文件時出錯,為了確認這一點,花了不少時間。
      下載x86(32位元)和amd64(64位元)版本,分別安裝於不同目錄。
      安裝 Setuptools
      下載 ez_setup.py 置於 C:\Python27_32 下
      執行 C:\Python27_32>python ez_setup.py
    2. Start up a command window and navigate to your Python install Scripts folder.
      Install Sphinx via the command:
      C:\Python27_32\Scripts\easy_inatall.exe sphinx
    3. Download and install Numpy: http://sourceforge.net/projects/numpy/files/NumPy/1.8.1/
      注意相對 Python 的版本
    4. Download and install Miktex: http://miktex.org/.
      At the fourth step make sure you select for the "Install missing packages" the Yes option.
    5. Download the Intel TBB library: https://www.threadingbuildingblocks.org/, 選擇 Windows 版本
      Extract it.
      Create a dep directory in your OpenCV folder.
      And copy the extracted files here.
    6. Do the same with the eigen files: eigen.tuxfamily.org
    7. And again with the OpenEXR source files: http://www.openexr.com/
      這個好像不用裝。
    8. For OpenNI first download and install the binaries:
      http://www.openni.org/downloadfiles/opennimodules
      Then the PrimeSensor moudle (OpenNI Compliant Hardware Binaries).
      我沒有這個東西。
    9. To use CUDA you need to install the latest CUDA Toolkit...
      and the Cuda Tools SDK.
      CUDA 並不支援 VS2013
    10. Qt - You first need to download the source files: http://qt-project.org/
      Then extract them to a final path (should be a short one).
      When finished start up a Visual Studio Command Prompt (2010) from the start menu.
      Navigate to your Qt folder.
      Now enter the command: configure.exe -release -no-webkit -no-phonon -no-phorion -backend -no-script -no-scripttools -no-qt3support -no-multimedia -no-itcg
      Answer to the license agreement.
      Then wait as it could easily take up to a half hour to finish.
      Once finished just enter the nmake command.
      Building the library will take a lot longer then the previous step...
      QT5 64bit 參考如下:
      add C:\Python27_64 to PATH
      開啟 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts\VS2013 x64 Native Tools Command Prompt
      set QMAKESPEC=C:\OpenCV\dep\qt5_64\qtbase\mkspecs\win32-msvc2013
      configure.bat -debug-and-release -platform win32-msvc2013 -nomake examples
      nmake
      若是失敗要重來,就整個目錄刪除比較快。
      add C:\OpenCV\dep\qt5_64 to QTDIR
      add C:\OpenCV\dep\qt5_64\qtbase\bin to PATH
      QT5 32bit 參考如下:
      add C:\Python27_32 to PATH
      開啟 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts\VS2013 x86 Native Tools Command Prompt
      set QMAKESPEC=C:\OpenCV\dep\qt5_32\qtbase\mkspecs\win32-msvc2013
      configure.bat -debug-and-release -platform win32-msvc2013 -nomake examples
      nmake
      若是失敗要重來,就整個目錄刪除比較快。
      add C:\OpenCV\dep\qt5_32 to QTDIR
      add C:\OpenCV\dep\qt5_32\qtbase\bin to PATH
  5. Now we can build the OpenCV library.
    First start the CMake Gui from the start menu.
    Then select where your source files are and where your want your build files to be.
    Choose the compiler (IDE) you use.
    Note: They are different compiler for 32 and 64 bit.
    CMake will try to search for as many libraries as possible.
    For the ones he cannot find a NOTFOUND constant is set.
    You need to specify these manually.
    Under the WITH group you can select which 3th party libraries to use for the build.
    Under the BUILD group you can specify which extra OpenCV parts to build.
    Set all not found constant to the correct path.
    In ENABLE group enable the solution folders in order to make an organized Visual Studio solution.
    Look arund the items and set any further not found constants.
    Then press the configure button to test them.
    This will bring up some new not found constants. specify them manually.
    Then press again the configure for validation.
    Repeat this procedure until all the entries are accepted.
    Then press the Generate to make the solution and project files.
    Now in the build directory you have the OpenCV solution. Open it.
    Then Build the ALL_BUILD project.
    Do it for both the Debug and Release configuration.
    Depanding on just how much of OpenCV you are building this can take quite long...
    If you haven't yet you might need to add the Intel TBB bin folders content to the system path. Again use the Path Editor.
    To test if your build works start up the generated exe files from your build directory.
    For example contours.exe...
    To collect the built binary files into a single folder built the install project.
    In the install folder you will have all the files of OpenCV that you will use inside your projects.
    That's it. You are done!
    以下步驟紀錄:
    Visual Studio 12 ==> VS2013 x86
    Visual Studio 12 Win64 ==> VS2013 x64
    勾選 Grouped 和 Advanced
    SPHINX_BUILD=C:/Python27/Scripts/sphinx-build.exe
    EIGEN_INCLUDE_PATH=C:/OpenCV/dep/eigen
    選 WITH_QT
    QT_QMAKE_EXECUTABLE=C:/OpenCV/dep/qt5_64/qtbase/qmake/qmake.exe
    Qt5OpenGL_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5OpenGL
    Qt5Concurrent_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Concurrent
    Qt5Core_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Core
    Qt5Gui_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Gui
    Qt5Test_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Gui
    Qt5Widgets_DIR=C:/OpenCV/dep/qt5_64/qtbase/lib/cmake/Qt5Widgets
    選 WITH_TBB, 不選 BUILD_TBB
    TBB_INCLUDE_DIRS=C:/OpenCV/dep/tbb42_20140122oss/include
    TBB_LIB_DIR=C:/OpenCV/dep/tbb42_20140122oss/lib/ia32/vc12
    TBB_STDDEF_PATH=C:/OpenCV/dep/tbb42_20140122oss/include/tbb/tbb_stddef.h
    選 WITH_IPP, WITH_IPP_A
    IPP_A_INCLUDE_DIR=C:/Program Files (x86)/Intel/IPP Preview 2014 February/ipp/include
    IPP_A_LIBRARIES=C:/Program Files (x86)/Intel/IPP Preview 2014 February/ipp/lib/intel64/ipp_async_preview.lib
    PYTHON_INCLUDE_DIR=C:/Python27/include
    PYTHON_LIBRARY=C:/Python27/libs/python27.lib
    PYTHON_LIBRARY_RELEASE=C:/Python27/libs/python27.lib
  6. 用 VisualStudio2013 開啟 C:\OpenCV\Builds\OpenCV.sln
    Build Debug 會有一個失敗,因為缺少 python27_d.lib
    Build Release
    Build documentation/docs or documentation/html_docs 單獨的
    Build CMakeTargets/INSTALL 單獨的