Example #1
0
    def get_detections_on_timestamp(self, timestamp):

        dset = ds.DetectionSet()

        frame = self.frames[timestamp.frame]
        data = convert_frame_to_numpy(frame)

        #print 'timestamp: ' + str(frame.timestamp)

        for detection_data in data:

            dset.add_detection(
                ds.Detection(
                    detection_data['idx'],
                    timestamp,
                    np.array([
                        detection_data['ypos'], detection_data['xpos']
                    ]),  # rotated, otherwise will be portrait orientation
                    detection_data['localizerSaliency'],
                    detection_data['decodedId']
                    [::-1],  # reversed, we want least significant bit last
                    detection_data['xRotation'],
                    detection_data['yRotation'],
                    detection_data['zRotation']))

        return dset
Example #2
0
    def get_detections_on_timestamp(self, timestamp):

        dset = ds.DetectionSet()

        self.cursor.execute("SELECT id, x, y, orientation from " +
                            timestamp.table + " WHERE timestamp = '" +
                            timestamp.key + "' AND \"camID\" = " +
                            str(timestamp.cam))
        detection_rows = self.cursor.fetchall()

        for d_row in detection_rows:
            self.cursor.execute(
                "SELECT id, \"beeID\", score, zrotation FROM " +
                timestamp.table + "b" + " WHERE id = " + str(d_row[0]))
            candidate_rows = self.cursor.fetchall()

            candidate_ids = []
            for c_row in candidate_rows:
                candidate_ids.append(
                    (c_row[1], c_row[2],
                     c_row[3]))  # list of tupels: (id,score,zrotation)

            # orientation is empty in our database, so we choose the zrotation of the first candidate_id instead
            zrotation = 0
            if len(candidate_ids) > 0:
                zrotation = candidate_ids[0][2]

            dset.add_detection(
                ds.Detection(
                    #d_row[0], timestamp, np.array( [d_row[1],d_row[2]] ), d_row[3], candidate_ids
                    d_row[0],
                    timestamp,
                    np.array([d_row[1], d_row[2]]),
                    zrotation,
                    candidate_ids))
        return dset
Example #3
0
    def load_data(self):

        if not os.path.exists(config.DATA_FOLDER):
            print 'Error: folder not found'
            return

        self.block_inputs(True)

        self.dset_store = ds.DetectionSetStore()
        self.path_manager = None
        self.paths_load_progress.setValue(0)
        self.paths_load_label.setText('')

        try:
            repo = Repository(config.DATA_FOLDER)
            start_time = datetime(config.DATE[0],
                                  config.DATE[1],
                                  config.DATE[2],
                                  config.TIME[0],
                                  config.TIME[1],
                                  tzinfo=pytz.utc)

            fnames = repo.iter_fnames(begin=start_time)
            for fname in fnames:

                frame_container = load_frame_container(fname)

                cam = frame_container.camId
                #frame_container.fromTimestamp              # already available
                #frame_container.toTimestamp                # already available

                self.dset_store.source = frame_container.dataSources[
                    0].filename

                previous_timestamp = None

                self.data_load_progress.setMaximum(config.FRAME_END + 1 -
                                                   config.FRAME_START)
                self.app.processEvents()

                frame_index = config.FRAME_START

                for frame in list(frame_container.frames
                                  )[config.FRAME_START:config.FRAME_END + 1]:

                    #timestamp = frame.timestamp  # not included yet
                    #frame.id                     # not included yet

                    timestamp = ds.TimeStamp(frame_index, cam)
                    timestamp.connect_with_previous(previous_timestamp)
                    previous_timestamp = timestamp

                    dset = ds.DetectionSet()
                    self.dset_store.store[timestamp] = dset

                    data = convert_frame_to_numpy(frame)

                    for detection_data in data:

                        dset.add_detection(
                            ds.Detection(
                                detection_data['idx'],
                                timestamp,
                                np.array(
                                    [
                                        detection_data['ypos'],
                                        detection_data['xpos']
                                    ]
                                ),  # rotated, otherwise will be portrait orientation
                                detection_data['localizerSaliency'],
                                detection_data['decodedId']
                                [::
                                 -1]  # reversed, we want least significant bit last
                            ))

                    frame_index += 1

                    self.data_load_progress.setValue(frame_index -
                                                     config.FRAME_START)
                    self.app.processEvents()

                self.data_load_label.setText(
                    str(len(self.dset_store.store)) + ' frames loaded')
                self.app.processEvents()

                # break because we only load the first fname
                break

        except:

            pass

        self.block_inputs(False)