Changes in facedetect test
This commit is contained in:
parent
87fc75c6d7
commit
0c6e09f060
@ -133,6 +133,10 @@ if __name__ == '__main__':
|
|||||||
print("Testing OpenCV", cv2.__version__)
|
print("Testing OpenCV", cv2.__version__)
|
||||||
print("Local repo path:", args.repo)
|
print("Local repo path:", args.repo)
|
||||||
NewOpenCVTests.repoPath = args.repo
|
NewOpenCVTests.repoPath = args.repo
|
||||||
|
try:
|
||||||
|
NewOpenCVTests.extraTestDataPath = os.environ['OPENCV_TEST_DATA_PATH']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
random.seed(0)
|
random.seed(0)
|
||||||
unit_argv = [sys.argv[0]] + other;
|
unit_argv = [sys.argv[0]] + other;
|
||||||
unittest.main(argv=unit_argv)
|
unittest.main(argv=unit_argv)
|
@ -31,8 +31,7 @@ class facedetect_test(NewOpenCVTests):
|
|||||||
cascade = cv2.CascadeClassifier(cascade_fn)
|
cascade = cv2.CascadeClassifier(cascade_fn)
|
||||||
nested = cv2.CascadeClassifier(nested_fn)
|
nested = cv2.CascadeClassifier(nested_fn)
|
||||||
|
|
||||||
dirPath = 'samples/data/'
|
samples = ['samples/data/lena.jpg', 'cv/cascadeandhog/images/mona-lisa.png']
|
||||||
samples = ['lena.jpg', 'kate.jpg']
|
|
||||||
|
|
||||||
faces = []
|
faces = []
|
||||||
eyes = []
|
eyes = []
|
||||||
@ -43,17 +42,17 @@ class facedetect_test(NewOpenCVTests):
|
|||||||
[ 244, 240, 294, 290],
|
[ 244, 240, 294, 290],
|
||||||
[ 309, 246, 352, 289]],
|
[ 309, 246, 352, 289]],
|
||||||
|
|
||||||
#kate
|
#lisa
|
||||||
[[207, 89, 436, 318],
|
[[167, 119, 307, 259],
|
||||||
[245, 161, 294, 210],
|
[188, 153, 229, 194],
|
||||||
[343, 139, 389, 185]]
|
[236, 153, 277, 194]]
|
||||||
]
|
]
|
||||||
|
|
||||||
for sample in samples:
|
for sample in samples:
|
||||||
|
|
||||||
img = self.get_sample(dirPath + sample)
|
img = self.get_sample( sample)
|
||||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||||
gray = cv2.GaussianBlur(gray, (3, 3), 1.1)
|
gray = cv2.GaussianBlur(gray, (5, 5), 5.1)
|
||||||
|
|
||||||
rects = detect(gray, cascade)
|
rects = detect(gray, cascade)
|
||||||
faces.append(rects)
|
faces.append(rects)
|
||||||
|
@ -19,6 +19,7 @@ class NewOpenCVTests(unittest.TestCase):
|
|||||||
|
|
||||||
# path to local repository folder containing 'samples' folder
|
# path to local repository folder containing 'samples' folder
|
||||||
repoPath = None
|
repoPath = None
|
||||||
|
extraTestDataPath = None
|
||||||
# github repository url
|
# github repository url
|
||||||
repoUrl = 'https://raw.github.com/Itseez/opencv/master'
|
repoUrl = 'https://raw.github.com/Itseez/opencv/master'
|
||||||
|
|
||||||
@ -30,6 +31,11 @@ class NewOpenCVTests(unittest.TestCase):
|
|||||||
if os.path.isfile(candidate):
|
if os.path.isfile(candidate):
|
||||||
with open(candidate, 'rb') as f:
|
with open(candidate, 'rb') as f:
|
||||||
filedata = f.read()
|
filedata = f.read()
|
||||||
|
if NewOpenCVTests.extraTestDataPath is not None:
|
||||||
|
candidate = NewOpenCVTests.extraTestDataPath + '/' + filename
|
||||||
|
if os.path.isfile(candidate):
|
||||||
|
with open(candidate, 'rb') as f:
|
||||||
|
filedata = f.read()
|
||||||
if filedata is None:
|
if filedata is None:
|
||||||
filedata = urlopen(NewOpenCVTests.repoUrl + '/' + filename).read()
|
filedata = urlopen(NewOpenCVTests.repoUrl + '/' + filename).read()
|
||||||
self.image_cache[filename] = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor)
|
self.image_cache[filename] = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 40 KiB |
Loading…
x
Reference in New Issue
Block a user