{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "In research and development (R&D), interactive computing environments are a frequently employed alternative for data exploration, algorithm development and prototyping. In the last twelve years, a popular scientific computing environment flourished around the Python programming language. Most of this environment is part of (or built over) a software stack named the SciPy Stack. Combined to the OpenCV’s Python interface, this environment becomes an alternative for current computer vision R&D. This tutorial introduces such an environment and shows how it can address different steps on computer vision research, from initial data exploration to parallel computing implementations. Several code examples are presented, addressing problems from simple image processing to inference by machine learning.\n", "\n", "**About these notebooks**\n", "\n", "These notebooks are part of the tutorial *[SciPy and OpenCV as an interactive computing environment for computer vision](http://emap.fgv.br/sibgrapi-2014/tutorials.html)* to be presented at [SIBGRAPI 2014](http://emap.fgv.br/sibgrapi-2014/). The tutorial will be also available as a full paper in [*Revista de Informática Teórica e Aplicada (RITA)*](http://www.seer.ufrgs.br/index.php/rita/)." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Introduction" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## What are we looking for in a computing environment?" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "- **Data exploration and visualization**\n", " - Images, video sequences, point clouds and feature vectors\n", "- **Extensive list of tools**\n", " - Image processing\n", " - Machine learning\n", " - Optimization\n", " - Statistics\n", " - Linear algebra\n", "- **High-performance computing** (HPC)\n", "- Promote **reproducible research**" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "Computer vision practitioners need a computing environment that lets them explore data like images, video sequences, point clouds and feature vectors. Such an environment should help on the development and testing of new models and algorithms, and on the deployment of the results, either as a final software module or a scientific/technical publication. It should also provides an *extensive* list of tools, routines for image processing, machine learning, statistical inference, linear algebra, convex optimization and graph algorithms, just to name a few. Problems involving large sets of images can require high-performance computing (HPC) such that the environment should provide practical ways to parallelize and distribute computation. An ideal environment should also combine documentation and computation in a single bundle, promoting results reproducibility, but preventing the research pipeline to become more cumbersome." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## A Python-based environment \n", "![xkcd on Python](./figs/python.png)\n", "\n", "[http://xkcd.com/353/](http://xkcd.com/353/) by Randall Munroe" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "- *SciPy*, a **scientific computing** environment based on Python\n", " - Developed in the last **12 years**\n", "- Based on the **NumPy** module for $n$-dimensional arrays\n", "- Not just software, but a **community**\n", " - This community meets at [SciPy Conferences](http://conference.scipy.org)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "In the last twelve years, a powerful scientific computing environment emerged from the Python programming community. This language is an attractive option for researchers: it is interpreted (a wanted property for interactive computing environments), dynamically typed,\n", "and presents a very concise and elegant syntax, resembling the pseudo-code found in computer science textbooks. But the tipping point for Python to become a major player in scientific computing was the advent of an efficient module for $n$-dimensional array\n", "representation and manipulation. The Numarray module was created by [Greenfield *et al.*](http://adsabs.harvard.edu/abs/2002adass..11..140G) to address astronomical data analysis. In 2005, Numarray successor, [NumPy](http://www.numpy.org/), appeared and became the workhorse of the Python scientific computing. An active community composed by scientists and engineers flourished around Python and NumPy, represented today by the SciPy Stack and the [SciPy Conferences](http://conference.scipy.org). " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Why is an interactive environment important to computer vision?" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "In computer vision, the practitioner is interested in inferring the **world state** from images, that act as **observations**. The statistical relation between the world state and the observed images is defined by **models**. A particular model is defined by **parameters**, chosen by **learning algorithms**. Finally, the world state is estimated by **inference algorithms**." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ " This *vision on computer vision* is properly presented by Prince in [his book](http://www.computervisionmodels.com/) and translates the state-of-the-art of contemporary research in the field, which is deeply associated to machine learning nowadays." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "- Environment should enable tinkering with machine learning techniques\n", "- Visualization and exploration tools to address problems involving:\n", " - generalization,\n", " - overfitting,\n", " - dimensionality reducion,\n", " - optimization\n", "- The SciPy environment provides these capabilities" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "The development of these models and subsequent problems in learning and inference require a computing environment that allows proper tinkering with machine learning techniques. Visualization and exploration tools are necessary to address problems involving generalization, overfitting, dimensionality reduction and optimization. An interactive computing environment as [IPython](ython.org/), enriched with tools from the SciPy Stack and the OpenCV library, can address these needs." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## This tutorial introduces\n", "\n", "- interactive computing *and* HPC with the **IPython** shell;\n", "- **OpenCV** use under Python;\n", "- **Matplotlib** for visualization and 2D plotting;\n", "- the SciPy **scientific library** and\n", "- machine learning with the **scikit-learn** module" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "* This tutorial provides a *glimpse*, not a broad and deep coverage\n", "* Examples should provide a starting point for the insterested user" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "The present tutorial provides a short overview on this Python-based computing environment. Considering the large set of tools available and the space constraints, this tutorial does not pretend to be a complete reference or a broad review. It provides just a glimpse of the environment's capabilities to the computer vision community, briefly presenting and discussing some problems and code examples. These examples can guide the user's first steps and the provided references help on the next ones. " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Available material\n", "\n", "**IPython notebooks** presenting the complete code for the examples are available on \n", "\n", "[http://nbviewer.ipython.org/github/thsant/scipy4cv](http://nbviewer.ipython.org/github/thsant/scipy4cv) \n", "\n", "and on GitHub:\n", "\n", "[https://github.com/thsant/scipy4cv](https://github.com/thsant/scipy4cv) " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Installation\n", "\n", "### Windows, Mac, and Linux\n", "\n", "Consider **Continuum Analytics’s Anaconda distribution**:\n", "\n", "[http://continuum.io/downloads](http://continuum.io/downloads)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "### Linux\n", "\n", "- Consider your system's package manager\n", "- For Debian/Ubuntu:" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ " $ sudo apt-get install ipython ipython-qtconsole ipython-notebook\n", " \n", " $ sudo apt-get install python-scipy python-matplotlib \n", " \n", " $ sudo apt-get install python-sklearn python-skimage" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Using Python pip\n", "\n", " $ pip install ipython jupyter scipy matplotlib scikit-learn scikit-image" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "### OpenCV\n", "\n", "* OpenCV's documentation provides [installation tutorials](http://docs.opencv.org/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.html#table-of-content-introduction)\n", "* Continuum Anaconda also provides OpenCV" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "As a general guideline, users should always consider the most recent installation instructions provided by the packages’ maintainers. To the date, Windows, Mac and Linux users could consider [Continuum Analytics’s Anaconda distribution](http://continuum.io/downloads) as one of the easiest ways to get all the environment presented in this tutorial. Linux users can also use the package manager of their systems to effortless download and install the components (as the `apt-get` system in Debian/Ubuntu distributions). The [pip tool](https://pypi.python.org/pypi/pip) is also a practical way to get the packages and keep them updated." ] } ], "metadata": { "celltoolbar": "Slideshow", "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.12" } }, "nbformat": 4, "nbformat_minor": 0 }