Cv2 python install linux

Cv2 python install linux

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 with following command in terminal (as root user).

Open Python IDLE (or IPython) and type following codes in Python terminal.

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.

Источник

Как установить OpenCV в Ubuntu 20.04

OpenCV (Open Source Computer Vision Library) — это библиотека компьютерного зрения с открытым исходным кодом с привязками для C ++, Python и Java, поддерживающая все основные операционные системы. Он может использовать преимущества многоядерной обработки и ускорения графического процессора для работы в реальном времени.

OpenCV используется для широкого спектра приложений, включая анализ медицинских изображений, сшивание изображений улиц, видеонаблюдение, обнаружение и распознавание лиц, отслеживание движущихся объектов, извлечение 3D-моделей и многое другое.

Читайте также:  Windows mac os linux различия

В этой статье описывается, как установить OpenCV в Ubuntu 20.04. Чтобы установить последнюю стабильную версию OpenCV из исходного кода, прокрутите вниз до раздела « Установка OpenCV из исходного кода » этого руководства. Выберите наиболее удобный для вас способ установки.

Установка OpenCV из репозитория Ubuntu

OpenCV доступен для установки из репозиториев Ubuntu 20.04 по умолчанию. Для его установки выполните:

sudo apt updatesudo apt install libopencv-dev python3-opencv

Приведенная выше команда установит все пакеты, необходимые для запуска OpenCV.

Проверьте установку, импортировав модуль cv2 и распечатав версию OpenCV:

python3 -c "import cv2; print(cv2.__version__)"

На момент написания в репозиториях стоит версия 4.2:

Установка OpenCV из исходного кода

Сборка библиотеки OpenCV из исходного кода позволяет получить самую последнюю доступную версию. Он будет оптимизирован для вашей конкретной системы, и вы получите полный контроль над параметрами сборки. Это рекомендуемый способ установки OpenCV.

Выполните следующие шаги, чтобы установить последнюю версию OpenCV из источника:

sudo apt install build-essential cmake git pkg-config libgtk-3-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev python3-dev python3-numpy libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
mkdir ~/opencv_build && cd ~/opencv_build git clone https://github.com/opencv/opencv.git git clone https://github.com/opencv/opencv_contrib.git
cd ~/opencv_build/opencv mkdir -p build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules -D BUILD_EXAMPLES=ON ..
-- Configuring done -- Generating done -- Build files have been written to: /home/vagrant/opencv_build/opencv/build
pkg-config --modversion opencv4
python3 -c "import cv2; print(cv2.__version__)"

Выводы

Мы показали вам два разных способа установки OpenCV на ваш компьютер с Ubuntu 20.04. Выбор метода зависит от ваших требований и предпочтений. Несмотря на то, что установить упакованную версию из репозитория Ubuntu проще, сборка OpenCV из исходного кода дает вам больше гибкости, и это должно быть вашим первым вариантом при установке OpenCV.

Если у вас есть какие-либо вопросы или отзывы, не стесняйтесь оставлять комментарии ниже.

Источник

Cv2 python install linux

  • Image Resizing using OpenCV | Python
  • Python OpenCV | cv2.erode() method
  • Python | Image blurring using OpenCV
  • Python OpenCV | cv2.copyMakeBorder() method
  • Python | Grayscaling of Images using OpenCV
  • Image Processing in Python (Scaling, Rotating, Shifting and Edge Detection)
  • Erosion and Dilation of images using OpenCV in python
  • OpenCV Python Program to analyze an image using Histogram
  • Histograms Equalization in OpenCV
  • Python | Thresholding techniques using OpenCV | Set-1 (Simple Thresholding)
  • Python | Thresholding techniques using OpenCV | Set-2 (Adaptive Thresholding)
  • Python | Thresholding techniques using OpenCV | Set-3 (Otsu Thresholding)
  • OpenCV: Segmentation using Thresholding
  • Python OpenCV | cv2.cvtColor() method
  • Filter Color with OpenCV
  • Python | Denoising of colored images using opencv
  • Python | Visualizing image in different color spaces
  • Find Co-ordinates of Contours using OpenCV | Python
  • Python | Bilateral Filtering
  • Image Inpainting using OpenCV
  • Python | Intensity Transformation Operations on Images
  • Python | Image Registration using OpenCV
  • Python | Background subtraction using OpenCV
  • Background Subtraction in an Image using Concept of Running Average
  • Python | Foreground Extraction in an Image using Grabcut Algorithm
  • Python | Morphological Operations in Image Processing (Opening) | Set-1
  • Python | Morphological Operations in Image Processing (Closing) | Set-2
  • Python | Morphological Operations in Image Processing (Gradient) | Set-3
  • Image segmentation using Morphological operations in Python
  • Image Translation using OpenCV | Python
  • Image Pyramid using OpenCV | Python
  • Python | Program to extract frames using OpenCV
  • Displaying the coordinates of the points clicked on the image using Python-OpenCV
  • White and black dot detection using OpenCV | Python
  • Python | OpenCV BGR color palette with trackbars
  • Draw a rectangular shape and extract objects using Python’s OpenCV
  • Invisible Cloak using OpenCV | Python Project
  • ML | Unsupervised Face Clustering Pipeline
  • Saving Operated Video from a webcam using OpenCV
  • Face Detection using Python and OpenCV with webcam
  • Opening multiple color windows to capture using OpenCV in Python
  • Python | Play a video in reverse mode using OpenCV
  • Template matching using OpenCV in Python
  • Cartooning an Image using OpenCV – Python
  • Vehicle detection using OpenCV Python
  • Count number of Faces using Python – OpenCV
  • Live Webcam Drawing using OpenCV
  • Detect and Recognize Car License Plate from a video in real time
  • Build GUI Application Pencil Sketch from Photo in Python
  • Python OpenCV – Drowsiness Detection
  • Face Alignment with OpenCV and Python
  • Age Detection using Deep Learning in OpenCV
  • Right and Left Hand Detection Using Python
  • OpenCV Python: How to detect if a window is closed?
  • Save frames of live video with timestamps – Python OpenCV
  • Detecting low contrast images with OpenCV, scikit-image, and Python
  • Animate image using OpenCV in Python
  • Drawing a cross on an image with OpenCV
  • Blur and anonymize faces with OpenCV and Python
  • Face detection using Cascade Classifier using OpenCV-Python
  • Real time object color detection using OpenCV
  • Python – Writing to video with OpenCV
  • Add image to a live camera feed using OpenCV-Python
  • Face and Hand Landmarks Detection using Python – Mediapipe, OpenCV
  • Emotion Based Music Player – Python Project
  • Realtime Distance Estimation Using OpenCV – Python
  • Webcam QR code scanner using OpenCV
  • Color Identification in Images using Python – OpenCV
  • Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
  • Opencv Python program for Face Detection
  • Image Resizing using OpenCV | Python
  • Python OpenCV | cv2.erode() method
  • Python | Image blurring using OpenCV
  • Python OpenCV | cv2.copyMakeBorder() method
  • Python | Grayscaling of Images using OpenCV
  • Image Processing in Python (Scaling, Rotating, Shifting and Edge Detection)
  • Erosion and Dilation of images using OpenCV in python
  • OpenCV Python Program to analyze an image using Histogram
  • Histograms Equalization in OpenCV
  • Python | Thresholding techniques using OpenCV | Set-1 (Simple Thresholding)
  • Python | Thresholding techniques using OpenCV | Set-2 (Adaptive Thresholding)
  • Python | Thresholding techniques using OpenCV | Set-3 (Otsu Thresholding)
  • OpenCV: Segmentation using Thresholding
  • Python OpenCV | cv2.cvtColor() method
  • Filter Color with OpenCV
  • Python | Denoising of colored images using opencv
  • Python | Visualizing image in different color spaces
  • Find Co-ordinates of Contours using OpenCV | Python
  • Python | Bilateral Filtering
  • Image Inpainting using OpenCV
  • Python | Intensity Transformation Operations on Images
  • Python | Image Registration using OpenCV
  • Python | Background subtraction using OpenCV
  • Background Subtraction in an Image using Concept of Running Average
  • Python | Foreground Extraction in an Image using Grabcut Algorithm
  • Python | Morphological Operations in Image Processing (Opening) | Set-1
  • Python | Morphological Operations in Image Processing (Closing) | Set-2
  • Python | Morphological Operations in Image Processing (Gradient) | Set-3
  • Image segmentation using Morphological operations in Python
  • Image Translation using OpenCV | Python
  • Image Pyramid using OpenCV | Python
  • Python | Program to extract frames using OpenCV
  • Displaying the coordinates of the points clicked on the image using Python-OpenCV
  • White and black dot detection using OpenCV | Python
  • Python | OpenCV BGR color palette with trackbars
  • Draw a rectangular shape and extract objects using Python’s OpenCV
  • Invisible Cloak using OpenCV | Python Project
  • ML | Unsupervised Face Clustering Pipeline
  • Saving Operated Video from a webcam using OpenCV
  • Face Detection using Python and OpenCV with webcam
  • Opening multiple color windows to capture using OpenCV in Python
  • Python | Play a video in reverse mode using OpenCV
  • Template matching using OpenCV in Python
  • Cartooning an Image using OpenCV – Python
  • Vehicle detection using OpenCV Python
  • Count number of Faces using Python – OpenCV
  • Live Webcam Drawing using OpenCV
  • Detect and Recognize Car License Plate from a video in real time
  • Build GUI Application Pencil Sketch from Photo in Python
  • Python OpenCV – Drowsiness Detection
  • Face Alignment with OpenCV and Python
  • Age Detection using Deep Learning in OpenCV
  • Right and Left Hand Detection Using Python
  • OpenCV Python: How to detect if a window is closed?
  • Save frames of live video with timestamps – Python OpenCV
  • Detecting low contrast images with OpenCV, scikit-image, and Python
  • Animate image using OpenCV in Python
  • Drawing a cross on an image with OpenCV
  • Blur and anonymize faces with OpenCV and Python
  • Face detection using Cascade Classifier using OpenCV-Python
  • Real time object color detection using OpenCV
  • Python – Writing to video with OpenCV
  • Add image to a live camera feed using OpenCV-Python
  • Face and Hand Landmarks Detection using Python – Mediapipe, OpenCV
  • Emotion Based Music Player – Python Project
  • Realtime Distance Estimation Using OpenCV – Python
  • Webcam QR code scanner using OpenCV
  • Color Identification in Images using Python – OpenCV
  • Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
  • Opencv Python program for Face Detection
Читайте также:  Alt linux настроить vpn

Источник

Оцените статью
Adblock
detector