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.
tests: refactoring: Use set_config consistently

Standardise on a way of setting configuration values in tests using the
recent work on improved test sandboxing and the introduction of
`_set_config()`.

The tests are now shorter, more declarative and easier to read.  This
helper function replaces a surprising diversity in the ways in which sed
was used.
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.  This will be used for Smart TV support some of
our test patterns are generated from textual descriptions and we want to
match sub-images within them.  e.g. the "letters" test pattern looks like:

    ABCDEFG
    HIJKLMN
    OPQRSTU

and we want to check the locations of each of the letters to confirm that
they're in the right places.

Nonetheless it seems that this could be generally very useful.

Possible example uses:

* You are navigating a carousel of DVD box covers and want to check that
  it correctly wraps back to the beginning.  The code could look like:

        # Grab the currently shown DVD cover given that we know its
        # location and size:
        initial_dvd_cover = stbt.get_frame()[300:700,500:700]

        stbt.press("KEY_RIGHT")
        stbt.press_until_match("KEY_RIGHT", initial_dvd_cover)

* You have an image and you want to find out which way up it is being
  displayed:

        def get_orientation():
            arrow = cv2.imread("arrow.png")
            if matches(arrow):
                return 1
            elif matches(cv2.flip(arrow)):
                return -1
            else:
                raise RuntimeError("Can't find arrow")

Future work: This feature (and stb-tester in general) would really benefit
with some tutorial style documentation to help introduce concepts and
explain when the various features of stb-tester should be applied.