diff --git a/modules/python/test/test2.py b/modules/python/test/test2.py index 815993e8a1..cbdfc17771 100644 --- a/modules/python/test/test2.py +++ b/modules/python/test/test2.py @@ -8,22 +8,7 @@ import numpy as np import cv2 import cv2.cv as cv -class NewOpenCVTests(unittest.TestCase): - - def get_sample(self, filename, iscolor = cv.CV_LOAD_IMAGE_COLOR): - if not filename in self.image_cache: - filedata = urllib2.urlopen("https://raw.github.com/Itseez/opencv/2.4/" + filename).read() - image = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor) - self.assertFalse(image is None) - self.image_cache[filename] = image - return self.image_cache[filename] - - def setUp(self): - self.image_cache = {} - - def hashimg(self, im): - """ Compute a hash for an image, useful for image comparisons """ - return hashlib.md5(im.tostring()).digest() +from tests_common import NewOpenCVTests # Tests to run first; check the handful of basic operations that the later tests rely on diff --git a/modules/python/test/ticket_6.py b/modules/python/test/ticket_6.py deleted file mode 100755 index 7249ff2c75..0000000000 --- a/modules/python/test/ticket_6.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python - -import urllib -import cv2.cv as cv -import Image -import unittest - -class TestLoadImage(unittest.TestCase): - def setUp(self): - open("large.jpg", "w").write(urllib.urlopen("http://www.cs.ubc.ca/labs/lci/curious_george/img/ROS_bug_imgs/IMG_3560.jpg").read()) - - def test_load(self): - pilim = Image.open("large.jpg") - cvim = cv.LoadImage("large.jpg") - self.assert_(len(pilim.tostring()) == len(cvim.tostring())) - -class Creating(unittest.TestCase): - size=(640, 480) - repeat=100 - def test_0_Create(self): - image = cv.CreateImage(self.size, cv.IPL_DEPTH_8U, 1) - cnt=cv.CountNonZero(image) - self.assertEqual(cnt, 0, msg="Created image is not black. CountNonZero=%i" % cnt) - - def test_2_CreateRepeat(self): - cnt=0 - for i in range(self.repeat): - image = cv.CreateImage(self.size, cv.IPL_DEPTH_8U, 1) - cnt+=cv.CountNonZero(image) - self.assertEqual(cnt, 0, msg="Created images are not black. Mean CountNonZero=%.3f" % (1.*cnt/self.repeat)) - - def test_2a_MemCreated(self): - cnt=0 - v=[] - for i in range(self.repeat): - image = cv.CreateImage(self.size, cv.IPL_DEPTH_8U, 1) - cv.FillPoly(image, [[(0, 0), (0, 100), (100, 0)]], 0) - cnt+=cv.CountNonZero(image) - v.append(image) - self.assertEqual(cnt, 0, msg="Memorized images are not black. Mean CountNonZero=%.3f" % (1.*cnt/self.repeat)) - - def test_3_tostirng(self): - image = cv.CreateImage(self.size, cv.IPL_DEPTH_8U, 1) - image.tostring() - cnt=cv.CountNonZero(image) - self.assertEqual(cnt, 0, msg="After tostring(): CountNonZero=%i" % cnt) - - def test_40_tostringRepeat(self): - cnt=0 - image = cv.CreateImage(self.size, cv.IPL_DEPTH_8U, 1) - cv.Set(image, cv.Scalar(0,0,0,0)) - for i in range(self.repeat*100): - image.tostring() - cnt=cv.CountNonZero(image) - self.assertEqual(cnt, 0, msg="Repeating tostring(): Mean CountNonZero=%.3f" % (1.*cnt/self.repeat)) - - def test_41_CreateToStringRepeat(self): - cnt=0 - for i in range(self.repeat*100): - image = cv.CreateImage(self.size, cv.IPL_DEPTH_8U, 1) - cv.Set(image, cv.Scalar(0,0,0,0)) - image.tostring() - cnt+=cv.CountNonZero(image) - self.assertEqual(cnt, 0, msg="Repeating create and tostring(): Mean CountNonZero=%.3f" % (1.*cnt/self.repeat)) - - def test_4a_MemCreatedToString(self): - cnt=0 - v=[] - for i in range(self.repeat): - image = cv.CreateImage(self.size, cv.IPL_DEPTH_8U, 1) - cv.Set(image, cv.Scalar(0,0,0,0)) - image.tostring() - cnt+=cv.CountNonZero(image) - v.append(image) - self.assertEqual(cnt, 0, msg="Repeating and memorizing after tostring(): Mean CountNonZero=%.3f" % (1.*cnt/self.repeat)) - -if __name__ == '__main__': - unittest.main()