def __init__(
            self,
            session_dir: str,
            input_data_head_path=Path('/Volumes/WD'),
            results_head_path=Path('.') / 'data/calibration_data',
            cache_dir_path=Path('/Volumes/WD/image_cache'),
            num_points=1,
    ):
        self._session_dir = session_dir
        self._input_data_head_path = input_data_head_path
        self._results_head_path = results_head_path
        self._cache_dir_path = cache_dir_path
        self._num_points = num_points

        # Helpers
        self._ldfh = LDFH(self._input_data_head_path)
        self._calibration_data_filer = CalibrationDataFiler(
            self._results_head_path)

        self.maxima_text_color = 'red'
        self.minima_text_color = 'green'
        self.fontsize = 8

        # Lazy initializers
        self._pan_motor_read_data_series = None
        self._base_time_series = None
        self._motor_maxima = None
        self._motor_minima = None
        self._motor_maxima_from_series = None
        self._motor_minima_from_series = None
        self._motor_maxima_from_archive = None
        self._motor_minima_from_archive = None
        self._archived_results = None
        self._selected_frames_from_archive = None

        # State
        self._base_time = None
        self._motor_idx = None
        self._min_or_max = None
        self._alignment_results = []
    def __init__(self,
                 session_dir: str,
                 input_data_head_path=Path('/Volumes/WD'),
                 results_head_path=Path('.')  / 'data/calibration_data',
                 cache_dir_path=Path('/Volumes/WD/image_cache'),
                ):
        self._session_dir = session_dir
        self._input_data_head_path = input_data_head_path
        self._results_head_path = results_head_path
        self._cache_dir_path = cache_dir_path

        # helpers
        self._ldfh = LDFH(self._input_data_head_path)
        self._calibration_data_filer = CalibrationDataFiler(self._results_head_path)

        # state
        self._alignment_data = []

        # lazy inits
        self._latitude_series = None
        self._longitude_series = None
        self._time_series = None
    def __init__(
            self,
            session_dir: str,
            input_data_head_path=Path('/Volumes/WD'),
            results_head_path=Path('.') / 'data/calibration_data',
            cache_dir_path=Path('/Volumes/WD/image_cache'),
    ):
        self._session_dir = session_dir
        self._input_data_head_path = input_data_head_path
        self._results_head_path = results_head_path
        self._cache_dir_path = cache_dir_path

        # settings
        self._anotation_color = 'green'
        self._anotation_fontsize = '8'

        self._ldfh = LDFH(self._input_data_head_path)
        self._calibration_data_filer = CalibrationDataFiler(
            self._results_head_path)

        # lazy inits
        self._fov_time_series = None
        self._fov_data_series = None
        self._unique_fovs = None
        self._transition_indexes = None
        self._transition_levels = None
        self._unique_transitions = None

        # state
        self._alignment_results = {}
        self._current_transition = None
        self._alignment_stats_delays = []
        self._alignment_stats_durations = []
        self._alignment_stats_zoom_out_delays = []
        self._alignment_stats_zoom_out_durations = []
        self._alignment_stats_zoom_in_delays = []
        self._alignment_stats_zoom_in_durations = []
Esempio n. 4
0
 def setUp(self):
     self.ldfh = LDFH(self.__class__.HEAD_PATH)
 def setUp(self):
     self.ldfh = LDFH(self.__class__.HEAD_PATH)
     self.fovta = FovTimebaseAligner(self.__class__.TEST_SESSION_DIR_NAME)
    def setUp(self):
        head_path = Path('/Volumes/WD')
        session_dir = 'Aug_17_Palo_Alto_High_2nd_time_B80_ottofillmore'

        ldfh = LDFH(head_path)

        tag_latitude_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.TAG_LATITUDE_FIELD,
        )
        tag_longitude_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.TAG_LONGITUDE_FIELD,
        )
        self.tag_time_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.TAG_TIME_FIELD,
        )

        self.geo_map_scrubber = GeoMapScrubber(
            latitude_series=tag_latitude_series,
            longitude_series=tag_longitude_series,
            time_series=self.tag_time_series,
        )

        tag = Tag(
            latitude_series=tag_latitude_series,
            longitude_series=tag_longitude_series,
            time_series=self.tag_time_series,
            map_coordinate_transformer=self.geo_map_scrubber.
            _get_map_coordinate_transformer(),
        )

        self.base_latitude_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.BASE_LATITUDE_FIELD,
        )
        self.base_longitude_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.BASE_LONGITUDE_FIELD,
        )

        reported_base = Base(
            gps_latitude_series=self.base_latitude_series,
            gps_longitude_series=self.base_longitude_series,
            map_coordinate_transformer=self.geo_map_scrubber.
            _get_map_coordinate_transformer(),
        )

        # Base position we believe to be correct based on where we believe we set up
        # the base on the field. Point picked on map using GeoMapScrubber
        # x: 132 y: 612 latitude: 37.38639419602273 longitude: -122.11008779357967
        actual_base_latitude_series = np.full(self.base_latitude_series.size,
                                              37.38639419602273)
        actual_base_longitude_series = np.full(self.base_longitude_series.size,
                                               -122.11008779357967)

        actual_base = Base(
            gps_latitude_series=actual_base_latitude_series,
            gps_longitude_series=actual_base_longitude_series,
            map_coordinate_transformer=self.geo_map_scrubber.
            _get_map_coordinate_transformer(),
        )

        fov_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.LENS_NPZ_FILE,
            fieldname=LDFH.LENS_FOV_FIELD,
        )
        fov_time_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.LENS_NPZ_FILE,
            fieldname=LDFH.LENS_TIME_FIELD,
        )

        self.tag_position_analyzer_with_actual_base = TagPositionInStableFovSegmentsAnalyzer(
            fov_series=fov_series,
            fov_time_series=fov_time_series,
            tag=tag,
            base=actual_base,
        )

        self.tag_position_analyzer_with_reported_base = TagPositionInStableFovSegmentsAnalyzer(
            fov_series=fov_series,
            fov_time_series=fov_time_series,
            tag=tag,
            base=reported_base,
        )

        return self
Esempio n. 7
0
    def setUp(self):
        head_path = Path('/Volumes/WD')
        session_dir = 'Aug_17_Palo_Alto_High_2nd_time_B80_ottofillmore'
        results_head_path = Path('.')  / 'data/calibration_data',

        ldfh = LDFH(
            head_path=head_path,
        )
        cdf = CDF(
            top_level_dir=results_head_path
        )

        fov_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.LENS_NPZ_FILE,
            fieldname=LDFH.LENS_FOV_FIELD,
        )
        fov_time_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.LENS_NPZ_FILE,
            fieldname=LDFH.LENS_TIME_FIELD,
        )
        tag_latitude_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.TAG_LATITUDE_FIELD,
        )
        tag_longitude_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.TAG_LONGITUDE_FIELD,
        )
        tag_time_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.TAG_TIME_FIELD,
        )

        self.geo_map_scrubber = GeoMapScrubber(
            latitude_series=tag_latitude_series,
            longitude_series=tag_longitude_series,
            time_series=tag_time_series,
        )

        self.video_path = ldfh.get_video_path(session_dir)

        map_fitter = MapFitter(
            latitude_series=tag_latitude_series,
            longitude_series=tag_longitude_series,
        )

        map_coordinate_transformer = MapCoordinateTransformer.init_with_map_fitter(
            map_fitter=map_fitter,
        )

        tag = Tag(
            latitude_series=tag_latitude_series,
            longitude_series=tag_longitude_series,
            time_series=tag_time_series,
            alignment_offset_video_to_tag_ms=-340, # From calibration data
            map_coordinate_transformer=map_coordinate_transformer,
        )

        base_gps_latitude = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.BASE_LATITUDE_FIELD,
        )
        base_gps_longitude = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.TAG_NPZ_FILE,
            fieldname=LDFH.BASE_LONGITUDE_FIELD,
        )
        base_motor_time_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.BASE_NPZ_FILE,
            fieldname=LDFH.BASE_TIME_FIELD,
        )

        pan_motor_angle_series = ldfh.get_field_from_npz_file(
            session_dir_name=session_dir,
            filename=LDFH.BASE_NPZ_FILE,
            fieldname=LDFH.PAN_MOTOR_READ_FIELD,
        )

        self.base = Base(
            gps_latitude_series=base_gps_latitude,
            gps_longitude_series=base_gps_longitude,
            base_motor_time_series=base_motor_time_series,
            map_coordinate_transformer=map_coordinate_transformer,
            pan_motor_angle_series=pan_motor_angle_series,
            actual_latitude=37.386206696022725,
            actual_longitude=-122.11009181597608,
            # actual_latitude=37.386203,
            # actual_longitude=-122.110091,
        )

        self.tag_position_analyzer = TagPositionInStableFovSegmentsAnalyzer(
            fov_series=fov_series,
            fov_time_series=fov_time_series,
            tag=tag,
            base=self.base,
        )

        self.frames_limit = 1
        self.threshold_deg = 20
        self.min_distance_to_camera = 100
        # self.frames_limit = None
        # self.threshold_deg = 20
        # self.min_distance_to_camera = 100
        self.legacy_data_base_position_calibrator = LegacyDataBasePositionCalibrator(
            session_dir=session_dir,
            tag_position_in_stable_fov_segments_analyzer=self.tag_position_analyzer,
            legacy_data_file_system_helper=ldfh,
            calibration_data_filer=cdf,
            frames_limit=self.frames_limit,
            angle_threshold_rad=np.radians(self.threshold_deg),
            min_distance_to_camera=self.min_distance_to_camera,
        )

        return self
Esempio n. 8
0
 def setUp(self):
     self.ldfh = LDFH(self.__class__.HEAD_PATH)
     self.pmta = PanMotorTimeBaseAligner(
         self.__class__.TEST_SESSION_DIR_NAME, num_points=10)