The role of OpenCV and the installation case tutorial of python

  • 2021-11-14 06:36:14
  • OfStack

Function and Installation of OpenCV

Introduction to OpenCV

OpenCV is an open source, cross-platform computer vision library that runs on Linux, Windows, Android, and Mac OS operating systems. It provides the interface of Python, Ruby, MATLAB and so on, and realizes many general algorithms in image processing and computer vision, which can be called by developers.

Applications of OpenCV

Direction of computer vision field Man-machine interaction Object recognition Image segmentation Face recognition Motion recognition Motion tracking Robot Motion analysis Machine vision Structural analysis Safe driving of automobiles

Technologies involved in OpenCV

Operation of image data: allocation, release, copy, setting and conversion. Image is video input and output I/O, file and camera input, image and video file output). Matrix and vector operations and linear algebra algorithm procedures: Matrix product, solving equations, eigenvalues and singular values. Various dynamic data structures: lists, queues, collections, trees, graphs, etc.   Basic digital image processing: filtering, edge detection, corner detection, sampling and difference, color conversion, morphological operation, histogram, image pyramid and so on.   Structural analysis: Connecting parts, contour processing, distance transformation, respective distance calculation, template matching, Hough transformation, polygon approximation, straight line fitting, ellipse fitting, Delaunay 3-angle division, etc.   Camera calibration: Discovery and tracking calibration mode, calibration, basic matrix estimation, homogeneous matrix estimation, stereo correspondence. Motion analysis: optical flow, motion segmentation, tracking.   Target recognition: feature method, hidden Markov model: HMM. Basic GUI: Image and video display, keyboard and mouse event handling, scroll bar.   Image annotation: line, quadratic curve, polygon, drawing text.

Installation of OpenCV

When installing opencv on mac, 1 starts to use pip3 install python-opencv to report an error, prompting: No ES40distribution found for python-opencv, using pip3 install opencv, also reporting an error, prompting that opencv cannot be found, as shown in the figure

alicedembp:~ alice$ pip3 install python-opencv

Collecting python-opencv

  Could not find a version that satisfies the requirement python-opencv (from versions: )

No matching distribution found for python-opencv

Later, I tried pip3 install opencv-python again, and it was successful, as shown in the figure


alicedembp:~ alice$ pip3 install python-opencv
Collecting python-opencv
  Could not find a version that satisfies the requirement python-opencv (from versions: )
No matching distribution found for python-opencv
alicedembp:~ alice$ pip3 install opencv-python
Collecting opencv-python
  Downloading https://files.pythonhosted.org/packages/8d/ff/13e77ee7ac431f831e20d81a6bf0214ca1cf550cf9b575e3213e14325c81/opencv_python-4.1.0.25-cp37-cp37m-macosx_10_7_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (52.1MB)
    100% | In fact, in fact, the | 52.1MB 735kB/s 
Requirement already satisfied: numpy>=1.14.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from opencv-python) (1.16.1)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.1.0.25
alicedembp:~ alice$ 

You can use the command line import cv2 at the terminal to verify whether the 1 is really successful


alicedembp:~ alice$ python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> 

There is no error prompt when importing, confirm success ~ you can also view the installed version through cv2.__version__, as shown below:


alicedembp:~ alice$ python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.1.0'

Related articles: