Update the changelog
[opencv] / tests / python / highgui / cvWaitKey.py
1 #! /usr/bin/env python
2 """
3 This script will test highgui's cvWaitKey(int) function
4 """
5
6 # name of this test and it's requirements
7 TESTNAME = "cvWaitKey"
8 REQUIRED = ["cvShowImage"]
9
10 # needed for sys.exit(int) and .works file handling
11 import os
12 import sys
13 import works
14
15 # path to imagefiles we need
16 PREFIX=os.environ["top_srcdir"]+"/tests/python/testdata/images/"
17
18 # check requirements and delete old flag file, if it exists
19 if not works.check_files(REQUIRED, TESTNAME):
20         sys.exit(77)
21
22
23 # import the necessary things for OpenCV
24 import python
25 from python.highgui import *
26
27 # request some user input
28 print "(INFO) Press anykey within the next 20 seconds to 'PASS' this test." 
29
30 # create a dummy window which reacts on cvWaitKey()
31 cvNamedWindow(TESTNAME, CV_WINDOW_AUTOSIZE)
32
33 # display an image
34 cvShowImage(TESTNAME, cvLoadImage(PREFIX+"cvWaitKey.jpg"))
35
36 # wait 20 seconds using cvWaitKey(20000),
37 # return 'FAIL' if no key has been pressed.
38 if cvWaitKey(20000) == -1:
39         print "(ERROR) No key pressed, remarking as 'FAIL'."
40         sys.exit(1)
41
42 #create flag file for the following tests
43 works.set_file(TESTNAME)
44
45 # return 0 ('PASS')
46 sys.exit(0)