Install and use OpenCV
Although face authentication by image recognition using a personal computer or smartphone camera is commonplace, Python's OpenCV is one of the Python libraries that are also used for face authentication.In this article, we will explain the outline of OpenCV and how to install it for Python beginners.
What is OpenCV?
The official name is "Open Source Computer Vision Library", as its name suggests, OpenCV is an open source library with functions such as computer -based imaging, image analysis, and machine learning, and can be used for free.increase.
OpenCV is open to C/C ++, Java, and Matlab in addition to Python, and is widely used, from academic use to commercial use.It is also compatible with multi -platforms and is used on all platforms.
[Reference]: OpenCV official website
What is OpenCV??できることや活用事例について詳しく解説!OpenCV function
The following is implemented in the OpenCV function, focusing on image processing.
▪ Filtering function of image ▪ ▪ 行 行 行 行Processing function ▪ Mosaic processing, mask processing, 2 image synthesis functions ▪ 形 形 形 形 形 形 形 形 形 形
OpenCV support OS
As OpenCV is officially supported by the following platform, it is a great advantage that it can be used in any OS environment, such as a server, a smartphone, or a smartphone.
▪ Windows ▪ Mac OS ▪ Linux ▪android
Support language
The language that can use OpenCV is C ++, Java, and Python.OpenCV started with C at first, but now C is not supported.
Pythonとは?人気のPythonを学ぶ際に知っておきたいことJavaとは?人気プログラミング言語Javaの将来性やメリットについて解説Install OpenCV
After understanding the outline and functions of OpenCV, let's actually install Open-CV.Open-CV installation is broadly divided, how to use Anaconda's Condo command, which is one of the integrated development environments, and use Python standard PIP.
If you use both environments at the same time, you may cause various problems, so if you are installing Python, please use pip, and if you use ANACONDA on a daily basis.Here, we will introduce the installation using PIP.
Check the Python version before using PIP
It is common to install OpenCV with PIP, but the version is 3.If Python has been installed after 4, PIP is attached, and there is no need to install a new PIP.
Just enter the PIP command from the command line and the Numpy of the dependent package is installed.If you are concerned about the Python version if the PIP is installed, enter "Python --version" from the command line.
Python version is 3.10.Since it was confirmed that it was 0, you can see that the PIP is also installed.
By the way, if the Python version is old, there may be a problem that OpenCV cannot be installed, so unless there is a special reason, make a new version of Python and then install the library.
If python is not installed
If Python is not installed, you need to install Python.On a PC where Python is not installed, first install Python from the following official website.
[Reference]: Download page (Python official website)
Pythonのインストール方法:初心者向けインストール方法を1から解説!Install OpenCV-Python with PIP
Let's enter "Pip Install OpenCV-Python" from the command line and install Open-CV.As I introduced earlier, OpenCV has C ++ and Java, so OpenCV for Python is installed from the Python library repository (the Python Package Index) using the pip command.
The installation is finished and "Successfully Installed OpenCV-Python4444444.5.4.The installation is complete if it is displayed as 60.Numpy, a dependent package, is also installed safely.
Install OpenCv-Contrib-Python
Install the contrib, an extended module group of OpenCV, along with OpenCV.Enter the "Pip Install OpenCv-Contrib-Python" command from the command line.
The installation is finished and "SuccessFully Installed OpenCv-Contrib-Python-4-4-4-4-4.5.4.If it is displayed "60", the installation is completed.
Let's use OpenCV
If the usage environment of OpenCV is in place, try it immediately.Launch Jupyter Notebook and let it operate on the notebook screen.
Install Jupyter Note with PIP
If you are not installing jupyter-notebook, install Jupyter-Notebook.
Jupyter-notebook is an integrated development environment (IDE) for Python.Jupyter-notebook is a suitable tool for handling visual data, so you should install it with Matplotlib, which is strong in graph creation and data analysis.
Installing the jupyter-notebook is entered from the command prompt to enter the "Pip Install Jupyter" and the pip command to automatically install the library related to the jupyter-notebook.
Jupyter Notebookとは?その導入・操作方法を解説Install Matplotlib with PIP
It is very useful to install Matplotlib, an image processing library that is good at drawing graph drawing.To install Matplotlib, you can install it simply by entering "Pip Install Matplotlib" from the command prompt.
"Successfully Installed MatplotLib-3.5.The installation is complete if the display is "1".
Actually read the image
Let's try image processing when the execution environment of OpenCV is in place.This time, I will download the free image and actually read it.
Here is the read image.
[Reference]: Reference image -pixabay
"Dog" under C: \ WORK \ image.Place it with the file name of "JPG".
The created demo programs are as follows.
Import Matplotlib.Pyplot as Pltimport CV2%Matplotlib Inline #Proad image Img = cv2.IMREAD (C: \ WORK \ IMAGE \ DOG.JPG)# Drawing images PLT.IMSHOW (img)
"%Matplotlib Inline" is described on Jupyter Notebook to draw a graph on Notebook.
Paste the above demo program on the cell on the notebook, click [run] (execution) and execute the tetrogram.Then, the image read as follows is displayed.
It turns out that the image can be processed easily using OpenCV.
Possibility of OpenCV
In this article, we introduced an overview of OpenCV, how to install, and a simple demo.You may have understood the appeal and possibilities of OpenCV.OpenCV has a lot of sample code, and you can develop a variety of apps with almost non -programming.
In recent years, facial authentication technology has been improved, and AI has become easy to identify the person from the camera image.OpenCV's attention is high, and the demand for engineers who can use OpenCV is growing.If you are interested in OpenCV, please install OpenCV with reference to this article and learn it.