2013-04-11 22:34:04 +08:00
|
|
|
#!/usr/bin/env python
|
2012-11-24 02:57:22 +08:00
|
|
|
|
2014-08-07 12:51:48 +08:00
|
|
|
from __future__ import print_function
|
2011-05-04 00:00:31 +08:00
|
|
|
import unittest
|
|
|
|
import random
|
|
|
|
import time
|
|
|
|
import math
|
|
|
|
import sys
|
|
|
|
import array
|
|
|
|
import tarfile
|
|
|
|
import hashlib
|
|
|
|
import os
|
|
|
|
import getopt
|
|
|
|
import operator
|
|
|
|
import functools
|
2013-03-25 04:42:46 +08:00
|
|
|
import numpy as np
|
|
|
|
import cv2
|
2014-12-03 23:12:01 +08:00
|
|
|
import argparse
|
2011-05-04 00:00:31 +08:00
|
|
|
|
2014-08-07 12:51:48 +08:00
|
|
|
# Python 3 moved urlopen to urllib.requests
|
|
|
|
try:
|
|
|
|
from urllib.request import urlopen
|
|
|
|
except ImportError:
|
|
|
|
from urllib import urlopen
|
|
|
|
|
2016-01-28 20:43:08 +08:00
|
|
|
from tests_common import NewOpenCVTests
|
2011-05-04 00:00:31 +08:00
|
|
|
|
2013-04-12 21:39:16 +08:00
|
|
|
# Tests to run first; check the handful of basic operations that the later tests rely on
|
2011-05-04 00:00:31 +08:00
|
|
|
|
2016-01-29 23:00:18 +08:00
|
|
|
basedir = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
|
|
|
def load_tests(loader, tests, pattern):
|
|
|
|
tests.addTests(loader.discover(basedir, pattern='test_*.py'))
|
|
|
|
return tests
|
|
|
|
|
2011-05-04 00:00:31 +08:00
|
|
|
if __name__ == '__main__':
|
2014-12-03 23:12:01 +08:00
|
|
|
parser = argparse.ArgumentParser(description='run OpenCV python tests')
|
|
|
|
parser.add_argument('--repo', help='use sample image files from local git repository (path to folder), '
|
|
|
|
'if not set, samples will be downloaded from github.com')
|
|
|
|
parser.add_argument('--data', help='<not used> use data files from local folder (path to folder), '
|
|
|
|
'if not set, data files will be downloaded from docs.opencv.org')
|
|
|
|
args, other = parser.parse_known_args()
|
2014-08-07 12:51:48 +08:00
|
|
|
print("Testing OpenCV", cv2.__version__)
|
2014-12-03 23:12:01 +08:00
|
|
|
print("Local repo path:", args.repo)
|
|
|
|
NewOpenCVTests.repoPath = args.repo
|
2016-02-05 23:46:43 +08:00
|
|
|
try:
|
|
|
|
NewOpenCVTests.extraTestDataPath = os.environ['OPENCV_TEST_DATA_PATH']
|
|
|
|
except KeyError:
|
2016-02-24 18:09:42 +08:00
|
|
|
print('Missing opencv extra repository. Some of tests may fail.')
|
2011-05-04 00:00:31 +08:00
|
|
|
random.seed(0)
|
2017-09-03 19:17:15 +08:00
|
|
|
unit_argv = [sys.argv[0]] + other
|
2014-12-03 23:12:01 +08:00
|
|
|
unittest.main(argv=unit_argv)
|