Esempio n. 1
0
    def test_preprocess_img(self):
        cv_img_good = zc.raw2cv_image(self.good_img)
        cv_img_bad = zc.raw2cv_image(self.bad_img)

        bitmap_good = preprocess_img(cv_img_good)
        self.assertTrue(bm.bitmap_same(bitmap_good, self.correct_state))
        self.assertFalse(bm.bitmap_same(bitmap_good, self.incorrect_state))

        with self.assertRaises(expected_exception=LEGOCVError) as e:
            bitmap_bad = preprocess_img(cv_img_bad)
Esempio n. 2
0
    def test_cv_real_frames(self):
        # clear, beautiful frames first:
        # first frame is a pic of an empty board
        frames = [zc.raw2cv_image(frame) for frame in self.step_frames_1]
        with self.assertRaises(NoLEGODetectedError):
            preprocess_img(frames[0])

        for frame, correct_bm in zip(frames[1:], self.task_bitmaps):
            bitmap = preprocess_img(frame)
            self.assertTrue(bm.bitmap_same(bitmap, correct_bm),
                            msg=f'\nCorrect bitmap: \n{correct_bm}\n'
                            f'\nReceived bitmap: \n{bitmap}\n')
Esempio n. 3
0
 def __eq__(self, other: BoardState) -> bool:
     return bm.bitmap_same(self._bitmap, other._bitmap)
Esempio n. 4
0
def _execute(img: np.ndarray) -> float:
    ti = time.time()
    bitmap = preprocess_img(img)
    assert bm.bitmap_same(bitmap, expected_bitmap)
    return time.time() - ti
Esempio n. 5
0
 def _fn(self: unittest.TestCase):
     parsed_bitmap = preprocess_img(zc.raw2cv_image(raw_img))
     self.assertTrue(bm.bitmap_same(exp_bitmap, parsed_bitmap),
                     msg=f'\nExpected bitmap: \n{exp_bitmap}\n'
                     f'\nReceived bitmap: \n{parsed_bitmap}\n')