Пример #1
0
    def _get_container(self):
        TIMESTAMP_IDX = 2
        self.frames.sort(key=lambda x: x[TIMESTAMP_IDX])
        start_ts = self.frames[0][TIMESTAMP_IDX]
        end_ts = self.frames[-1][TIMESTAMP_IDX]
        fc = FrameContainer.new_message(
            fromTimestamp=start_ts, toTimestamp=end_ts, camId=self.camId, id=unique_id()
        )
        dataSources = fc.init("dataSources", len(self.data_sources))
        for i, dsource in enumerate(self.data_sources):
            dataSources[i] = dsource
            dataSources[i].idx = int(i)

        frames = fc.init("frames", len(self.frames))
        for i, (data_source_idx, detection, timestamp) in enumerate(self.frames):
            frame = frames[i]
            frame.id = unique_id()
            frame.dataSourceIdx = data_source_idx
            frame.frameIdx = int(i)
            frame.timestamp = timestamp
            detections_builder = frame.init(
                "detectionsDP", len(detection.tag_positions)
            )
            for j, db in enumerate(detections_builder):
                db.idx = j
                db.xpos = int(detection.tag_positions[j, 1])
                db.ypos = int(detection.tag_positions[j, 0])
                db.zRotation = float(detection.orientations[j, 0])
                db.yRotation = float(detection.orientations[j, 1])
                db.xRotation = float(detection.orientations[j, 2])
                db.localizerSaliency = float(detection.tag_saliencies[j])
                decodedId = db.init("decodedId", len(detection.ids[j]))
                for k, bit in enumerate(detection.ids[j]):
                    decodedId[k] = int(round(255 * bit))

            detections_builder = frame.init(
                "detectionsBees", len(detection.bee_positions)
            )
            for j, db in enumerate(detections_builder):
                db.idx = j
                db.xpos = int(detection.bee_positions[j, 1])
                db.ypos = int(detection.bee_positions[j, 0])
                db.localizerSaliency = float(detection.bee_saliencies[j])
                db.type = self.label_map[detection.bee_types[j]]

        return fc
Пример #2
0
    def _get_container(self):
        TIMESTAMP_IDX = 2
        self.frames.sort(key=lambda x: x[TIMESTAMP_IDX])
        start_ts = self.frames[0][TIMESTAMP_IDX]
        end_ts = self.frames[-1][TIMESTAMP_IDX]
        fc = FrameContainer.new_message(fromTimestamp=start_ts,
                                        toTimestamp=end_ts,
                                        camId=self.camId,
                                        id=unique_id())
        dataSources = fc.init('dataSources', len(self.data_sources))
        for i, dsource in enumerate(self.data_sources):
            dataSources[i] = dsource
            dataSources[i].idx = int(i)

        frames = fc.init('frames', len(self.frames))
        for i, (data_source_idx, detection,
                timestamp) in enumerate(self.frames):
            frame = frames[i]
            frame.id = unique_id()
            frame.dataSourceIdx = data_source_idx
            frame.frameIdx = int(i)
            frame.timestamp = timestamp
            detections_builder = frame.detectionsUnion.init(
                'detectionsDP', len(detection.positions))
            for j, db in enumerate(detections_builder):
                db.idx = j
                db.xpos = int(detection.positions[j, 1])
                db.ypos = int(detection.positions[j, 0])
                db.xposHive = int(detection.hive_positions[j, 1])
                db.yposHive = int(detection.hive_positions[j, 0])
                db.zRotation = float(detection.orientations[j, 0])
                db.yRotation = float(detection.orientations[j, 1])
                db.xRotation = float(detection.orientations[j, 2])
                db.localizerSaliency = float(detection.saliencies[j, 0])
                db.radius = float(detection.radii[j])
                descriptor = db.init('descriptor',
                                     len(detection.descriptors[j]))
                for k, part in enumerate(detection.descriptors[j]):
                    descriptor[k] = int(part)
                decodedId = db.init('decodedId', len(detection.ids[j]))
                for k, bit in enumerate(detection.ids[j]):
                    decodedId[k] = int(round(255 * bit))

        return fc