原文链接: opencvjs 安装 windows ubuntu
上一篇: opencvjs 磨皮美颜
下一篇: js 显示矩阵形式的图片
opencv-node
https://github.com/peterbraden/node-opencv
windows 未成功
mac 没有...
ubuntu 1804 虚拟机未成功
https://www.learnopencv.com/install-opencv-4-on-ubuntu-18-04/
需要完整安装两个博客列出的所有包,才能进行make,否则报错
1 2 3 | |
We are also going to clean build
directories and create installation
directory.
1 2 3 | |
1 2 3 | |
Finally, we will be storing the current working directory in cwd
variable. We are also going to refer to this directory as OpenCV_Home_Dir throughout this blog.
1 2 | |
1 2 | |
If you are still not able to install OpenCV on your system, but want to get started with it, we suggest using our docker images with pre-installed OpenCV, Dlib, miniconda and jupyter notebooks along with other dependencies as described in this blog .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
Looking for installation script for OpenCV 3.4.4 on Ubuntu 18.04 ? Have a look at this blog .
1 2 3 | |
We are also going to install virtualenv
and virtualenvwrapper
modules to create Python virtual environments.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Download Installation Script
To easily follow along this tutorial, please download installation script by clicking on the button below. It’s FREE!
1 2 3 4 5 6 7 8 9 |
|
First we navigate to the build directory.
1 2 3 | |
Next, we start the compilation and installation process.
1 2 3 4 5 6 7 8 9 10 11 | |
For system wide installation of OpenCV, change CMAKE_INSTALL_PREFIX to CMAKE_INSTALL_PREFIX=/usr/local \ .
1 2 | |
Using CMakeLists.txt
The basic structure of your CMakeLists.txt will be as follows:
1 2 3 4 | |
You will have to set OpenCV_DIR as shown below.
1 | |
Make sure that you replace OpenCV_Home_Dir with correct path. For example, in my case:
1 | |
Once you have made your CMakeLists.txt, follow the steps given below.
1 2 3 | |
This will generate your executable file in build directory.
To use the OpenCV version installed using Python script, first we activate the correct Python Virtual Environment.
For OpenCV-4 : Python 3
1 | |
Once you have activated the virtual environment, you can enter Python shell and test OpenCV version.
1 2 3 | |
- GCC 4.4.x or later
- CMake 2.6 or higher
- Git
- GTK+2.x or higher, including headers (libgtk2.0-dev)
- pkg-config
- Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
- ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
- [optional] libtbb2 libtbb-dev
- [optional] libdc1394 2.x
- [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
The packages can be installed using a terminal and the following commands or by using Synaptic Manager:
[compiler] sudo apt-get install build-essential [required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev [optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
You can use the latest stable OpenCV version available in sourceforge or you can grab the latest snapshot from our Git repository .
Launch Git client and clone OpenCV repository
In Linux it can be achieved with the following command in Terminal:
cd ~/<my_working _directory> git clone https://github.com/opencv/opencv.git
Create a temporary directory, which we denote as <cmake_binary_dir>, where you want to put the generated Makefiles, project files as well the object files and output binaries.
Enter the <cmake_binary_dir> and type
cmake [<some optional parameters>] <path to the OpenCV source directory>
For example
cd ~/opencv mkdir release cd release cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
Enter the created temporary directory (<cmake_binary_dir>) and proceed with:
make sudo make install