def run(self): """ Function handle run_detector_button. """ detector = DataMatrixDetector(self.db) detector.set_template("data_matrixes/template.jpg") camera = Camera() camera.OnCapture += detector.detect_matrix camera.run()
def test_check_matrix(self): expect = [[1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 0], [1, 0, 1, 1, 1, 1], [1, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1]] #rotated to the right test = [[1,1,1,1,1,1], [0,0,1,0,0,1], [1,0,0,1,1,1], [0,0,1,1,1,1], [1,0,0,1,0,1], [0,1,0,1,0,1]] db = DBConnection("../data_base/test_base.db") det = DataMatrixDetector(db) det.set_template("../data_matrixes/template.jpg") self.assertTrue(det.check_matrix(expect)) self.assertFalse(det.check_matrix(test))
def test_turn_matrix(self): expect = [[1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 0], [1, 0, 1, 1, 1, 1], [1, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1]] #rotated to the right test = [[1,1,1,1,1,1], [0,0,1,0,0,1], [1,0,0,1,1,1], [0,0,1,1,1,1], [1,0,0,1,0,1], [0,1,0,1,0,1]] db = DBConnection("../data_base/test_base.db") det = DataMatrixDetector(db) det.set_template("../data_matrixes/template.jpg") test = det.turn_matrix(test) self.assertEqual(test,expect)
def test_set_template(self): db = DBConnection("../data_base/test_base.db") det = DataMatrixDetector(db) det.set_template("../data_matrixes/template.jpg") self.assertGreater(len(det.contours),0)