def test2(self):
     camera = Camera(90, 4, 6, 0, 135)
     solution = CameraAngleSolution(camera, self.grid)
     solution.calculate()
     array = np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0],
                       [1, 1, 0, 0, 0], [1, 1, 1, 0, 0]],
                      dtype=bool)
     np.testing.assert_equal(array, solution.grid.seen)
コード例 #2
0
    def __init__(self,
                 camera_positions,
                 max_distance,
                 angle_of_view,
                 field_len_x,
                 field_len_y,
                 field_origin_x,
                 field_origin_y,
                 points_on_grid=1000):
        """

        :param camera_positions:
        :param max_distance:
        :param angle_of_view:
        :param field_len_x:
        :param field_len_y:
        :param field_origin_x:
        :param field_origin_y:
        :param points_on_grid:
        """
        self.max_distance = max_distance
        self.angle_of_view = angle_of_view
        self.field_len_x = field_len_x
        self.field_len_y = field_len_y
        self.field_origin_x = field_origin_x
        self.field_origin_y = field_origin_y

        # initialize grid
        m = math.sqrt(points_on_grid / ((field_len_x + 1) * (field_len_y + 1)))
        self._grid_start_x = field_origin_x
        self._grid_end_x = field_origin_x + field_len_x
        self._grid_start_y = field_origin_y
        self._grid_end_y = field_origin_y + field_len_y
        self._grid_count_x = math.ceil((field_len_x + 1) * m)
        self._grid_count_y = math.ceil((field_len_y + 1) * m)

        # initialize cameras
        self.cameras = []
        for camera_position in camera_positions:
            self.cameras.append(
                Camera(angle_of_view, max_distance, float(camera_position[0]),
                       float(camera_position[1]), 0))
        self.camera_solutions = []
        self.best_camera_solutions = []
        self.solutions = []
コード例 #3
0
    def __init__(self,
                 cameras,
                 max_distance,
                 angle_of_view,
                 field_len_x,
                 field_len_y,
                 field_origin_x,
                 field_origin_y,
                 points_on_grid=10000):
        """

        :param list cameras:         A list of cameras. Each camera is defined by a dict with entries
                                     "x", "y" and "alignment_angle"
        :param float max_distance:   The maximum distance an object can be apart from the camera
        :param float angle_of_view:  The maximum angle of view of a camera
        :param float field_len_x:    The length in x direction of the observing field
        :param float field_len_y:    The length in y direction of the observing field
        :param float field_origin_x: The smallest x coordinate of the observing field
        :param float field_origin_y: The smallest y coordinate of the observing field
        :param int points_on_grid:   Number of points on the grid
        """
        # initialize cameras
        self.angle_of_view = angle_of_view
        self.max_distance = max_distance
        self.cameras = []
        for camera in cameras:
            test_camera_format(camera)
            self.cameras.append(
                Camera(angle_of_view, max_distance, float(camera["x"]),
                       float(camera["y"]), float(camera["alignment_angle"])))
        # initialize grid
        m = math.sqrt(points_on_grid / ((field_len_x + 1) * (field_len_y + 1)))
        self._grid_start_x = field_origin_x
        self._grid_end_x = field_origin_x + field_len_x
        self._grid_start_y = field_origin_y
        self._grid_end_y = field_origin_y + field_len_y
        self._grid_count_x = math.ceil((field_len_x + 1) * m)
        self._grid_count_y = math.ceil((field_len_y + 1) * m)
        self.grid = FieldGrid(self._grid_start_x, self._grid_end_x,
                              self._grid_start_y, self._grid_end_y,
                              self._grid_count_x, self._grid_count_y)
        self.camera_solutions = {}
コード例 #4
0
 def add_camera(self, angle_of_view, max_distance, x, y, direction):
     self.cameras.append(
         Camera(angle_of_view, max_distance * self.scale, x * self.scale,
                y * self.scale, direction))
コード例 #5
0
 def setUp(self):
     self.camera = Camera(90, 4, 10, 10, 45)
コード例 #6
0
 def setUp(self):
     self.camera = Camera(71, 18.75, 10, 0, 90)
コード例 #7
0
 def setUp(self):
     self.camera = Camera(90, 4, 6, 0, 135)
 def setUp(self):
     grid = CameraGrid(1, 5, 1, 5, 5, 5)
     camera = Camera(90, 4, 0, 0, 45)
     self.solution = CameraAngleSolution(camera, grid)
     self.solution.calculate()
 def setUp(self):
     grid = CameraGrid(1, 6, 1, 7, 6, 7)
     camera = Camera(math.degrees(2 * math.asin(3 / 5)), 5, 0, 4, 0)
     self.solution = CameraAngleSolution(camera, grid)
     self.solution.calculate()