Things change. Half a year ago, I was happy with running OpenCV on Python 2. But not anymore. As hard as it is for me to admit, it is time to switch to Python 3. So here is my supposedly easy to follow tutorial on setting up OpenCV on Python 3.
First of all, get the latest package listings from the repository. If you are on Fedora, you can safely skip this. If you are on Debian, do the following:
Let's make sure Python 3 and its dev-libs are installed. If on Debian, run
If you are on fedora,
Virtualenv is a container inside which you can set a Python environment complete with libraries that are independent of the rest of the system. Setting up Virtualenv is worth it, as it allows us to maintain multiple versions of libraries parallelly without conflicts.
On Fedora, do
If you are on Debian, do
Once installed, go to someplace where you want to keep the files for your project. Create a directory for the same and initialize a virtual env inside the directory. It can be done as follows:
To make a virtual env work for us, we need to activate it. This is done by calling the activate script.
Once this is properly done, your prompt should change to something that resembles
That should do it. Let's install the libraries.
Now we address the elephant in the room. Let us set up OpenCV and some of the essential packages to make it work for us.
If you want an easy to use programming environment for learning OpenCV, you just installed it. We are, of course, talking about Jupyter Notebook. To start, do
As always, once you are done coding, you can quit by pressing “Ctrl + C”, then deactivate Virtualenv by running “deactivate” commandThere you go !!!