OpenCV: Difference between revisions
From charlesreid1
(→Flags) |
|||
| Line 7: | Line 7: | ||
===OpenCV3=== | ===OpenCV3=== | ||
To install OpenCV3 on a Mac, use Homebrew: | To install OpenCV3 on a Mac, and make it usable from Python 3, use Homebrew: | ||
<pre> | <pre> | ||
$ brew install | $ brew install opencv --with-python3 --c++11 --with-contrib | ||
$ brew link --force | $ brew link --force opencv | ||
</pre> | </pre> | ||
You may need to add the <code>--without-openexr</code> flag if you run into compiler errors (hat tip: [https://gravityjack.com/news/opencv-python-3-homebrew/]). | |||
Test that it installed okay: | Test that it installed okay: | ||
Revision as of 07:02, 27 October 2017
The OpenCV library is a general, all-purpose computer vision library. It's high performance and written in C++. It has many dependencies and is non-trivial to install, so the best approach is to either use a detailed guide, a package manager like aptitude or homebrew, or an Ansible playbook.
Operating Systems
Mac
OpenCV3
To install OpenCV3 on a Mac, and make it usable from Python 3, use Homebrew:
$ brew install opencv --with-python3 --c++11 --with-contrib $ brew link --force opencv
You may need to add the --without-openexr flag if you run into compiler errors (hat tip: [1]).
Test that it installed okay:
$ python3 >>> import cv2 >>> print(cv2.__version__)
OpenCV2
To install OpenCV version 2, use the (at)2 after opencv:
$ brew install opencv@2 $ brew unlink opencv # This is necessary if you already installed opencv (version 3 by default) $ brew link --force opencv@2
Raspberry Pi
Install OpenCV using aptitude:
#!/bin/bash ### # This is a meta-package that points to other dev packages. ### # Try the stuff below first. ### apt-get -y install libopencv-dev apt-get -y install libopencv-core-dev apt-get -y install libopencv-video-dev apt-get -y install libopencv-features2d-dev apt-get -y install python-opencv
See the pi-opencv repository on Github: https://github.com/charlesreid1-raspberry-pi/pi-opencv
Usage
Python
Unfortunately, most of the OpenCV documentation covers use of OpenCV from C++, not Python.
Tutorials
OpenCV-Python Tutorials: https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_tutorials.html
These cover the following topics:
- Introduction to OpenCV
- GUI features
- Image processing
- Feature detection
- Video analysis
- Camera calibration
- Machine learning
- Computational photography
- Object detection
Face Detection and Object Detection
Face detection: https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html#face-detection
Cpp
OpenCV documentation for C++ API: https://docs.opencv.org/2.4/index.html