def test_complete_should_be_false_if_all_sections_unhandled(self):
        sections = 200
        point_capture = PointCaptureXYZ(sections, self.img2point, self.laser_theta)
        for idx in range(sections - 2):
            point_capture.handle(laser_detection="BLA", section=idx, roi=self.roi)

        self.assertFalse(point_capture.complete)
Ejemplo n.º 2
0
    def test_handle_adds_to_existing_points(self):
        sections = 4
        frame = np.ones((200, 200), dtype='uint8')

        self.img2point = Mock()
        points = [
            np.array([[1.0, 1.0, 1.0]], dtype='float16'),
            np.array([[2.0, 2.0, 2.0]], dtype='float16')
        ]

        self.img2point.get_points.side_effect = points

        point_capture = PointCaptureXYZ(sections,
                                        self.img2point,
                                        self.laser_theta,
                                        points_xyz=np.array(
                                            [[-1.0, -1.0, -1.0],
                                             [-2.0, -2.0, -2.0]]))
        expected = np.array([[-1.0, -1.0, -1.0], [-2.0, -2.0, -2.0],
                             [1.0, 1.0, 1.0], [2.0, 2.0, 2.0]])

        point_capture.handle(laser_detection=frame, section=0, roi=self.roi)
        point_capture.handle(laser_detection=frame, section=1, roi=self.roi)

        actual = point_capture.points_xyz

        self.assertEquals(expected.shape, actual.shape)
        self.assertTrue((expected == actual).all())
    def test_handle_calls_img2points(self):
        sections = 200
        frame = np.ones((200,200), dtype='uint8')
        point_capture = PointCaptureXYZ(sections, self.img2point, self.laser_theta)

        point_capture.handle(laser_detection=frame, section=0, roi=self.roi)

        self.img2point.get_points.assert_called_with(frame, 0, self.roi, self.laser_theta)
    def test_status_should_return_amount_complete(self):
        sections = 10

        point_capture = PointCaptureXYZ(sections, self.img2point, self.laser_theta)
        for idx in range(sections):
            self.assertEquals(idx / float(sections), point_capture.status)
            point_capture.handle(laser_detection="BLA", section=idx, roi=self.roi)
        self.assertEquals(1.0, point_capture.status)
Ejemplo n.º 5
0
    def test_complete_should_be_false_if_all_sections_unhandled(self):
        sections = 200
        point_capture = PointCaptureXYZ(sections, self.img2point,
                                        self.laser_theta)
        for idx in range(sections - 2):
            point_capture.handle(laser_detection="BLA",
                                 section=idx,
                                 roi=self.roi)

        self.assertFalse(point_capture.complete)
Ejemplo n.º 6
0
    def test_handle_calls_img2points(self):
        sections = 200
        frame = np.ones((200, 200), dtype='uint8')
        point_capture = PointCaptureXYZ(sections, self.img2point,
                                        self.laser_theta)

        point_capture.handle(laser_detection=frame, section=0, roi=self.roi)

        self.img2point.get_points.assert_called_with(frame, 0, self.roi,
                                                     self.laser_theta)
    def test_handle_calls_img2points_with_correct_rad(self):
        sections = 200
        current_section = 50
        expected_rad = np.pi / 2.0
        frame = np.ones((200, 200), dtype='uint8')
        point_capture = PointCaptureXYZ(sections, self.img2point, self.laser_theta)

        point_capture.handle(laser_detection=frame, section=current_section, roi=self.roi)

        self.img2point.get_points.assert_called_with(frame, expected_rad, self.roi, self.laser_theta)
    def test_handle_stores_points(self):
        sections = 200
        frame = np.ones((200, 200), dtype='uint8')
        point_capture = PointCaptureXYZ(sections, self.img2point, self.laser_theta)
        expected = np.array([[1.0, 1.0, 1.0]])

        point_capture.handle(laser_detection=frame, section=0, roi=self.roi)

        actual = point_capture.points_xyz

        self.assertTrue((expected == actual).all())
Ejemplo n.º 9
0
    def test_status_should_return_amount_complete(self):
        sections = 10

        point_capture = PointCaptureXYZ(sections, self.img2point,
                                        self.laser_theta)
        for idx in range(sections):
            self.assertEquals(idx / float(sections), point_capture.status)
            point_capture.handle(laser_detection="BLA",
                                 section=idx,
                                 roi=self.roi)
        self.assertEquals(1.0, point_capture.status)
Ejemplo n.º 10
0
    def test_handle_stores_points(self):
        sections = 200
        frame = np.ones((200, 200), dtype='uint8')
        point_capture = PointCaptureXYZ(sections, self.img2point,
                                        self.laser_theta)
        expected = np.array([[1.0, 1.0, 1.0]])

        point_capture.handle(laser_detection=frame, section=0, roi=self.roi)

        actual = point_capture.points_xyz

        self.assertTrue((expected == actual).all())
Ejemplo n.º 11
0
    def test_handle_calls_img2points_with_correct_rad(self):
        sections = 200
        current_section = 50
        expected_rad = np.pi / 2.0
        frame = np.ones((200, 200), dtype='uint8')
        point_capture = PointCaptureXYZ(sections, self.img2point,
                                        self.laser_theta)

        point_capture.handle(laser_detection=frame,
                             section=current_section,
                             roi=self.roi)

        self.img2point.get_points.assert_called_with(frame, expected_rad,
                                                     self.roi,
                                                     self.laser_theta)
Ejemplo n.º 12
0
    def test_should_handle_all_sections_if_starting_at_not_0_index(self):
        sections = 200
        point_capture = PointCaptureXYZ(sections, self.img2point, self.laser_theta)
        for idx in range(sections):
            index = (idx + 50) % 200
            result = point_capture.handle(laser_detection="BLA", section=idx, roi=self.roi)

        self.assertFalse(result)
Ejemplo n.º 13
0
    def test_handle_stores_points_more_then_once(self):
        sections = 4
        frame = np.ones((200, 200), dtype='uint8')

        self.img2point = Mock()
        points = [np.array([[1.0, 1.0, 1.0]], dtype='float16'), np.array([[2.0, 2.0, 2.0]], dtype='float16')]

        self.img2point.get_points.side_effect = points

        point_capture = PointCaptureXYZ(sections, self.img2point, self.laser_theta)
        expected = np.array([[1.0, 1.0, 1.0], [2.0, 2.0, 2.0]])

        point_capture.handle(laser_detection=frame, section=0, roi=self.roi)
        point_capture.handle(laser_detection=frame, section=1, roi=self.roi)

        actual = point_capture.points_xyz

        self.assertTrue((expected == actual).all())
Ejemplo n.º 14
0
    def test_handle_adds_to_existing_points(self):
        sections = 4
        frame = np.ones((200, 200), dtype='uint8')

        self.img2point = Mock()
        points = [np.array([[1.0, 1.0, 1.0]], dtype='float16'), np.array([[2.0, 2.0, 2.0]], dtype='float16')]

        self.img2point.get_points.side_effect = points

        point_capture = PointCaptureXYZ(sections, self.img2point, self.laser_theta, points_xyz=np.array([[-1.0, -1.0, -1.0], [-2.0, -2.0, -2.0]]))
        expected = np.array([[-1.0, -1.0, -1.0], [-2.0, -2.0, -2.0], [1.0, 1.0, 1.0], [2.0, 2.0, 2.0]])

        point_capture.handle(laser_detection=frame, section=0, roi=self.roi)
        point_capture.handle(laser_detection=frame, section=1, roi=self.roi)

        actual = point_capture.points_xyz

        self.assertEquals(expected.shape, actual.shape)
        self.assertTrue((expected == actual).all())
Ejemplo n.º 15
0
    def test_should_handle_all_sections_if_starting_at_not_0_index(self):
        sections = 200
        point_capture = PointCaptureXYZ(sections, self.img2point,
                                        self.laser_theta)
        for idx in range(sections):
            index = (idx + 50) % 200
            result = point_capture.handle(laser_detection="BLA",
                                          section=idx,
                                          roi=self.roi)

        self.assertFalse(result)
Ejemplo n.º 16
0
    def test_handle_stores_points_more_then_once(self):
        sections = 4
        frame = np.ones((200, 200), dtype='uint8')

        self.img2point = Mock()
        points = [
            np.array([[1.0, 1.0, 1.0]], dtype='float16'),
            np.array([[2.0, 2.0, 2.0]], dtype='float16')
        ]

        self.img2point.get_points.side_effect = points

        point_capture = PointCaptureXYZ(sections, self.img2point,
                                        self.laser_theta)
        expected = np.array([[1.0, 1.0, 1.0], [2.0, 2.0, 2.0]])

        point_capture.handle(laser_detection=frame, section=0, roi=self.roi)
        point_capture.handle(laser_detection=frame, section=1, roi=self.roi)

        actual = point_capture.points_xyz

        self.assertTrue((expected == actual).all())
Ejemplo n.º 17
0
 def test_handle_ignores_extra_keywords(self):
     point_capture = PointCaptureXYZ(10, self.img2point, self.laser_theta)
     point_capture.handle(frame='pizza', laser_detection="BLA", section=0, roi=self.roi)
Ejemplo n.º 18
0
 def test_handle_ignores_extra_keywords(self):
     point_capture = PointCaptureXYZ(10, self.img2point, self.laser_theta)
     point_capture.handle(frame='pizza',
                          laser_detection="BLA",
                          section=0,
                          roi=self.roi)