Göm meny

Python Course

Welcome to the Python part of the Robot Vision Systems course.

Preparations

In the course we will use Python 3. If possible, get the latest version 3.5, otherwise 3.4 will be fine. Earlier versions are not recommended.

You will also need to install the python packages scipy, numpy and matplotlib. Since the course is based on OpenCV, you need to install the Python bindings for that too. These are all more or less easy to install, depending on your platform. For Linux systems installing via your distributions package manager (i.e. yum/dnf, apt-get, etc.) is usually quite easy. For Mac and Windows it is apparently often much more difficult. Therefore I recommend you to use a stand-alone Python distribution instead. My recommendation is the Anaconda Python distribution.

Anaconda

Using Anaconda is IMHO the easiest way to use and install the Python scientific computing stack. Instead of the full anaconda install, you can also choose to use the miniconda version, and only install the packages that you actually need. Note that the Anaconda installer says "Python 3.4", which is fine, since you can still use the conda package manager to install a newer python version.

Do not allow anaconda to become the default python interpreter! At least on Linux and Mac systems this is likely to give you all sorts of problems.

There is a short tutorial you can follow, to test your install of anaconda/miniconda.

After installing anaconda or miniconda, you should use the conda command to create a suitable environment: $ conda create --name pycourse python=3.5 numpy=1.10 scipy h5py pandas ipython ipython-notebook matplotlib This creates a virtual python environment named "pycourse" with the packages that I will use for the course. The environment can be activated by running source activate pycourse on Linux and Mac and activate pycourse on Windows.

To test the environment, just run python --version and make sure the output looks similar to Python 3.5.0 :: Continuum Analytics, Inc.

OpenCV

If you chose to use anaconda, then you can install a version of opencv 3.0 compatible with Python 3.5 and numpy 1.10 using $ conda install -c hovren opencv For recent versions of Fedora (22) you will then have to remove the fontconfig conda package, to avoid errors when importing the cv2 module: $ conda remove fontconfig

Assignments

  1. Assignment 1 - IMDB movie scores

Lectures

The lecture slides are available both as rendered HTML, and as the original IPython interactive notebook. To run the notebooks simply download the files and run ipython notebook in that directory.

  1. Lecture 1 - Python introduction [Slides] [Notebook]
  2. Lecture 2 - Scientific Python [Slides] [Notebook]
  3. Lecture 3 - Mixed topics [Slides] [Notebook]

Informationsansvarig: Hannes Ovrén
Senast uppdaterad: 2015-11-18