def dr_data(self) -> IotNvpSeq:
     data = IotNvpSeq()
     data.append(IotNvp('engine_id', self.__engine_id))
     data.append(IotNvp('frame_id', self.__frame_id))
     data.append(IotNvp('model_id', self.__model_id))
     value = IotValue()
     value.nvp_seq = self.__data
     data.append(IotNvp('classification_data', value))
     return data
Beispiel #2
0
 def dr_data(self) -> IotNvpSeq:
     data = IotNvpSeq()
     data.append(IotNvp('engine_id', self.__engine_id))
     data.append(IotNvp('stream_id', self.__stream_id))
     data.append(IotNvp('frame_id', self.__frame_id))
     dbox_value = IotValue()
     dbox_value.nvp_seq = self.__data
     data.append(IotNvp('data', dbox_value))
     return data
Beispiel #3
0
    def __init__(self, engine_id='', stream_id='', frame_id=0):
        self.__engine_id = IotValue()
        self.__stream_id = IotValue()
        self.__frame_id = IotValue()
        self.__data = IotNvpSeq()

        self.engine_id = engine_id
        self.stream_id = stream_id
        self.frame_id = frame_id
Beispiel #4
0
 def __init__(self,
              obj_id=0,
              obj_label='',
              class_id=0,
              class_label='',
              x=0.0,
              y=0.0,
              radius=0.0,
              probability=0.0,
              meta=''):
     self._obj_id = IotValue()
     self._obj_label = IotValue()
     self._class_id = IotValue()
     self._class_label = IotValue()
     self._x = IotValue()
     self._y = IotValue()
     self._radius = IotValue()
     self._probability = IotValue()
     self._meta = IotValue()
     self.obj_id = obj_id
     self.obj_label = obj_label
     self.class_id = class_id
     self.class_label = class_label
     self.x = x
     self.y = y
     self.radius = radius
     self.probability = probability
     self.meta = meta
Beispiel #5
0
    def write_sample(self, temperature):
        temperature_v = IotValue()
        temperature_v.float32 = temperature

        sensor_data = IotNvpSeq()
        sensor_data.append(IotNvp('temperature', temperature_v))

        try:
            self._thing.write('temperature', sensor_data)
        except RuntimeError as e:
            print('Error writing data: ' + str(e))
    def __init__(self,
                 engine_id: str = '',
                 model_id: str = '',
                 frame_id: int = 0):
        self.__engine_id = IotValue()
        self.__frame_id = IotValue()
        self.__model_id = IotValue()
        self.__data = IotNvpSeq()

        self.engine_id = engine_id
        self.model_id = model_id
        self.frame_id = frame_id
Beispiel #7
0
    def init_payload(self, video):
        payload = IotValue()
        payload.byte_seq = []
        #payload.byte_seq.append(video)
        #payload.byte_seq = video

        for i in video:
            #for j in i:
            #for k in j:
            payload.byte_seq.append(int(i))

        #print(len(video))
        self._send_payload = IotNvpSeq()
        self._send_payload.append(IotNvp('video', payload))
Beispiel #8
0
 def add_data(self, value: PyDetectionBoxData):
     seq = value.dr_data
     value = IotValue()
     value.nvp_seq = seq
     it = IotNvp()
     it.value = value
     self.__data.push_back(it)
    def write_distance(self, my_location_flow_id, distance, eta, timestamp):
        dist_v = IotValue()
        dist_v.float64 = distance
        eta_v = IotValue()
        eta_v.float32 = eta
        timestamp_v = IotValue()
        timestamp_v.uint64 = timestamp

        distance_data = IotNvpSeq()
        distance_data.append(IotNvp('distance', dist_v))
        distance_data.append(IotNvp('eta', eta_v))
        distance_data.append(IotNvp('timestampUtc', timestamp_v))

        # Write distance to DataRiver using flow ID from incoming location sample
        self._thing.write('distance', my_location_flow_id, distance_data)
Beispiel #10
0
    def __init__(self,
                 obj_id=0,
                 obj_label='',
                 class_id=0,
                 class_label='',
                 x1=0.0,
                 y1=0.0,
                 x2=0.0,
                 y2=0.0,
                 probability=0.0,
                 meta='',
                 dist_x=0.0,
                 dist_y=0.0,
                 dist_z=0.0):
        super().__init__(obj_id, obj_label, class_id, class_label, x1, y1, x2,
                         y2, probability, meta)
        self.__dist_x = IotValue()
        self.__dist_y = IotValue()
        self.__dist_z = IotValue()

        self.dist_x = dist_x
        self.dist_y = dist_y
        self.dist_z = dist_z
Beispiel #11
0
 def dr_data(self):
     data = IotNvpSeq()
     data.append(IotNvp('engine_id', self._engine_id))
     data.append(IotNvp('stream_id', self._stream_id))
     data.append(IotNvp('frame_id', self._frame_id))
     nvp_seq = IotNvpSeq()
     for value in self._data:
         iot_value = IotValue()
         iot_value.nvp_seq = value.dr_data
         it = IotNvp()
         it.value = iot_value
         nvp_seq.push_back(it)
     seq_value = IotValue()
     seq_value.nvp_seq = nvp_seq
     data.append(IotNvp('data', seq_value))
     return data
    def __init__(self,
                 category_id: int = -1,
                 category_label='',
                 super_category_id: int = -1,
                 super_category_label='',
                 metadata: str = '',
                 probability: float = 0.0):
        self.__category_id = IotValue()
        self.__category_label = IotValue()
        self.__super_category_id = IotValue()
        self.__super_category_label = IotValue()
        self.__metadata = IotValue()
        self.__probability = IotValue()

        self.category_id = category_id
        self.category_label = category_label
        self.super_category_id = super_category_id
        self.super_category_label = super_category_label
        self.metadata = metadata
        self.probability = probability
Beispiel #13
0
    def write(self, burst_interval, burst_size, running_time, mode):
        try:
            burst_count = 0
            count = 0
            timed_out = False

            pub_start = current_time_milliseconds()
            burst_start = current_time_milliseconds()
            current_time = current_time_milliseconds()

            output_handler = self._thing.get_output_handler('ThroughputOutput')
            internal_sequencenumber_v = IotValue()

            if mode == WriterMode.OUTPUT_HANDLER_NOT_THREAD_SAFE:
                output_handler.non_reentrant_flow_id = self._thing.context_id
                internal_nvp_seq = output_handler.setup_non_reentrant_nvp_seq(
                    self._sample)

                internal_sequencenumber_nvp = internal_nvp_seq[0]
                internal_sequencenumber_v = internal_sequencenumber_nvp.value

            while not timed_out:
                # Write data until burst size has been reached
                if burst_count < burst_size:
                    burst_count += 1

                    if mode == WriterMode.OUTPUT_HANDLER:
                        # Fill the nvp_seq with updated sequencenr
                        self._sample[0].value.uint64 = count
                        count += 1

                        # Write the data using output handler
                        output_handler.write(self._sample)
                    elif mode == WriterMode.OUTPUT_HANDLER_NOT_THREAD_SAFE:
                        # Fill the nvp_seq with updated sequencenr
                        internal_sequencenumber_v.uint64 = count
                        count += 1

                        # Write the data using non-reentrant write on output handler
                        output_handler.write_non_reentrant()
                    else:
                        # Fill the nvp_seq with updated sequencenr
                        self._sample[0].value.uint64 = count
                        count += 1

                        # Write the data
                        self._thing.write('ThroughputOutput', self._sample)
                elif burst_interval != 0:
                    # Sleep until burst interval has passed
                    current_time = current_time_milliseconds()

                    delta_time = current_time - burst_start
                    if delta_time < burst_interval:
                        time.sleep(float(burst_interval - delta_time) / 1000.0)

                    burst_start = current_time_milliseconds()
                    burst_count = 0
                else:
                    burst_count = 0

                # Check of timeout
                if running_time != 0:
                    current_time = current_time_milliseconds()
                    if float(current_time - pub_start) / 1000.0 > running_time:
                        timed_out = True

            print('Timed out: {} samples written'.format(count))
        except KeyboardInterrupt:
            print('Terminated: {} samples written'.format(count))
            sys.exit(1)
Beispiel #14
0
    def __init__(self, stream_id='', mac_address='', ip_address='', port=0, uri='', manufacturer='ADLINK',
                 serial='v0.1', model='video-analytics-pipeline', fw_version='', dev_id='', status='DEVICE_STATUS_ONLINE', kind='DEVICE_KIND_UNKNOWN', protocol='INTERFACE_DDS'):
        self.__stream_id = IotValue()
        self.__mac_address = IotValue()
        self.__ip_address = IotValue()
        self.__port = IotValue()
        self.__uri = IotValue()
        self.__manufacturer = IotValue()
        self.__model = IotValue()
        self.__serial = IotValue()
        self.__fw_version = IotValue()
        self.__dev_id = IotValue()
        self.__status = IotValue()
        self.__kind = IotValue()
        self.__protocol = IotValue()

        self.stream_id = stream_id
        self.mac_address = mac_address
        self.ip_address = ip_address
        self.port = port
        self.uri = uri
        self.manufacturer = manufacturer
        self.model = model
        self.serial = serial
        self.fw_version = fw_version
        self.dev_id = dev_id
        self.status = status
        self.kind = kind
        self.protocol = protocol
Beispiel #15
0
 def write_sample(self, barcode, x, y, z):
     barcode_v = IotValue()
     barcode_v.string = barcode
     position_x_v = IotValue()
     position_x_v.int32 = x
     position_y_v = IotValue()
     position_y_v.int32 = y
     position_z_v = IotValue()
     position_z_v.int32 = z
     
     data = IotNvpSeq()
     data.append(IotNvp('barcode', barcode_v))
     data.append(IotNvp('position_x', position_x_v))
     data.append(IotNvp('position_y', position_y_v))
     data.append(IotNvp('position_z', position_z_v))
     
     self._thing.write('observation', self.get_flow_id(barcode), data)