How to install Opencv

Asked

Viewed 4,641 times

2

i would like to know how to install the latest version of Opencv 3.2 on linux Ubuntu 14.04. I was able to install and put to compile in codeblocks using C++ following a tutorial. But my goal is to actually install the opencv library so that I use it with the python language and can run the code well. I didn’t understand it very well but would I use python impot to use opencv? someone who knows this library could give me some tips and help me in this? Thanks.

Note: my goal is color recognition, and objects. Note 2: I would like to run it in Atom or codeblocks. Preferably in codeblocks.

2 answers

3

Look for the opencv package in python with Pip, in the example below I am in a Ubuntu 16, in an env python3:

~$ pip search opencv | grep "^opencv"
opencv-python-armv7l (3.2.0)     - opencv-python on armv7l.
opencv-contrib-python (3.2.0.7)  - Wrapper package for OpenCV python bindings.
opencv-cython (0.4)              - An alternative OpenCV wrapper
opencv-utils (0.0.2)             - OpenCV Utilities
opencv-python (3.2.0.7)          - Wrapper package for OpenCV python bindings.
opencv_cffi (0.2.2)              - A random subset of OpenCV's functionality, wrapped via CFFI
opencv_engine (1.0.1)            - OpenCV imaging engine for thumbor.
opencv_helpers (1.1)             - Helper functions for opencv
opencvutils (0.9.2)              - Simple OpenCV 3.x image processing functions

In that case we’ll install the fourth item:

pip install opencv-python

Or install the anaconda and end all package problems. :-)

Example of use

Capturing a video:

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Our operations on the frame come here
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    # Display the resulting frame
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

This example was taken from the great documentation of the package, there an area of tutorials very good with various exercises, have fun.

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.