[opencv] 73/98: Fix for nonlocal data requirement in test2.py

Mattia Rizzolo mattia at debian.org
Tue Oct 4 17:51:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to annotated tag 2.4.13
in repository opencv.

commit 34b3d31f5499ea258ff60a2821144f903fc7a1a3
Author: Vitaly Tuzov <vitaly.tuzov at itseez.com>
Date:   Tue Apr 5 11:21:22 2016 +0300

    Fix for nonlocal data requirement in test2.py
---
 modules/python/test/test2.py    | 17 +--------
 modules/python/test/ticket_6.py | 78 -----------------------------------------
 2 files changed, 1 insertion(+), 94 deletions(-)

diff --git a/modules/python/test/test2.py b/modules/python/test/test2.py
index 815993e..cbdfc17 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 7249ff2..0000000
--- 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()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git



More information about the debian-science-commits mailing list