# Run with ./run-tests.sh

test_ocr_on_live_video() {
    cat > test.py <<-EOF
	import stbt
	
	text = stbt.ocr()
	assert text == "Hello there", "Unexpected text: %s" % text
	
	text = stbt.ocr(region=stbt.Region(x=70, y=180, width=90, height=40))
	assert text == "Hello", "Unexpected text: %s" % text
	EOF
    stbt run -v \
        --source-pipeline="videotestsrc pattern=black ! \
                textoverlay text=Hello\ there font-desc=Sans\ 48" \
        test.py
}

# Run with ./run-tests.sh

test_ocr_on_live_video() {
    cat > test.py <<-EOF
	import stbt
	
	stbt.frames(timeout_secs=30).next()  # wait 'til video pipeline playing
	text = stbt.ocr()
	assert text == "Hello there", "Unexpected text: %s" % text
	
	text = stbt.ocr(region=stbt.Region(x=70, y=180, width=90, height=40))
	assert text == "Hello", "Unexpected text: %s" % text
	EOF
    stbt run -v \
        --source-pipeline="videotestsrc pattern=black ! \
                textoverlay text=Hello\ there font-desc=Sans\ 48" \
        test.py
}

Fix timeout when run under load
test_ocr_on_live_video: Fix timeout when run under load

When run under heavy load (e.g. `make check` with GNU parallel
installed) this self-test could fail if the video pipeline hadn't
managed to start at all in the 10 seconds allowed by the call to
`get_frame` inside of `stbt.ocr()`.
