From charlesreid1

No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
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.
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.


[[OpenCV/Cross Compiling on Mac for Raspberry Pi]]
=Operating Systems=


==Mac==


===OpenCV3===
To install OpenCV3 on a Mac, and make it usable from Python 3, use Homebrew:
<pre>
$ brew install opencv --with-python3 --c++11 --with-contrib
$ brew link --force opencv
</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:
<pre>
$ python3
>>> import cv2
>>> print(cv2.__version__)
</pre>
(Yeah, the OpenCV 3 module is still called "cv2" - thanks to the genius who thought that was a good idea.)
===OpenCV2===
To install OpenCV version 2, use the (at)2 after opencv:
<pre>
$ brew install opencv@2
$ brew unlink opencv # This is necessary if you already installed opencv (version 3 by default)
$ brew link --force opencv@2
</pre>
==Raspberry Pi==
Install OpenCV using aptitude:
<pre>
#!/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
</pre>
See the pi-opencv repository on Github: https://github.com/charlesreid1-raspberry-pi/pi-opencv
=Documentation and Usage=
==Using OpenCV from Python==
Unfortunately, most of the OpenCV documentation covers use of OpenCV from C++, not Python.
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===
{{Main|OpenCV/Face Detection}}
Face detection: https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html#face-detection
==Using OpenCV from Cpp==
All of the documentation links: https://docs.opencv.org/
OpenCV 2.4 documentation for C++ API: https://docs.opencv.org/2.4/index.html
OpenCV 3.3.1 documentation for C++ API: https://docs.opencv.org/3.3.1/
==How the Documentation Works==
Here's a link to an explanation of how the OpenCV documentation works, how it is organized, and how to contribute to it: https://docs.opencv.org/trunk/d4/db1/tutorial_documentation.html


=Flags=
=Flags=


[[Category:OpenCV]]
[[Category:OpenCV]]
[[Category:Images]]
[[Category:Faces]]

Latest revision as of 07:07, 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__)

(Yeah, the OpenCV 3 module is still called "cv2" - thanks to the genius who thought that was a good idea.)

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


Documentation and Usage

Using OpenCV from Python

Unfortunately, most of the OpenCV documentation covers use of OpenCV from C++, not Python.

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

Using OpenCV from Cpp

All of the documentation links: https://docs.opencv.org/

OpenCV 2.4 documentation for C++ API: https://docs.opencv.org/2.4/index.html

OpenCV 3.3.1 documentation for C++ API: https://docs.opencv.org/3.3.1/

How the Documentation Works

Here's a link to an explanation of how the OpenCV documentation works, how it is organized, and how to contribute to it: https://docs.opencv.org/trunk/d4/db1/tutorial_documentation.html

Flags