WIP: Allow passing a numpy array as a template to match functions

This allows templates to be generated on-the-fly without having to create
intermediate image files.

TODO:

* Write tests
* Add documentation
stbt tv: Allow complex source pipelines with shell escaping

Previously if you had a stbt.conf like:

    source_pipeline=mysrc property="prop with spaces"

bash would get confused and would pass `property="prop` as `$2` and
separately pass `with` as `$3` and `spaces"` as `$4`.  Using `eval` fixes
this issue although it does make me slightly worried that if some bash
syntax inadvertently ended up in source_pipeline stbt tv could behave
oddly.

This is required for smart-tv support as, due to the complexities of
image processing `source_pipeline`s can require many complex parameters.
debugging: Add checking to gst_to_opencv

OpenCV requires video frames in BGR format.  Previously if you passed a
`GstSample` in another format (e.g. I420 or RGB) `gst_to_opencv` would
either produce a cryptic error message or silently continue having done
the wrong thing.

This commit fixes that by adding an assertion.  Admittedly you have to try
pretty hard to get your hands on a non BGR format `GstSample` but I've
managed it in the past and this would have saved me some debugging effort.
Self-Tests: Improve sandboxing

Take a copy of `stbt.conf` so tests are free to make modifications to it.
Also move `$XDG_CACHE_HOME` into test sandbox dir.  This will be useful
for smart TV support as the calibration and test programs will need to
generate videos for display on the TVs.
Smart TV Support: Add command stbt camera

Entry point for stb-tester support for pointing a camera at a TV.  It is
just a placeholder for now.  Real functionality will be added in later
commits.

Building camera support is optional, as is installing it with rpm as the
RPMs are split into stb-tester and stb-tester-camera.  This will allow
expressing additional dependencies required for camera support but not for
the rest.
Add helper library for generating videos based on stills
Add tv driver
Add fake TV driver for testing
WIP: fake-video-src: Add overlay
WIP: Smart TV support: Add command stbt camera validate

stbt camera validate is intended to measure the quality of video capture
that a camera (plus the software corrections to that camera) provides.  It
does this by displaying images on the TV and then compares the output to
what was expected producing a report.

Currently it defers responsibility for displaying the reference images on
the TV to the user, but support for automatic TV control using DLNA is
coming in the future.

TODO:
* Validate that tests are sufficient?
* Makefile stuff to install validator
* Don't hard-code paths
* Split TV drivers into different python file
WIP: Add video_transformation_pipeline

Turns out that we need more control over the pipeline than we thought.
Add stbt camera calibrate
WIP: Smart TV Support: Perform geometric correction to reconstruct TV image

Like set-top boxes, Smart TVs run complex software, including software
not provided by the manufacturer (e.g. apps).  Unlike set-top boxes they
provide no digital video output - the only video output they provide is
to screen.  So to support testing software running on TVs we need to
capture the contents of the TV screen.

We plan to do this with a webcam and some image processing to get the
contents of the screen such that we can feed that into GStreamer.  The
image processing will correct for problems with the positioning of the
camera and issues with the lens (which we will call "flattening") as well
as problems with the colours and brighness of the pixels.

This commit adds a GStreamer element `stbtwatchplane` which flattens the
image by first undoing distortions due to the camera lens and then
extracting the region in the undistorted image that corresponds to the
TV (homography) like:

                  |----------------------------|
    1080p         |       stbtwatchplane       |        720p
  Image from  --> |                            | --> Contents of
    Camera        | Undistort  --> Perspective |         TV
                  |----------------------------|

Undistort is parameterised by the properties:

* `camera-matrix` - A 3x3 matrix of the form:

        f_x   0   c_x
         0   f_y  c_y
         0    0    1

* `distortion-coefficients` - 5 values of the form:

        k_1, k_2, p_1, p_2, k_3

The perspective transformation is parameterised by the property:

* `homography-matrix` - A 3x3 matrix.

See the OpenCV documentation for more information[1].

The combined undistort/perspective transformation is actually done in one
operation.  We create a 1280x720 matrix where each "pixel" contains (x, y)
coordinates of where the real pixel value should be taken from in the
source 1080p image.  The OpenCV function `cvRemap` then justs looks
through this matrix to produce a 720p image from the 1080p input.

We generate this remapping matrix by tracing pixel locations from the 720p
image back through to the location on the 1080p image.  This means doing
the reverse perspective transformation on the coordinates and then
distorting the coordinates.

`stbt camera calibrate` is enhanced to generate the parameters described
above by displaying an image of a chessboard on the TV and then comparing
the measured values to the expected ones.

In test with real life TVs this calibration/correction achieves pixel
perfect positioning according to `stbt camera validate`.

This commit adds an optional build-time/test-time dependency on a C
compiler, OpenCV development headers and GStreamer development headers.
If they are not installed the GStreamer element will not be built.

[1]: http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html

TODO:
* Rename stbtwatchplane to stbtgeometriccorrection
* Add tests for calibration
WIP: Smart TV Support: Add stbtvignettecorrect element

Does location dependent contrast stretching

TODO:
* Add documetation
* Rename stbtcontraststretch or stbtilluminationcorrect
WIP: Add interactive colour adjustment

TODO:
Show graphs
REMOVEME: Disable manual driver integration test
stbt camera calibrate: Optimise for C920 with Samsung UE32F5370