stbt run: Dump pipeline-error debug from the right pipeline

If you define the environment variable `GST_DEBUG_DUMP_DOT_DIR` and a
GStreamer error occurs, `stbt run` will dump a Graphviz dot file with
debugging information (see 7b3eaf33). Previously we always dumped
debugging information for the *source* pipeline, even if the error came
from the *sink* pipeline.
stbt batch run: Classify blackmagic failure correctly

The classification for errors due to the Blackmagic Intensity Pro
video-capture card hasn't worked correctly since we ported stbt to
GStreamer 1.0 in commit a83333a2.

Also the "blackmagic card in use by another process" detection logic
hasn't worked since the blackmagic device moved from /dev/blackmagic0 to
/dev/blackmagic/dv0 -- presumably this changed with the recently
released blackmagic 10.0 driver. We look at both locations, thus
providing an upgrade path to users (upgrade stb-tester first, then
upgrade the blackmagic driver -- if you care enough about getting this
error classification right).

Thanks to Lewis Haley for the bug report and for the detailed solution.
Fixes #144.
Merge pull request #148 from drothlis/blackmagic-classification

stbt batch run: Classify blackmagic failure correctly
Bug fix: Ensure that frames are still dropped even after a pipeline restart

If stbt's image analysis is slower than real time frames can get queued
up in the pipeline meaning that the frames we are operating on may be out
of date.  To minimise this latency we drop frames from a queue in the
GStreamer pipeline.

This commit fixes a bug introduced in b8d39d4 where this leaky behaviour
was not being applied after the pipeline was restarted.
stbt.py, stbt-tv: Move the leaky queue right after `decodebin`

This commit resolves high latency of video frames on slow computers by
ensuring that an appropriate number of frames are dropped.

The latency is too high if the same queue is after `videoconvert` even
though the property `leaky=downstream` is set. The idea that the leaky
queue should come before `videoconvert` is the outcome of
trial-and-error.

It is in-keeping with the idea in the pipeline that we shouldn't be
throwing away frames we've done significant processing on.

Note that the slow-down is due to `decodebin` and not stbt's video
processing algorithm. Using `stbt tv` (i.e. a simple video capture
pipeline) without a leaky queue after `decodebin` also results in high
latency.

The "slow computer" used for testing had 2.4 GHz Core 2 Duo CPU.
stbt screenshot: Skip first frame

Some V4L video-capture hardware delivers a single black frame before the
real video stream.
Merge pull request #152 from drothlis/stbt-screenshot-skip-first-frame

stbt screenshot: Skip first frame
Merge pull request #151 from szemate/ensure-that-frames-are-dropped

Fix high latency of video frames on slow computers
README.rst: Update byline to match stb-tester.com

This is the first step in clearer documentation & promotional material
about stb-tester's true capabilities -- it isn't restricted to set-top
boxes.
make check: Enforce pep8 `import` order

PEP8 says: [1]

> Imports should be grouped in the following order:
>
> 1. standard library imports
> 2. related third party imports
> 3. local application/library specific imports
>
> You should put a blank line between each group of imports.

If we're going to follow this convention, let's make the computer check
it to avoid wasting reviewer cycles.

Unfortunately neither the `pep8` tool nor `pylint` have checks to
enforce this. Instead, we use `isort`[2] from PyPI (pip install isort).

If you have trouble getting a file to pass isort's check, run
`isort` (without `--check-only`) on the file to fix it in-place.
To keep this as convenient as possible, don't customise isort's
formatting rules in our pylint.sh.

[1] http://legacy.python.org/dev/peps/pep-0008/#imports
[2] https://pypi.python.org/pypi/isort/
make check: check pep8 import order only if `isort` is installed

`isort` isn't installable with yum/apt-get on Fedora, Debian or Ubuntu;
some developers find it a bit annoying to be forced to use pip, so make
this optional. The important thing is that Travis will check it.
make check: Run pylint before unit & integration tests

Static analysis is faster than our dynamic tests, so if static analysis
is going to fail the build we want to fail as quickly as possible.
make check: Log details when isort fails

isort (3.8.0) passes on my PC, but fails on Travis (isort version
???). We need some diagnostic information.

Note that `isort --diff --check-only` doesn't work; `--check-only` takes
priority and `--diff` is ignored.
Add .isort.cfg to fix false positives on Travis

When run on Travis, `isort` thinks that `binascii` is a 3rd-party
module (it's part of the python standard library), and that `cv2` is a
standard library (it's a third-party library, from `apt-get install
python-opencv`). I don't know why.

I've raised https://github.com/timothycrosley/isort/issues/157
Merge pull request #154 from drothlis/make-check--import-order

make check: Enforce pep8 `import` order
OCR: Add script for measuring OCR effectiveness

validate-ocr.py can be run on a corpus of test images reporting how good a
job stbt has done of reading the text.  Thus it can be used to measure
improvements to the OCR algorithm and, more importantly, detect any
regressions introduced.

This tool is designed such that it can be run on corpuses outside the
stb-tester git tree to allow corpuses containing screen captures from many
set-top boxes without bloating the main stb-tester repo or risking
upsetting the owners of the creators of the various set-top box UIs.

It is not currently run in-tree as a part of make check.

Thanks to david@rothlis.net and lewis.haley@youview.com for review and
fixups.
Region: Add convenience methods

Sometimes it's convenient to think in terms of width and height, other
times in terms of extents.  The addition of `right`, `bottom` and
`from_extents` to `Region` allow either model to be used as convenient.

These and the `_bounding_box` helper function will be useful for more
advanced uses of OCR which requires manipulating regions.
OCR: Support tesseract writing to files with any extension

The second argument to the tesseract command line tool is "output base"
which is a filename to which an extension will be appended.  Unfortunately
this extension varies depending on the arguments passed to tesseract and
even varies between different versions of tesseract[^1].

Using a temporary directory means that we don't need to know the extension
in advance and we can read the output independent of the extension that
tesseract appends.

[^1]: In hOCR mode tesseract 3.02 will write to base.html whereas 3.03 will
      write to base.hocr.
Refactor: _tesseract: Require that a frame to be passed in

This removes a dependency on `Display` from `_tesseract` making it a pure
function depending entirely on it's arguments and producing no
side-effects[^1].  This makes uses of it clearer.

[^1]: Or close enough.
Refactor: _tesseract: Allow passing a `Gst.Sample` as frame

This was originally written to allow getting the timestamp of frames being
passed to `_tesseract` allowing returning richer information.  This has not
yet been done but being able to pass a `GstSample` is still a nice thing to
be able to do.  It makes _tesseract more like the other image analysis
functions and has the pleasant side-effect of reducing copying.