Beispiel #1
0
    def _test_remove_reddot(self, img):

        f0 = CalibrateRedDotFilter()
        f1 = SeparateObjectFilter()
        meta_img = MetaImg(img, {})
        f0.filter(meta_img)
        f1.filter(meta_img)
        self.assertLess(np.sum(meta_img.meta['mask']) / 255, 40)
Beispiel #2
0
 def _test_remove_reddot(self, img):
     
     f0 = CalibrateRedDotFilter()
     f1 = SeparateObjectFilter()
     meta_img = MetaImg(img, {})
     f0.filter(meta_img)
     f1.filter(meta_img)
     self.assertLess(np.sum(meta_img.meta['mask'])/255, 40)
Beispiel #3
0
 def test_chess_speed(self):
     im3 = cv2.imread('tests/reddot_seed.jpg', cv2.CV_LOAD_IMAGE_COLOR)
     f1 = CalibrateRedDotFilter({'dims': (4, 4), 'dot_diameter_in_mm': 5})
     t = time()
     for i in xrange(25):
         meta_img = MetaImg(np.array(im3), {})
         f1.filter(meta_img)
     t2 = time()
     self.assertLess(t2 - t, 4)
Beispiel #4
0
 def test_chess_speed(self):
     im3 = cv2.imread('tests/reddot_seed.jpg', cv2.CV_LOAD_IMAGE_COLOR)
     f1 = CalibrateRedDotFilter({'dims': (4,4),
                                'dot_diameter_in_mm': 5})
     t = time()
     for i in xrange(25):
         meta_img = MetaImg(np.array(im3), {})
         f1.filter(meta_img)
     t2 = time()
     self.assertLess(t2-t, 4)
Beispiel #5
0
    def full_fitlers_test(self):
        im3 = cv2.imread('tests/reddot_seed.jpg', cv.CV_LOAD_IMAGE_COLOR)
        f1 = CalibrateRedDotFilter({'dims': (4, 4), 'dot_diameter_in_mm': 5})
        f2 = SeparateObjectFilter()

        t = time()
        for i in xrange(5):
            meta_img = MetaImg(np.array(im3), {})
            f1.filter(meta_img)
            f2.filter(meta_img)
        t2 = time()
        self.assertLess(t2 - t, 5)  #at least 2 frames for second
Beispiel #6
0
 def test_filter(self):
     im3 = cv2.imread('tests/reddot_seed.jpg', cv2.CV_LOAD_IMAGE_COLOR)
     f = CalibrateRedDotFilter()
     meta_img = MetaImg(im3, {})
     f(meta_img)
     self.assertTrue(meta_img.meta['ok'])
     self.assertLess(abs(meta_img.meta['mm_on_px'] - 0.0105), 0.005)
Beispiel #7
0
 def full_fitlers_test(self):
     im3 = cv2.imread('tests/reddot_seed.jpg', cv.CV_LOAD_IMAGE_COLOR)
     f1 = CalibrateRedDotFilter({'dims': (4,4),
                                'dot_diameter_in_mm': 5})
     f2 = SeparateObjectFilter()
     
     t = time()
     for i in xrange(5):
         meta_img = MetaImg(np.array(im3), {})
         f1.filter(meta_img)
         f2.filter(meta_img)
     t2 = time()
     self.assertLess(t2-t, 5) #at least 2 frames for second
 
     
     
     
Beispiel #8
0
    def test_measure(self):
        im3 = cv2.imread('tests/reddot_seed.jpg', cv.CV_LOAD_IMAGE_COLOR)
        f1 = CalibrateRedDotFilter({'dims': (4, 4), 'dot_diameter_in_mm': 5})
        f2 = SeparateObjectFilter()

        meta_img = MetaImg(im3, {})
        f1(meta_img)
        f2(meta_img)
        print meta_img.meta['ellipsis']
Beispiel #9
0
 def __init__(self, video_widget, conf):
     super(VideoThread, self).__init__()
     self.cam_num = conf.get('cam_num', 0)
     self.red_dot_diameter = conf.get('dot_diameter_in_mm', 1)
     self._frame_count = 0
     self._show_detail = False
     self._killed = False
     self._show_mask = False
     self._prev_grab_res = (1280, 1024)
     self._snap_grab_res = (2592, 1944)
     self.video_widget = video_widget
     self._cam_mutex = Lock()
     
     self.calib_filter = CalibrateRedDotFilter({'dot_diameter_in_mm': self.red_dot_diameter})
     self.sep_filter = SeparateObjectFilter()
     
     self._timer = QTimer()
     self._timer.timeout.connect(self.on_frame)
Beispiel #10
0
 def test_red_filter(self):
     im3 = cv2.imread('tests/reddot_seed.jpg', cv2.CV_LOAD_IMAGE_COLOR)
     f = CalibrateRedDotFilter()
     imred = f._red_filter(im3)
     self.assertGreater(np.sum(imred), 400)
Beispiel #11
0
    def test_avg(self):
        f1 = CalibrateRedDotFilter({'dims': (3, 2)})
        avg = f1._avg_diameter(((10, 10), (20, 30), 78))

        self.assertAlmostEqual(avg, 25)
Beispiel #12
0
 def test_gray(self):
     f1 = CalibrateRedDotFilter()
     meta_img = MetaImg(self.lena3, {})
     f1(meta_img)
     self.assertEqual(meta_img.gray.shape[:2], self.lena3_ref.shape[:2])
Beispiel #13
0
 def test_red_filter(self):
     im3 = cv2.imread('tests/reddot_seed.jpg', cv2.CV_LOAD_IMAGE_COLOR)
     f = CalibrateRedDotFilter()
     imred = f._red_filter(im3)
     self.assertGreater(np.sum(imred), 400)
Beispiel #14
0
 def test_avg(self):
     f1 = CalibrateRedDotFilter({'dims':(3,2)})
     avg = f1._avg_diameter(((10,10),(20,30),78))
     
     self.assertAlmostEqual(avg, 25)