In this course we will use Python with OpenCV. But do read on.
The objective of this lab is for you to setup your computer for computer vision system development.
In the past the easiest way to experiment with computer vision was through Matlab. Matlab is available for Windows, Linux and OSX. If your system doesn't already come with Matlab or if you don't find Matlab on Landisk then most likely you will not be able to install Matlab. Matlab is a fairly costly software package, and I don't suggest that you buy a license of Matlab for this course.
So if you have Matlab, good; otherwise, don't worry about it for now.
GNU Octave is an free open-source clone of Matlab. You can get it from here https://www.gnu.org/software/octave/download.html. You may find it useful.
It is now possible to use Python for rapid computer vision system development and experimentation in lieu of a package, such as Matlab. You will need to install a number of python scientific packages - Numpy, Scipy, Matplotlib, Image, Notebook - plus rely upon OpenCV python bindings to use Python for comptuer vision system development. It is easier to setup your system to use Python for computer vision than it sounds. Your best bet is to download Enthought Canopy Python distribution (with academic license). This distribution come pre-loaded with everything that you will need to rapidly develop computer vision systems. Enthought Canopy Python distribution is available for a number of platforms, see https://www.enthought.com/products/canopy/. Another powerful Python distribution is Anaconda.
You may also want to look at http://simplecv.org/. Although it is quite limited.
A time will come when you will find that your programs are too slow. You will be amazed how large images and videos actually are. These are many orders of magnitude larger than text files. At that time Python, Matlab or Octave will not serve your purpose. You will have to rely upon something more efficient, such as C/C++, for example. In order to use C/C++ for computer vision system development, you will need to rely upon existing computer vision and image processing libraries, such as OpenCV or VLFeat. It is best if you set up your system to use one of these libraries. This will especially be useful for your course project.
In this course we will use Python with OpenCV. For your project, you are free to use any of the above choices.
You can use any of the following approaches to install Python + NumPy + SciPy + OpenCV + Matplotlib + Notebook on your machine.
Don't forget to also install iPython Notebook.
This program loads an image
test.jpg from the current directory and displays it in a window. Press Esc key to dismiss the window. This is how you will be writing python computer vision applications.
import cv2 im = cv2.imread('test.jpg') cv2.imshow('Image', im) print('Press Esc to exit') cv2.waitKey(0)
The IPython Notebook provides an interactive computational environment that combines code execution with plotting and rich media. In the absence of full-fledged Matlab (or Octave), Python Notebook's is an excellent way to experiment with Python code.
Check out IPython Notebook documentation for information about how to install it on your system. See here.
You should complete the following tasks:
> python loadimg test.png Press q to exit
> python loadcam Press q to exit
> python loadmov traffic-short.mp4 Press q to exit
> python loadimg --gray test.png Press q to exit
> python loadimage --crop 10 10 30 20 test.png Press q to exit
> python loadimage --channel 0 test.jpg Press q to exit
These programs will use
opencv to implement the required functionality. I suggest you use
argparse for processing commandline arguments. Each program simply shows a window that will show frame(s) from the loaded image, the video or the camera.
Check out the following iPython notebooks.
loadmov.py files via Blackboard.