feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/images/fedora_logo.jpg
vendored
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/images/opencv_logo.jpg
vendored
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/images/windows_logo.jpg
vendored
Normal file
After Width: | Height: | Size: 3.1 KiB |
86
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_intro/py_intro.markdown
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
Introduction to OpenCV-Python Tutorials {#tutorial_py_intro}
|
||||
=======================================
|
||||
|
||||
OpenCV
|
||||
------
|
||||
|
||||
OpenCV was started at Intel in 1999 by **Gary Bradsky**, and the first release came out in 2000.
|
||||
**Vadim Pisarevsky** joined Gary Bradsky to manage Intel's Russian software OpenCV team. In 2005,
|
||||
OpenCV was used on Stanley, the vehicle that won the 2005 DARPA Grand Challenge. Later, its active
|
||||
development continued under the support of Willow Garage with Gary Bradsky and Vadim Pisarevsky
|
||||
leading the project. OpenCV now supports a multitude of algorithms related to Computer Vision and
|
||||
Machine Learning and is expanding day by day.
|
||||
|
||||
OpenCV supports a wide variety of programming languages such as C++, Python, Java, etc., and is
|
||||
available on different platforms including Windows, Linux, OS X, Android, and iOS. Interfaces for
|
||||
high-speed GPU operations based on CUDA and OpenCL are also under active development.
|
||||
|
||||
OpenCV-Python is the Python API for OpenCV, combining the best qualities of the OpenCV C++ API and
|
||||
the Python language.
|
||||
|
||||
OpenCV-Python
|
||||
-------------
|
||||
|
||||
OpenCV-Python is a library of Python bindings designed to solve computer vision problems.
|
||||
|
||||
Python is a general purpose programming language started by **Guido van Rossum** that became very
|
||||
popular very quickly, mainly because of its simplicity and code readability. It enables the
|
||||
programmer to express ideas in fewer lines of code without reducing readability.
|
||||
|
||||
Compared to languages like C/C++, Python is slower. That said, Python can be easily extended with
|
||||
C/C++, which allows us to write computationally intensive code in C/C++ and create Python wrappers
|
||||
that can be used as Python modules. This gives us two advantages: first, the code is as fast as the
|
||||
original C/C++ code (since it is the actual C++ code working in background) and second, it easier to
|
||||
code in Python than C/C++. OpenCV-Python is a Python wrapper for the original OpenCV C++
|
||||
implementation.
|
||||
|
||||
OpenCV-Python makes use of **Numpy**, which is a highly optimized library for numerical operations
|
||||
with a MATLAB-style syntax. All the OpenCV array structures are converted to and from Numpy arrays.
|
||||
This also makes it easier to integrate with other libraries that use Numpy such as SciPy and
|
||||
Matplotlib.
|
||||
|
||||
OpenCV-Python Tutorials
|
||||
-----------------------
|
||||
|
||||
OpenCV introduces a new set of tutorials which will guide you through various functions available in
|
||||
OpenCV-Python. **This guide is mainly focused on OpenCV 3.x version** (although most of the
|
||||
tutorials will also work with OpenCV 2.x).
|
||||
|
||||
Prior knowledge of Python and Numpy is recommended as they won't be covered in this guide.
|
||||
**Proficiency with Numpy is a must in order to write optimized code using OpenCV-Python.**
|
||||
|
||||
This tutorial was originally started by *Abid Rahman K.* as part of the Google Summer of Code 2013
|
||||
program under the guidance of *Alexander Mordvintsev*.
|
||||
|
||||
OpenCV Needs You !!!
|
||||
--------------------
|
||||
|
||||
Since OpenCV is an open source initiative, all are welcome to make contributions to the library,
|
||||
documentation, and tutorials. If you find any mistake in this tutorial (from a small spelling
|
||||
mistake to an egregious error in code or concept), feel free to correct it by cloning OpenCV in
|
||||
[GitHub](https://github.com/opencv/opencv) and submitting a pull request. OpenCV developers will
|
||||
check your pull request, give you important feedback and (once it passes the approval of the
|
||||
reviewer) it will be merged into OpenCV. You will then become an open source contributor :-)
|
||||
|
||||
As new modules are added to OpenCV-Python, this tutorial will have to be expanded. If you are
|
||||
familiar with a particular algorithm and can write up a tutorial including basic theory of the
|
||||
algorithm and code showing example usage, please do so.
|
||||
|
||||
Remember, we **together** can make this project a great success !!!
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
Below is the list of contributors who submitted tutorials to OpenCV-Python.
|
||||
|
||||
-# Alexander Mordvintsev (GSoC-2013 mentor)
|
||||
2. Abid Rahman K. (GSoC-2013 intern)
|
||||
|
||||
Additional Resources
|
||||
--------------------
|
||||
|
||||
-# A Quick guide to Python - [A Byte of Python](http://swaroopch.com/notes/python/)
|
||||
2. [NumPy Quickstart tutorial](https://numpy.org/devdocs/user/quickstart.html)
|
||||
3. [NumPy Reference](https://numpy.org/devdocs/reference/index.html#reference)
|
||||
4. [OpenCV Documentation](http://docs.opencv.org/)
|
||||
5. [OpenCV Forum](https://forum.opencv.org/)
|
246
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.markdown
vendored
Normal file
@ -0,0 +1,246 @@
|
||||
Install OpenCV-Python in Fedora {#tutorial_py_setup_in_fedora}
|
||||
===============================
|
||||
|
||||
Goals
|
||||
-----
|
||||
|
||||
In this tutorial
|
||||
- We will learn to setup OpenCV-Python in your Fedora system. Below steps are tested for
|
||||
Fedora 18 (64-bit) and Fedora 19 (32-bit).
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
OpenCV-Python can be installed in Fedora in two ways, 1) Install from pre-built binaries available
|
||||
in fedora repositories, 2) Compile from the source. In this section, we will see both.
|
||||
|
||||
Another important thing is the additional libraries required. OpenCV-Python requires only **Numpy**
|
||||
(in addition to other dependencies, which we will see later). But in this tutorials, we also use
|
||||
**Matplotlib** for some easy and nice plotting purposes (which I feel much better compared to
|
||||
OpenCV). Matplotlib is optional, but highly recommended. Similarly we will also see **IPython**, an
|
||||
Interactive Python Terminal, which is also highly recommended.
|
||||
|
||||
Installing OpenCV-Python from Pre-built Binaries
|
||||
------------------------------------------------
|
||||
|
||||
Install all packages with following command in terminal as root.
|
||||
@code{.sh}
|
||||
$ yum install numpy opencv*
|
||||
@endcode
|
||||
Open Python IDLE (or IPython) and type following codes in Python terminal.
|
||||
@code{.py}
|
||||
>>> import cv2 as cv
|
||||
>>> print( cv.__version__ )
|
||||
@endcode
|
||||
If the results are printed out without any errors, congratulations !!! You have installed
|
||||
OpenCV-Python successfully.
|
||||
|
||||
It is quite easy. But there is a problem with this. Yum repositories may not contain the latest
|
||||
version of OpenCV always. For example, at the time of writing this tutorial, yum repository contains
|
||||
2.4.5 while latest OpenCV version is 2.4.6. With respect to Python API, latest version will always
|
||||
contain much better support. Also, there may be chance of problems with camera support, video
|
||||
playback etc depending upon the drivers, ffmpeg, gstreamer packages present etc.
|
||||
|
||||
So my personal preference is next method, i.e. compiling from source. Also at some point in time,
|
||||
if you want to contribute to OpenCV, you will need this.
|
||||
|
||||
Installing OpenCV from source
|
||||
-----------------------------
|
||||
|
||||
Compiling from source may seem a little complicated at first, but once you succeeded in it, there is
|
||||
nothing complicated.
|
||||
|
||||
First we will install some dependencies. Some are compulsory, some are optional. Optional
|
||||
dependencies, you can leave if you don't want.
|
||||
|
||||
### Compulsory Dependencies
|
||||
|
||||
We need **CMake** to configure the installation, **GCC** for compilation, **Python-devel** and
|
||||
**Numpy** for creating Python extensions etc.
|
||||
@code{.sh}
|
||||
yum install cmake
|
||||
yum install python-devel numpy
|
||||
yum install gcc gcc-c++
|
||||
@endcode
|
||||
Next we need **GTK** support for GUI features, Camera support (libdc1394, v4l), Media Support
|
||||
(ffmpeg, gstreamer) etc.
|
||||
@code{.sh}
|
||||
yum install gtk2-devel
|
||||
yum install libdc1394-devel
|
||||
yum install ffmpeg-devel
|
||||
yum install gstreamer-plugins-base-devel
|
||||
@endcode
|
||||
### Optional Dependencies
|
||||
|
||||
Above dependencies are sufficient to install OpenCV in your fedora machine. But depending upon your
|
||||
requirements, you may need some extra dependencies. A list of such optional dependencies are given
|
||||
below. You can either leave it or install it, your call :)
|
||||
|
||||
OpenCV comes with supporting files for image formats like PNG, JPEG, JPEG2000, TIFF, WebP etc. But
|
||||
it may be a little old. If you want to get latest libraries, you can install development files for
|
||||
these formats.
|
||||
@code{.sh}
|
||||
yum install libpng-devel
|
||||
yum install libjpeg-turbo-devel
|
||||
yum install jasper-devel
|
||||
yum install openexr-devel
|
||||
yum install libtiff-devel
|
||||
yum install libwebp-devel
|
||||
@endcode
|
||||
Several OpenCV functions are parallelized with **Intel's Threading Building Blocks** (TBB). But if
|
||||
you want to enable it, you need to install TBB first. ( Also while configuring installation with
|
||||
CMake, don't forget to pass -D WITH_TBB=ON. More details below.)
|
||||
@code{.sh}
|
||||
yum install tbb-devel
|
||||
@endcode
|
||||
OpenCV uses another library **Eigen** for optimized mathematical operations. So if you have Eigen
|
||||
installed in your system, you can exploit it. ( Also while configuring installation with CMake,
|
||||
don't forget to pass -D WITH_EIGEN=ON. More details below.)
|
||||
@code{.sh}
|
||||
yum install eigen3-devel
|
||||
@endcode
|
||||
If you want to build **documentation** ( *Yes, you can create offline version of OpenCV's complete
|
||||
official documentation in your system in HTML with full search facility so that you need not access
|
||||
internet always if any question, and it is quite FAST!!!* ), you need to install **Doxygen** (a
|
||||
documentation generation tool).
|
||||
@code{.sh}
|
||||
yum install doxygen
|
||||
@endcode
|
||||
### Downloading OpenCV
|
||||
|
||||
Next we have to download OpenCV. You can download the latest release of OpenCV from [sourceforge
|
||||
site](http://sourceforge.net/projects/opencvlibrary/). Then extract the folder.
|
||||
|
||||
Or you can download latest source from OpenCV's github repo. (If you want to contribute to OpenCV,
|
||||
choose this. It always keeps your OpenCV up-to-date). For that, you need to install **Git** first.
|
||||
@code{.sh}
|
||||
yum install git
|
||||
git clone https://github.com/opencv/opencv.git
|
||||
@endcode
|
||||
It will create a folder OpenCV in home directory (or the directory you specify). The cloning may
|
||||
take some time depending upon your internet connection.
|
||||
|
||||
Now open a terminal window and navigate to the downloaded OpenCV folder. Create a new build folder
|
||||
and navigate to it.
|
||||
@code{.sh}
|
||||
mkdir build
|
||||
cd build
|
||||
@endcode
|
||||
### Configuring and Installing
|
||||
|
||||
Now we have installed all the required dependencies, let's install OpenCV. Installation has to be
|
||||
configured with CMake. It specifies which modules are to be installed, installation path, which
|
||||
additional libraries to be used, whether documentation and examples to be compiled etc. Below
|
||||
command is normally used for configuration (executed from build folder).
|
||||
@code{.sh}
|
||||
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
|
||||
@endcode
|
||||
It specifies that build type is "Release Mode" and installation path is /usr/local. Observe the -D
|
||||
before each option and .. at the end. In short, this is the format:
|
||||
@code{.sh}
|
||||
cmake [-D <flag>] [-D <flag>] ..
|
||||
@endcode
|
||||
You can specify as many flags you want, but each flag should be preceded by -D.
|
||||
|
||||
So in this tutorial, we are installing OpenCV with TBB and Eigen support. We also build the
|
||||
documentation, but we exclude Performance tests and building samples. We also disable GPU related
|
||||
modules (since we use OpenCV-Python, we don't need GPU related modules. It saves us some time).
|
||||
|
||||
*(All the below commands can be done in a single cmake statement, but it is split here for better
|
||||
understanding.)*
|
||||
|
||||
- Enable TBB and Eigen support:
|
||||
@code{.sh}
|
||||
cmake -D WITH_TBB=ON -D WITH_EIGEN=ON ..
|
||||
@endcode
|
||||
- Enable documentation and disable tests and samples
|
||||
@code{.sh}
|
||||
cmake -D BUILD_DOCS=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF ..
|
||||
@endcode
|
||||
- Disable all GPU related modules.
|
||||
@code{.sh}
|
||||
cmake -D WITH_OPENCL=OFF -D BUILD_opencv_gpu=OFF -D BUILD_opencv_gpuarithm=OFF -D BUILD_opencv_gpubgsegm=OFF -D BUILD_opencv_gpucodec=OFF -D BUILD_opencv_gpufeatures2d=OFF -D BUILD_opencv_gpufilters=OFF -D BUILD_opencv_gpuimgproc=OFF -D BUILD_opencv_gpulegacy=OFF -D BUILD_opencv_gpuoptflow=OFF -D BUILD_opencv_gpustereo=OFF -D BUILD_opencv_gpuwarping=OFF ..
|
||||
@endcode
|
||||
- Set installation path and build type
|
||||
@code{.sh}
|
||||
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
|
||||
@endcode
|
||||
Each time you enter cmake statement, it prints out the resulting configuration setup. In the final
|
||||
setup you got, make sure that following fields are filled (below is the some important parts of
|
||||
configuration I got). These fields should be filled appropriately in your system also. Otherwise
|
||||
some problem has happened. So check if you have correctly performed above steps.
|
||||
@code{.sh}
|
||||
...
|
||||
-- GUI:
|
||||
-- GTK+ 2.x: YES (ver 2.24.19)
|
||||
-- GThread : YES (ver 2.36.3)
|
||||
|
||||
-- Video I/O:
|
||||
-- DC1394 2.x: YES (ver 2.2.0)
|
||||
-- FFMPEG: YES
|
||||
-- codec: YES (ver 54.92.100)
|
||||
-- format: YES (ver 54.63.104)
|
||||
-- util: YES (ver 52.18.100)
|
||||
-- swscale: YES (ver 2.2.100)
|
||||
-- gentoo-style: YES
|
||||
-- GStreamer:
|
||||
-- base: YES (ver 0.10.36)
|
||||
-- video: YES (ver 0.10.36)
|
||||
-- app: YES (ver 0.10.36)
|
||||
-- riff: YES (ver 0.10.36)
|
||||
-- pbutils: YES (ver 0.10.36)
|
||||
|
||||
-- V4L/V4L2: Using libv4l (ver 1.0.0)
|
||||
|
||||
-- Other third-party libraries:
|
||||
-- Use Eigen: YES (ver 3.1.4)
|
||||
-- Use TBB: YES (ver 4.0 interface 6004)
|
||||
|
||||
-- Python:
|
||||
-- Interpreter: /usr/bin/python2 (ver 2.7.5)
|
||||
-- Libraries: /lib/libpython2.7.so (ver 2.7.5)
|
||||
-- numpy: /usr/lib/python2.7/site-packages/numpy/core/include (ver 1.7.1)
|
||||
-- packages path: lib/python2.7/site-packages
|
||||
|
||||
...
|
||||
@endcode
|
||||
Many other flags and settings are there. It is left for you for further exploration.
|
||||
|
||||
Now you build the files using make command and install it using make install command. make install
|
||||
should be executed as root.
|
||||
@code{.sh}
|
||||
make
|
||||
su
|
||||
make install
|
||||
@endcode
|
||||
Installation is over. All files are installed in /usr/local/ folder. But to use it, your Python
|
||||
should be able to find OpenCV module. You have two options for that.
|
||||
|
||||
-# **Move the module to any folder in Python Path** : Python path can be found out by entering
|
||||
`import sys; print(sys.path)` in Python terminal. It will print out many locations. Move
|
||||
/usr/local/lib/python2.7/site-packages/cv2.so to any of this folder. For example,
|
||||
@code{.sh}
|
||||
su mv /usr/local/lib/python2.7/site-packages/cv2.so /usr/lib/python2.7/site-packages
|
||||
@endcode
|
||||
But you will have to do this every time you install OpenCV.
|
||||
|
||||
-# **Add /usr/local/lib/python2.7/site-packages to the PYTHON_PATH**: It is to be done only once.
|
||||
Just open \~/.bashrc and add following line to it, then log out and come back.
|
||||
@code{.sh}
|
||||
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages
|
||||
@endcode
|
||||
Thus OpenCV installation is finished. Open a terminal and try 'import cv2 as cv'.
|
||||
|
||||
To build the documentation, just enter following commands:
|
||||
@code{.sh}
|
||||
make doxygen
|
||||
@endcode
|
||||
Then open opencv/build/doc/doxygen/html/index.html and bookmark it in the browser.
|
||||
|
||||
Additional Resources
|
||||
--------------------
|
||||
|
||||
Exercises
|
||||
---------
|
||||
|
||||
-# Compile OpenCV from source in your Fedora machine.
|
184
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_ubuntu/py_setup_in_ubuntu.markdown
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
Install OpenCV-Python in Ubuntu {#tutorial_py_setup_in_ubuntu}
|
||||
===============================
|
||||
|
||||
Goals
|
||||
-----
|
||||
|
||||
In this tutorial We will learn to setup OpenCV-Python in Ubuntu System.
|
||||
Below steps are tested for Ubuntu 16.04 and 18.04 (both 64-bit).
|
||||
|
||||
OpenCV-Python can be installed in Ubuntu in two ways:
|
||||
- Install from pre-built binaries available in Ubuntu repositories
|
||||
- Compile from the source. In this section, we will see both.
|
||||
|
||||
Another important thing is the additional libraries required.
|
||||
OpenCV-Python requires only **Numpy** (in addition to other dependencies, which we will see later).
|
||||
But in this tutorials, we also use **Matplotlib** for some easy and nice plotting purposes (which I feel much better compared to OpenCV).
|
||||
Matplotlib is optional, but highly recommended.
|
||||
Similarly we will also see **IPython**, an Interactive Python Terminal, which is also highly recommended.
|
||||
|
||||
Installing OpenCV-Python from Pre-built Binaries
|
||||
------------------------------------------------
|
||||
|
||||
This method serves best when using just for programming and developing OpenCV applications.
|
||||
|
||||
Install package [python3-opencv](https://packages.ubuntu.com/focal/python3-opencv) with following command in terminal (as root user).
|
||||
|
||||
```
|
||||
$ sudo apt-get install python3-opencv
|
||||
```
|
||||
|
||||
Open Python IDLE (or IPython) and type following codes in Python terminal.
|
||||
|
||||
```
|
||||
import cv2 as cv
|
||||
print(cv.__version__)
|
||||
```
|
||||
|
||||
If the results are printed out without any errors, congratulations !!!
|
||||
You have installed OpenCV-Python successfully.
|
||||
|
||||
It is quite easy. But there is a problem with this.
|
||||
Apt repositories may not contain the latest version of OpenCV always.
|
||||
For example, at the time of writing this tutorial, apt repository contains 2.4.8 while latest OpenCV version is 3.x.
|
||||
With respect to Python API, latest version will always contain much better support and latest bug fixes.
|
||||
|
||||
So for getting latest source codes preference is next method, i.e. compiling from source.
|
||||
Also at some point in time, if you want to contribute to OpenCV, you will need this.
|
||||
|
||||
Building OpenCV from source
|
||||
---------------------------
|
||||
|
||||
Compiling from source may seem a little complicated at first, but once you succeeded in it, there is nothing complicated.
|
||||
|
||||
First we will install some dependencies.
|
||||
Some are required, some are optional.
|
||||
You can skip optional dependencies if you don't want.
|
||||
|
||||
### Required build dependencies
|
||||
|
||||
We need **CMake** to configure the installation, **GCC** for compilation, **Python-devel** and
|
||||
**Numpy** for building Python bindings etc.
|
||||
|
||||
```
|
||||
sudo apt-get install cmake
|
||||
sudo apt-get install gcc g++
|
||||
```
|
||||
to support python2:
|
||||
|
||||
```
|
||||
sudo apt-get install python-dev python-numpy
|
||||
```
|
||||
|
||||
to support python3:
|
||||
|
||||
```
|
||||
sudo apt-get install python3-dev python3-numpy
|
||||
```
|
||||
|
||||
Next we need **GTK** support for GUI features, Camera support (v4l), Media Support
|
||||
(ffmpeg, gstreamer) etc.
|
||||
|
||||
```
|
||||
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
|
||||
sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
|
||||
```
|
||||
|
||||
to support gtk2:
|
||||
```
|
||||
sudo apt-get install libgtk2.0-dev
|
||||
```
|
||||
|
||||
to support gtk3:
|
||||
```
|
||||
sudo apt-get install libgtk-3-dev
|
||||
```
|
||||
|
||||
### Optional Dependencies
|
||||
|
||||
Above dependencies are sufficient to install OpenCV in your Ubuntu machine.
|
||||
But depending upon your requirements, you may need some extra dependencies.
|
||||
A list of such optional dependencies are given below. You can either leave it or install it, your call :)
|
||||
|
||||
OpenCV comes with supporting files for image formats like PNG, JPEG, JPEG2000, TIFF, WebP etc.
|
||||
But it may be a little old.
|
||||
If you want to get latest libraries, you can install development files for system libraries of these formats.
|
||||
|
||||
```
|
||||
sudo apt-get install libpng-dev
|
||||
sudo apt-get install libjpeg-dev
|
||||
sudo apt-get install libopenexr-dev
|
||||
sudo apt-get install libtiff-dev
|
||||
sudo apt-get install libwebp-dev
|
||||
```
|
||||
|
||||
@note If you are using Ubuntu 16.04 you can also install ```libjasper-dev``` to add a system level support for the JPEG2000 format.
|
||||
|
||||
### Downloading OpenCV
|
||||
|
||||
To download the latest source from OpenCV's [GitHub Repository](https://github.com/opencv/opencv).
|
||||
(If you want to contribute to OpenCV choose this. For that, you need to install **Git** first)
|
||||
|
||||
```
|
||||
$ sudo apt-get install git
|
||||
$ git clone https://github.com/opencv/opencv.git
|
||||
```
|
||||
|
||||
It will create a folder "opencv" in current directory.
|
||||
The cloning may take some time depending upon your internet connection.
|
||||
|
||||
Now open a terminal window and navigate to the downloaded "opencv" folder.
|
||||
Create a new "build" folder and navigate to it.
|
||||
|
||||
```
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
```
|
||||
|
||||
### Configuring and Installing
|
||||
|
||||
Now we have all the required dependencies, let's install OpenCV.
|
||||
Installation has to be configured with CMake.
|
||||
It specifies which modules are to be installed, installation path, which additional libraries to be used, whether documentation and examples to be compiled etc.
|
||||
Most of this work are done automatically with well configured default parameters.
|
||||
|
||||
Below command is normally used for configuration of OpenCV library build (executed from build folder):
|
||||
|
||||
```
|
||||
$ cmake ../
|
||||
```
|
||||
|
||||
OpenCV defaults assume "Release" build type and installation path is "/usr/local".
|
||||
For additional information about CMake options refer to OpenCV @ref tutorial_linux_install "C++ compilation guide":
|
||||
|
||||
You should see these lines in your CMake output (they mean that Python is properly found):
|
||||
|
||||
```
|
||||
-- Python 2:
|
||||
-- Interpreter: /usr/bin/python2.7 (ver 2.7.6)
|
||||
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
|
||||
-- numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2)
|
||||
-- packages path: lib/python2.7/dist-packages
|
||||
--
|
||||
-- Python 3:
|
||||
-- Interpreter: /usr/bin/python3.4 (ver 3.4.3)
|
||||
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython3.4m.so (ver 3.4.3)
|
||||
-- numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.8.2)
|
||||
-- packages path: lib/python3.4/dist-packages
|
||||
```
|
||||
|
||||
Now you build the files using "make" command and install it using "make install" command.
|
||||
|
||||
```
|
||||
$ make
|
||||
# sudo make install
|
||||
```
|
||||
|
||||
Installation is over.
|
||||
All files are installed in "/usr/local/" folder.
|
||||
Open a terminal and try import "cv2".
|
||||
|
||||
```
|
||||
import cv2 as cv
|
||||
print(cv.__version__)
|
||||
```
|
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_windows/images/Capture1.jpg
vendored
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_windows/images/Capture2.png
vendored
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_windows/images/Capture3.png
vendored
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_windows/images/Capture5.png
vendored
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_windows/images/Capture6.png
vendored
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_windows/images/Capture7.png
vendored
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_windows/images/Capture8.png
vendored
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_windows/images/Capture80.png
vendored
Normal file
After Width: | Height: | Size: 11 KiB |
148
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.markdown
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
Install OpenCV-Python in Windows {#tutorial_py_setup_in_windows}
|
||||
================================
|
||||
|
||||
Goals
|
||||
-----
|
||||
|
||||
In this tutorial
|
||||
- We will learn to setup OpenCV-Python in your Windows system.
|
||||
|
||||
Below steps are tested in a Windows 7-64 bit machine with Visual Studio 2010 and Visual Studio 2012.
|
||||
The screenshots shows VS2012.
|
||||
|
||||
Installing OpenCV from prebuilt binaries
|
||||
----------------------------------------
|
||||
|
||||
-# Below Python packages are to be downloaded and installed to their default locations.
|
||||
|
||||
-# Python 3.x (3.4+) or Python 2.7.x from [here](https://www.python.org/downloads/).
|
||||
|
||||
-# Numpy package (for example, using `pip install numpy` command).
|
||||
|
||||
-# Matplotlib (`pip install matplotlib`) (*Matplotlib is optional, but recommended since we use it a lot in our tutorials*).
|
||||
|
||||
-# Install all packages into their default locations. Python will be installed to `C:/Python27/` in case of Python 2.7.
|
||||
|
||||
-# After installation, open Python IDLE. Enter **import numpy** and make sure Numpy is working fine.
|
||||
|
||||
-# Download latest OpenCV release from [GitHub](https://github.com/opencv/opencv/releases) or
|
||||
[SourceForge site](https://sourceforge.net/projects/opencvlibrary/files/)
|
||||
and double-click to extract it.
|
||||
|
||||
-# Goto **opencv/build/python/2.7** folder.
|
||||
|
||||
-# Copy **cv2.pyd** to **C:/Python27/lib/site-packages**.
|
||||
|
||||
-# Open Python IDLE and type following codes in Python terminal.
|
||||
@code
|
||||
>>> import cv2 as cv
|
||||
>>> print( cv.__version__ )
|
||||
@endcode
|
||||
|
||||
If the results are printed out without any errors, congratulations !!! You have installed
|
||||
OpenCV-Python successfully.
|
||||
|
||||
Building OpenCV from source
|
||||
---------------------------
|
||||
|
||||
-# Download and install Visual Studio and CMake.
|
||||
|
||||
-# [Visual Studio 2012](http://go.microsoft.com/?linkid=9816768)
|
||||
|
||||
-# [CMake](https://cmake.org/download/)
|
||||
|
||||
-# Download and install necessary Python packages to their default locations
|
||||
|
||||
-# Python
|
||||
|
||||
-# Numpy
|
||||
|
||||
@note In this case, we are using 32-bit binaries of Python packages. But if you want to use
|
||||
OpenCV for x64, 64-bit binaries of Python packages are to be installed. Problem is that, there
|
||||
is no official 64-bit binaries of Numpy. You have to build it on your own. For that, you have to
|
||||
use the same compiler used to build Python. When you start Python IDLE, it shows the compiler
|
||||
details. You can get more [information here](http://stackoverflow.com/q/2676763/1134940). So
|
||||
your system must have the same Visual Studio version and build Numpy from source.
|
||||
|
||||
@note Another method to have 64-bit Python packages is to use ready-made Python distributions
|
||||
from third-parties like [Anaconda](http://www.continuum.io/downloads),
|
||||
[Enthought](https://www.enthought.com/downloads/) etc. It will be bigger in size, but will have
|
||||
everything you need. Everything in a single shell. You can also download 32-bit versions also.
|
||||
|
||||
-# Make sure Python and Numpy are working fine.
|
||||
|
||||
-# Download OpenCV source. It can be from
|
||||
[Sourceforge](http://sourceforge.net/projects/opencvlibrary/) (for official release version) or
|
||||
from [Github](https://github.com/opencv/opencv) (for latest source).
|
||||
-# Extract it to a folder, opencv and create a new folder build in it.
|
||||
-# Open CMake-gui (*Start \> All Programs \> CMake-gui*)
|
||||
-# Fill the fields as follows (see the image below):
|
||||
|
||||
-# Click on **Browse Source...** and locate the opencv folder.
|
||||
|
||||
-# Click on **Browse Build...** and locate the build folder we created.
|
||||
|
||||
-# Click on **Configure**.
|
||||
|
||||

|
||||
|
||||
-# It will open a new window to select the compiler. Choose appropriate compiler (here,
|
||||
Visual Studio 11) and click **Finish**.
|
||||
|
||||

|
||||
|
||||
-# Wait until analysis is finished.
|
||||
|
||||
-# You will see all the fields are marked in red. Click on the **WITH** field to expand it. It
|
||||
decides what extra features you need. So mark appropriate fields. See the below image:
|
||||
|
||||

|
||||
|
||||
-# Now click on **BUILD** field to expand it. First few fields configure the build method. See the
|
||||
below image:
|
||||
|
||||

|
||||
|
||||
-# Remaining fields specify what modules are to be built. Since GPU modules are not yet supported
|
||||
by OpenCV-Python, you can completely avoid it to save time (But if you work with them, keep it
|
||||
there). See the image below:
|
||||
|
||||

|
||||
|
||||
-# Now click on **ENABLE** field to expand it. Make sure **ENABLE_SOLUTION_FOLDERS** is unchecked
|
||||
(Solution folders are not supported by Visual Studio Express edition). See the image below:
|
||||
|
||||

|
||||
|
||||
-# Also make sure that in the **PYTHON** field, everything is filled. (Ignore
|
||||
PYTHON_DEBUG_LIBRARY). See image below:
|
||||
|
||||

|
||||
|
||||
-# Finally click the **Generate** button.
|
||||
|
||||
-# Now go to our **opencv/build** folder. There you will find **OpenCV.sln** file. Open it with
|
||||
Visual Studio.
|
||||
|
||||
-# Check build mode as **Release** instead of **Debug**.
|
||||
|
||||
-# In the solution explorer, right-click on the **Solution** (or **ALL_BUILD**) and build it. It
|
||||
will take some time to finish.
|
||||
|
||||
-# Again, right-click on **INSTALL** and build it. Now OpenCV-Python will be installed.
|
||||
|
||||

|
||||
|
||||
-# Open Python IDLE and enter 'import cv2 as cv'. If no error, it is installed correctly.
|
||||
|
||||
@note We have installed with no other support like TBB, Eigen, Qt, Documentation etc. It would be
|
||||
difficult to explain it here. A more detailed video will be added soon or you can just hack around.
|
||||
|
||||
Additional Resources
|
||||
--------------------
|
||||
|
||||
Exercises
|
||||
---------
|
||||
|
||||
If you have a windows machine, compile the OpenCV from source. Do all kinds of hacks. If you meet
|
||||
any problem, visit OpenCV forum and explain your problem.
|
22
3rdparty/opencv-4.5.4/doc/py_tutorials/py_setup/py_table_of_contents_setup.markdown
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
Introduction to OpenCV {#tutorial_py_table_of_contents_setup}
|
||||
======================
|
||||
|
||||
- @subpage tutorial_py_intro
|
||||
|
||||
Getting Started with
|
||||
OpenCV-Python
|
||||
|
||||
- @subpage tutorial_py_setup_in_windows
|
||||
|
||||
Set Up
|
||||
OpenCV-Python in Windows
|
||||
|
||||
- @subpage tutorial_py_setup_in_fedora
|
||||
|
||||
Set Up
|
||||
OpenCV-Python in Fedora
|
||||
|
||||
- @subpage tutorial_py_setup_in_ubuntu
|
||||
|
||||
Set Up
|
||||
OpenCV-Python in Ubuntu
|