def setUp(self):
        self.num_timestamps = 10
        self.fov = math.pi / 2
        self.image_width = 1000
        self.object_universe = ObjectUniverse(
            num_timestamps=self.num_timestamps)
        self.camera = Camera()

        self.camera.set_actual_position((1,1)).\
                    set_fov_rad(self.fov).\
                    set_num_timestamps(self.num_timestamps).\
                    set_range(50000)

        for timestamp in range(self.camera.get_num_timestamps()):
            self.camera.set_state_of_pan_motor_angle_at_timestamp_rad(
                math.pi / 4, timestamp)

        self.cv = ComputerVision()
        self.image_generator = ImageGenerator(image_width=self.image_width)
        self.camera.set_computer_vision(self.cv).\
                    set_image_generator(self.image_generator)

        self.viewable_objects = [
            StationaryObject((2, 1 + math.tan(math.pi / 8))),
            StationaryObject((1 + math.tan(math.pi / 8), 2)),
            StationaryObject((10000, 1.1)),
            StationaryObject((1.1, 10000)),
        ]
        self.object_universe.add_viewable_objects(self.viewable_objects)
        self.object_universe.add_camera(self.camera)

        self.d = self.image_width / (2 * math.tan(self.fov / 2))
        self.theta = math.pi / 8
 def setUp(self):
     self.initial_num_timestamps = 100
     self.boundary = Boundary([(0, 0), (100, 0), (100, 100), (0, 100)])
     self.moving_object = RandomlyMovingObject(
         self.boundary, num_timestamps=self.initial_num_timestamps)
     self.stationary_object = StationaryObject(
         (100, 100), num_timestamps=self.initial_num_timestamps)
     self.viewable_objects = [self.moving_object, self.stationary_object]
     self.object_universe = ObjectUniverse()
Esempio n. 3
0
    def setUp(self):
        self.num_timestamps = 7
        self.fov_deg = 92
        self.fov_rad = math.radians(self.fov_deg)
        self.object_universe = ObjectUniverse(
            num_timestamps=self.num_timestamps)

        self.camera = Camera()
        self.camera.set_fov_deg(self.fov_deg).set_actual_position((0, 0))
        for timestamp in range(self.num_timestamps):
            self.camera.set_state_of_pan_motor_angle_at_timestamp(0, timestamp)

        self.viewable_object = ViewableObject()

        self.object_universe.add_camera(self.camera).\
                             add_viewable_objects(self.viewable_object)

        self.angles = [
            -math.pi / 4,
            -math.pi / 8,
            math.pi / 8,
            math.pi / 4,
        ]

        self.image_width = self.camera.get_image_generator().get_image_width()
        self.d = self.image_width / 2 / math.tan(self.fov_rad / 2)

        self.x_s = [self.d * math.tan(a) for a in self.angles]

        self.positions = [(self.d, x) for x in self.x_s]

        self.sequence = [0, 1, 0, 2, 3, 2, 1]

        for timestamp, s in enumerate(self.sequence):
            self.viewable_object.set_position_at_timestamp(
                self.positions[s], timestamp)

        self.subtended_angles = [
            math.pi / 8,
            -math.pi / 8,
            3 * math.pi / 8,
            math.pi / 8,
            -math.pi / 8,
            -math.pi / 4,
        ]

        self.image_analyzer = ImageAnalyzer(self.camera)
        self.image_analyzer.set_images(self.camera.get_image_generator(
        ).get_x_for_all_inview_objects_for_all_camera_time())
    def setUp(self):
        self.num_timestamps = 6
        self.object_universe = ObjectUniverse(num_timestamps=self.num_timestamps)
        self.camera = Camera(fov_deg=90, actual_position=(0,0))
        self.cv = ComputerVision()
        self.camera.set_computer_vision(self.cv)
        self.object_universe.add_camera(self.camera)

        for timestamp, _ in enumerate(self.camera.get_state_history()):
            self.camera.set_pan_angle_deg(0, timestamp)

        self.out_pos = (1,2)
        self.in_pos = (1,0)

        self.out_obj = ViewableObject()
        self.in_obj = ViewableObject()
        self.in_out_in_obj = ViewableObject()
        self.out_in_out_obj = ViewableObject()

        self.viewable_objects = [
            self.out_obj,
            self.in_obj,
            self.in_out_in_obj,
            self.out_in_out_obj,
        ]

        self.object_universe.add_viewable_objects(self.viewable_objects)

        for timestamp, _ in enumerate(self.out_obj.position_history):
            self.in_obj.set_position_at_timestamp(self.in_pos, timestamp)
            self.out_obj.set_position_at_timestamp(self.out_pos, timestamp)

        for timestamp in [0,1]:
            self.in_out_in_obj.set_position_at_timestamp(self.in_pos, timestamp)
            self.out_in_out_obj.set_position_at_timestamp(self.out_pos, timestamp)

        for timestamp in [2,3]:
            self.in_out_in_obj.set_position_at_timestamp(self.out_pos, timestamp)
            self.out_in_out_obj.set_position_at_timestamp(self.in_pos, timestamp)

        for timestamp in [4,5]:
            self.in_out_in_obj.set_position_at_timestamp(self.in_pos, timestamp)
            self.out_in_out_obj.set_position_at_timestamp(self.out_pos, timestamp)

        self.cv.set_cv_ids_for_all_camera_time()
Esempio n. 5
0
    def setUp(self):
        self.num_timestamps = 100
        self.object_universe = ObjectUniverse(num_timestamps=self.num_timestamps)
        self.camera = Camera(fov_deg=90, actual_position=(0,0))

        self.in_view_positions = [(1,0), (2,1), (2,-1)]
        self.out_view_positions = [(-1,0), (1,2), (1,-2)]
        self.in_view_objects  = list(map(
            lambda pos: StationaryObject(pos, name='in_view'),
            self.in_view_positions)
        )
        self.out_view_objects = list(map(
            lambda pos: StationaryObject(pos, name='out_view'),
            self.out_view_positions)
        )

        self.object_universe.clear_viewable_objects().add_viewable_objects(self.in_view_objects + self.out_view_objects)
        self.object_universe.add_camera(self.camera)
    def setUp(self, num_randomly_moving_objects=10):
        self.num_randomly_moving_objects = num_randomly_moving_objects

        self.num_timestamps = 60
        self.tag_gps_angle_threshold = math.radians(7)

        self.object_universe = ObjectUniverse(
            num_timestamps=self.num_timestamps)

        self.camera = Camera()
        self.camera.set_actual_position((100, 400)).\
                    set_gps_position((100,380)).\
                    set_gps_max_error(25).\
                    set_fov_rad(math.pi/2)

        self.boundary = Boundary([(220, 300), (420, 100), (420, 700),
                                  (220, 500)])

        self.tag = RandomlyMovingTag(boundary=self.boundary)
        self.viewable_objects = [self.tag]

        for _ in range(self.num_randomly_moving_objects):
            self.viewable_objects.append(
                RandomlyMovingObject(boundary=self.boundary))

        self.object_universe.add_camera(self.camera).\
                             add_viewable_objects(self.viewable_objects)

        for timestamp in range(self.num_timestamps):
            self.camera.set_state_of_pan_motor_angle_at_timestamp(0, timestamp)

        self.camera.get_computer_vision().set_cv_ids_for_all_camera_time()

        self.object_motion_analyzer = ObjectMotionAnalyzer(
            self.camera,
            self.tag,
            tag_gps_angle_threshold=self.tag_gps_angle_threshold)

        self.frames = self.object_motion_analyzer.get_complete_frames()

        return self
Esempio n. 7
0
    def __init__(self):

        # Setup physical environment
        self.num_timestamps = 100

        self.camera = Camera()
        self.camera.set_actual_position((100,300)).\
                    set_gps_position((100,290)).\
                    set_gps_max_error(10).\
                    set_fov_deg(70)
        for timestamp in range(self.num_timestamps):
            self.camera.set_pan_angle_deg(0, timestamp)

        self.cv = ComputerVision()
        self.camera.set_computer_vision(self.cv)

        self.boundary = Boundary([(150, 100), (150, 550), (300, 550),
                                  (300, 100)])

        self.viewable_objects = []
        for _ in range(20):
            self.viewable_objects.append(
                RandomlyMovingObject(boundary=self.boundary))

        self.object_universe = ObjectUniverse(
            num_timestamps=self.num_timestamps)
        self.object_universe.add_camera(self.camera).\
                             add_viewable_objects(self.viewable_objects)

        self.cv.set_cv_ids_for_all_camera_time()

        # Rendering
        renderable_objects = [
            self.boundary,
            self.object_universe,
        ]

        RenderOrchestrator(self.num_timestamps,
                           seconds_per_timestamp=0.2,
                           renderable_objects=renderable_objects).run()
Esempio n. 8
0
    def setUp(self, num_randomly_moving_objects=0):

        self.num_randomly_moving_objects = num_randomly_moving_objects

        self.num_timestamps = 100
        self.object_universe = ObjectUniverse(
            num_timestamps=self.num_timestamps)

        self.camera = Camera()
        self.camera.set_fov_rad(math.pi / 2).\
                    set_actual_position((100,400)).\
                    set_gps_position((100,410)).\
                    set_gps_max_error(12).\
                    set_num_timestamps(self.num_timestamps)
        for timestamp in range(self.num_timestamps):
            self.camera.set_state_of_pan_motor_angle_at_timestamp(0, timestamp)

        self.viewable_objects = []
        for y in range(100, 800, 50):
            self.viewable_objects.append(StationaryObject((301, y)))

        self.boundary = Boundary([(200, 200), (400, 200), (400, 600),
                                  (200, 600)])
        for _ in range(self.num_randomly_moving_objects):
            self.viewable_objects.append(
                RandomlyMovingObject(boundary=self.boundary))

        self.viewable_objects.append(RandomlyMovingTag(boundary=self.boundary))

        self.object_universe.add_camera(self.camera).\
                             add_viewable_objects(self.viewable_objects)

        self.camera.get_computer_vision().set_cv_ids_for_all_camera_time()

        self.image_renderer = ImageRenderer(self.camera.get_image_generator())
        self.image_renderer.set_computer_vision(
            self.camera.get_computer_vision())

        return self
    def setUp(self):
        self.num_timestamps = 2
        self.fov = math.pi / 2
        self.object_universe = ObjectUniverse(
            num_timestamps=self.num_timestamps)

        self.camera = Camera()

        self.camera.set_fov_rad(math.pi / 2).\
                    set_actual_position((100,400)).\
                    set_gps_position((100,410)).\
                    set_gps_max_error(12).\
                    set_num_timestamps(self.num_timestamps)

        for timestamp in range(self.num_timestamps):
            self.camera.set_state_of_pan_motor_angle_at_timestamp(0, timestamp)

        self.viewable_objects = [
            StationaryObject((300, 599)),
            StationaryObject((300, 201)),
        ]
        self.object_universe.add_viewable_objects(self.viewable_objects)
        self.object_universe.add_camera(self.camera)
    def setUp(self, tag_gps_angle_threshold=6, compass_err_deg=3.7):
        self.tag_gps_angle_threshold = tag_gps_angle_threshold
        self.compass_err_deg = compass_err_deg

        self.num_timestamps = 50
        self.tag_gps_angle_threshold = math.radians(self.tag_gps_angle_threshold)

        self.object_universe = ObjectUniverse(num_timestamps=self.num_timestamps)

        self.camera = Camera()
        self.camera.set_actual_position((100, 400)).\
                    set_gps_position((100,380)).\
                    set_gps_max_error(25).\
                    set_fov_rad(math.pi/2).\
                    set_compass_error_rad(math.radians(self.compass_err_deg))

        self.boundary = Boundary([(220,300), (420,100), (420,700), (220, 500)])

        self.tag = RandomlyMovingTag(boundary=self.boundary)
        self.viewable_objects = [self.tag]

        self.object_universe.add_camera(self.camera).\
                             add_viewable_objects(self.viewable_objects)

        for timestamp in range(self.num_timestamps):
            self.camera.set_state_of_pan_motor_angle_at_timestamp(0, timestamp)

        self.camera.get_computer_vision().set_cv_ids_for_all_camera_time()

        self.base_position_calibrator = BasePositionCalibrator(self.camera,
                                                               self.tag,
                                                               tag_gps_angle_threshold=self.tag_gps_angle_threshold)


        self.base_angle_calibrator = BaseAngleCalibrator(self.base_position_calibrator)

        return self
Esempio n. 11
0
 def test_stationary_object_updates_its_num_timestamps_to_match_object_universe_it_gets_added_to(self):
     ou = ObjectUniverse(num_timestamps=200)
     ou.add_viewable_objects(self.so)
     self.assertEqual(self.so.get_position_history_len(), 200)
     for timestamp in range(0, 200):
         self.assertEqual(self.so.get_position_at_timestamp(timestamp), self.pos)