Пример #1
0
def main():
    scans = glob(opt.scans_path + "/*")
    for scan in scans:
        scenename = scan.split("/")[-1]
        filename = os.path.join(scan, scenename + ".sens")
        if not os.path.exists(opt.output_path):
            os.makedirs(opt.output_path)
            os.makedirs(os.path.join(opt.output_path, 'depth'))
            os.makedirs(os.path.join(opt.output_path, 'color'))
            os.makedirs(os.path.join(opt.output_path, 'pose'))
            os.makedirs(os.path.join(opt.output_path, 'intrinsic'))
            # load the data
        sys.stdout.write('loading %s...' % filename)
        sd = SensorData(filename)
        sys.stdout.write('loaded!\n')
        if opt.export_depth_images:
            sd.export_depth_images(
                os.path.join(opt.output_path, 'depth', scenename))
        if opt.export_color_images:
            sd.export_color_images(
                os.path.join(opt.output_path, 'color', scenename))
        if opt.export_poses:
            sd.export_poses(os.path.join(opt.output_path, 'pose', scenename))
        if opt.export_intrinsics:
            sd.export_intrinsics(
                os.path.join(opt.output_path, 'intrinsic', scenename))
 def __init__(self, name):
     Thread.__init__(self)
     self.enableAdaptor = True
     self.connector = SmtpClientConnector()
     self.sensorData = SensorData()
     self.actuator = ActuatorData("AC/Humidifier")
     self.data = DataUtil()
Пример #3
0
class AirQSensorAdaptor(Thread):
    '''
    Initiating the thread for the Adaptor 
    creating the sensor data object and initial values to use inside Adaptor
    '''
    def __init__(self, name):
        Thread.__init__(self)
        self.enableAdaptor = True
        self.sensorData = SensorData(name)
        self.actuator = ActuatorData("AC/Humidifier")
        self.connector = SmtpClientConnector()

    '''
    This thread gets the current temperature from SenseHat.
    Publishes the values as a message to the gateway device
    '''

    def run(self):
        while True:
            if self.enableAdaptor:
                sleep(1)
                self.sensorData.updateValue()
                data = DataUtil()
                jsonData = data.sensorTojson(self.sensorData)
                #Print sensor information
                print('\n--------------------')
                print('New sensor readings for publishing:')
                print(' ' + str(self.sensorData))
                pubclient = MqttClientConnector()
                pubclient.publish(host, "airqm", jsonData)
            sleep(60)
Пример #4
0
def update_matrix():

    temp_data = SensorData()

    sensor_temp_outside = temp_data.temp_outside()
    rain_probability = RainData().rain_probability()
    sensor_temp_inside = temp_data.temp_inside()

    update_list = {
        1: ('Grüne Matrix', matrix_green, 'sensor_temp_outside', sensor_temp_outside),
        2: ('Orange Matrix', matrix_orange, 'rain_probability', rain_probability),
        3: ('Rote Matrix', matrix_red, 'sensor_temp_inside', sensor_temp_inside)
    }

    try:

        for matrix, value in update_list.items():

            value[1].clear()
            value[1].display_16x8_buffer(value[3])
            value[1].write_display()

            log_string('{} updated mit {} - {}'.format(value[0], value[2], value[3]))

            blink('red')
            time.sleep(0.25)

    except IOError:

        log_string('Matrix Error')

        return
Пример #5
0
async def data_handler(data):
    logger = logging.getLogger(__name__)
    # Get that data into an object
    data_object = SensorData()
    try:
        data_object.ParseFromString(data)
        logger.info(json.dumps(data_object.asDict()), extra={'data': True})
    except DecodeError:
        logger.info("Received non-protobuf encoded message (probably an advertisement)")
Пример #6
0
def main():
  if not os.path.exists(opt.output_path):
    os.makedirs(opt.output_path)
  # load the data
  sys.stdout.write('loading %s...' % opt.filename)
  sd = SensorData(opt.filename)
  sys.stdout.write('loaded!\n')
  if opt.export_depth_images:
    sd.export_depth_images(os.path.join(opt.output_path, 'depth'))
  if opt.export_color_images:
    sd.export_color_images(os.path.join(opt.output_path, 'color'))
  if opt.export_poses:
    sd.export_poses(os.path.join(opt.output_path, 'pose'))
  if opt.export_intrinsics:
    sd.export_intrinsics(os.path.join(opt.output_path, 'intrinsic'))
Пример #7
0
def processSensorData(data):
    #this functions processeses the data recieved from client
    #mnumber += 1
    #print("message number is : " + str(mnumber))
    jsonLog = {}
    jsonLog['mydata'] = []

    sensor = SensorData()
    print('Ip Address ::' + ':'.join('{:02X}'.format(a) for a in data[:8]))
    sensor.parseSensorData(data, 8)
    print(sensor.printSensorData())
    jsonLog['mydata'].append({
        'timestamp': str(datetime.datetime.now()),
        'temperature': temp,
        'pressure': press,
        'humidity': humidity,
        'acc_x': acc_x,
        'acc_y': acc_y,
        'acc_z': acc_z
    })
    #add this packet data to /tmp/data.txt file which is a json file
    with open('/tmp/data.txt', 'a') as outfile:
        json.dump(jsonLog, outfile)

    fo.seek(0, 0)  # set file pointer to zero to read from first position
    readVal = fo.read(2)  # read first two bytes
    if readVal == "OK":
        print('read OK')
        fo.seek(0, 0)  # set file pointer to zero
        # write all data to buffer file where it can be picked by the GUI
        fo.write(str(sensor.temperature))
        fo.write("\n")
        fo.write(str(sensor.pressure))
        fo.write("\n")
        fo.write(str(sensor.humidity))
        fo.write("\n")
        fo.write(str(sensor.acc_x))
        fo.write("\n")
        fo.write(str(sensor.acc_y))
        fo.write("\n")
        fo.write(str(sensor.acc_z))
        fo.write("\n")  # write all sensor value

#    /* SUBODH: My entry point */
# I am commenting the Cloud up load for now. Lets make it configurable from
# GUI in future
#    uploadData(sensor.acc_x, sensor.acc_y, sensor.acc_z, sensor.pressure, sensor.temperature, sensor.humidity)
    time.sleep(3)
Пример #8
0
def parseMessage(inputString):
	# Split the string in parts into a list
	splitUp = re.split(',', inputString)
	length = len(splitUp)

	# Create a sensor data object from the message 
	if splitUp[0] == 'se' and length == 5:
		try:
			se = SensorData(splitUp[1], splitUp[2], splitUp[3], splitUp[4])
			return se			
		
		except IndexError:
			print "Invalid strategy instruction format, instruction not created" 

	# Create a gps object from the message 
	elif splitUp[0] == 'gp' and length == 5:
		try:
			gp = GPS(splitUp[1], splitUp[2], splitUp[3], splitUp[4])
			return gp			
		
		except IndexError:
			print "Invalid strategy instruction format, instruction not created" 

	else:
		print('Invalid message input')
Пример #9
0
    def process(self, data):
        # avoid processing empty data
        if not data:
            # self.log.error('Ignoring empty data processing')
            return

        # self.log.debug('Processing {data}'.format(data=data))

        tokens = data.split(DELIMITER)
        sensor_data = SensorData(tokens)

        # if file not created then create it.
        # Stop gap fix for date & time not set in Atheros
        # Sync the time between Atheros and ATMega
        # UPODXX... xx has to be replaced with POD serial number
        if not self._file:
            dt = float(tokens[DATE_TIME])
            # sychronize Atheros system clock with ATMega
            self.sync_datetime(dt)
            #filename = datetime.fromtimestamp(dt).strftime('UPODXX%d%m%y.txt')
            filename = tokens[0] + '.txt'
            # self.log.info('Created file: {name}'.format(name=filename))
            self._file = TxtWriter(filename)  # RotatingTxtWriter(filename)

        # pprint(vars(sensor_data))
        # pprint(vars(sensor_data.GpsData))
        # print data
        #status = False
        #while not status:
        status = self._file.write(sensor_data)
Пример #10
0
    def fetchData(self, time):
        if debugging: print "SensorPacket.fetchData.flag0"
        try:
            if debugging: print "SensorPacket.fetchData.flag1"
            if int(self.ser.in_waiting) > 0:
                incoming = self.ser.readline().strip().rsplit(",")
                if incoming == None:
                    print "Incoming is Null"
                self.ser.reset_input_buffer()

                print incoming
                #print "Length:" + str(len(incoming))

                self.tim = time

                if debugging: print "SensorPacket.fetchData.flag2"
                if len(incoming) == 4:
                    #print "SensorPacket.fetchData.flag3"
                    self.rpm = int(incoming[0])
                    self.throttle = int(incoming[1])
                    self.current = float(incoming[2])
                    self.voltage = float(incoming[3])
                    return SensorData(
                        '0', 'all',
                        [self.rpm, self.throttle, self.current, self.voltage],
                        self.tim)

            return

        except IndexError:
            print "Wrong sensor data received, nothing sent"

        except ValueError:
            print "Wrong sensor data received, could not cast to int"
Пример #11
0
 def get_sensor_data(self):
     # Sensor data is being printed as
     # ADDR HUM TEMP HEAT_INDEX - separated with tab
     self.ser.write(PI_COMMANDS['GET_DATA'])
     time.sleep(3)
     sensor_raw_data = self.ser.readline().decode().strip()
     sensor_data = SensorData('{}'.format(sensor_raw_data))
     return sensor_data
Пример #12
0
def main():
    if not os.path.exists(opt.output_path):
        os.makedirs(opt.output_path)
    # load the data
    sys.stdout.write('loading %s...' % opt.filename)
    sd = SensorData(opt.filename)
    sys.stdout.write('loaded!\n')
    name = os.path.splitext(os.path.basename(opt.filename))[0]
    if opt.export_depth_images:
        sd.export_depth_images(os.path.join(opt.output_path, 'depth'))
    if opt.export_color_images:
        # sd.export_color_images(os.path.join(opt.output_path, name), image_size=(130, 95), frame_skip=1)
        sd.export_color_images(os.path.join(opt.output_path, name),
                               frame_skip=1)
    if opt.export_poses:
        sd.export_poses(os.path.join(opt.output_path, 'pose'))
    if opt.export_intrinsics:
        sd.export_intrinsics(os.path.join(opt.output_path, 'intrinsic'))
 def getData(self):
     try:
         data = int(self.arduino.readline())
         time = dt.datetime.now().strftime('%H:%M:%S.%f')
         return SensorData(data, time)
     except KeyboardInterrupt:
         sys.exit()
     except:
         print("Can not convert data!")
         return None
Пример #14
0
def reader(filename,
           output_path,
           export_depth_images=False,
           export_color_images=False,
           export_poses=False,
           export_intrinsics=False):
    if not os.path.exists(output_path):
        os.makedirs(output_path)
    # Load sensor data
    print 'Loading {0}...'.format(filename)
    sd = SensorData(filename)
    print 'done. '

    # Load each component
    if export_depth_images:
        sd.export_depth_images(os.path.join(output_path, 'depth'))
    if export_color_images:
        sd.export_color_images(os.path.join(output_path, 'color'))
    if export_poses:
        sd.export_poses(os.path.join(output_path, 'pose'))
    if export_intrinsics:
        sd.export_intrinsics(os.path.join(output_path, 'intrinsic'))


# def main():
#   if not os.path.exists(opt.output_path):
#     os.makedirs(opt.output_path)
#   # load the data
#   sys.stdout.write('loading %s...' % opt.filename)
#   sd = SensorData(opt.filename)
#   sys.stdout.write('loaded!\n')
#   if opt.export_depth_images:
#     sd.export_depth_images(os.path.join(opt.output_path, 'depth'))
#   if opt.export_color_images:
#     sd.export_color_images(os.path.join(opt.output_path, 'color'))
#   if opt.export_poses:
#     sd.export_poses(os.path.join(opt.output_path, 'pose'))
#   if opt.export_intrinsics:
#     sd.export_intrinsics(os.path.join(opt.output_path, 'intrinsic'))

# if __name__ == '__main__':
#     main()
 def jsonTosensor(self,jsonData):
     sensedataDict = json.loads(jsonData)
     sensedata = SensorData()
     sensedata.name = sensedataDict['name']
     sensedata.timeStamp = sensedataDict['timeStamp']
     sensedata.temperature = sensedataDict['temperature']
     sensedata.pressure = sensedataDict['pressure']
     sensedata.humidity = sensedataDict['humidity']
     return sensedata
Пример #16
0
    def getThrottledata(self, time):
        try:
            while (self.ser.in_waiting):
                incoming = self.ser.readline().rstrip()
                self.throttle = int(incoming)
                #print "throttle: " + incoming
                self.tim = time

            return SensorData('1', 'throttle', self.throttle, self.tim)

        except IndexError:
            print "Wrong current value, nothing sent"
Пример #17
0
def main():
    if not os.path.exists(opt.root):
        stdout("{} not exist, exit\n".format(opt.root))
        return
    root = opt.root
    fileNames = os.listdir(root)
    fileNames = [name for name in fileNames if name.find('scene') > -1]
    stdout("Found {} scenes in {}\n".format(len(fileNames), root))
    sort_nicely(fileNames)

    for i, filename in enumerate(fileNames):
        if i < opt.index:
            continue
        stdout("process {}th sense\n".format(i))
        # set output path
        output_path = os.path.join(root, filename)
        stdout("output path is {}\n".format(output_path))

        # filename renamed, load the data
        filename = os.path.join(root, filename, filename + '.sens')
        stdout("loading {} ... \n".format(filename))

        sd = SensorData(filename)
        stdout('loaded!\n')

        if opt.export_depth_images:
            sd.export_depth_images(os.path.join(output_path, 'depth'))
            stdout("depth read\t")
        if opt.export_color_images:
            sd.export_color_images(os.path.join(output_path, 'color'))
            stdout("color readed\t")
        if opt.export_poses:
            sd.export_poses(os.path.join(output_path, 'pose'))
            stdout("pose readed\t")
        if opt.export_intrinsics:
            sd.export_intrinsics(os.path.join(output_path, 'intrinsic'))
            stdout("intrinsic readed\t")

        stdout('\n')
Пример #18
0
def main():
    if not os.path.exists(opt.output_path):
        os.makedirs(opt.output_path)

    label_mapping = None
    if opt.export_label_images:
        label_map = util.read_label_mapping(opt.label_map_file, label_from='id', label_to='nyu40id')

    scenes = [d for d in os.listdir(opt.scannet_path) if os.path.isdir(os.path.join(opt.scannet_path, d))]
    print('Found %d scenes' % len(scenes))
    for i in range(len(scenes)):
        sens_file = os.path.join(opt.scannet_path, scenes[i], scenes[i] + '.sens')
        label_path = os.path.join(opt.scannet_path, scenes[i], opt.label_type)
        if opt.export_label_images and not os.path.isdir(label_path):
            print_error('Error: using export_label_images option but label path %s does not exist' % label_path)
        output_color_path = os.path.join(opt.output_path, scenes[i], 'color')
        if not os.path.isdir(output_color_path):
            os.makedirs(output_color_path)
        output_depth_path = os.path.join(opt.output_path, scenes[i], 'depth')
        if not os.path.isdir(output_depth_path):
            os.makedirs(output_depth_path)
        output_pose_path = os.path.join(opt.output_path, scenes[i], 'pose')
        if not os.path.isdir(output_pose_path):
            os.makedirs(output_pose_path)
        output_label_path = os.path.join(opt.output_path, scenes[i], 'label')
        if opt.export_label_images and not os.path.isdir(output_label_path):
            os.makedirs(output_label_path)

        # read and export
        sys.stdout.write('\r[ %d | %d ] %s\tloading...' % ((i + 1), len(scenes), scenes[i]))
        sys.stdout.flush()
        sd = SensorData(sens_file)
        sys.stdout.write('\r[ %d | %d ] %s\texporting...' % ((i + 1), len(scenes), scenes[i]))
        sys.stdout.flush()
        sd.export_color_images(output_color_path, image_size=[opt.output_image_height, opt.output_image_width], frame_skip=opt.frame_skip)
        sd.export_depth_images(output_depth_path, image_size=[opt.output_image_height, opt.output_image_width], frame_skip=opt.frame_skip)
        sd.export_poses(output_pose_path, frame_skip=opt.frame_skip)

        if opt.export_label_images:
            for f in range(0, len(sd.frames), opt.frame_skip):
                label_file = os.path.join(label_path, str(f) + '.png')
                image = np.array(imageio.imread(label_file))
                image = sktf.resize(image, [opt.output_image_height, opt.output_image_width], order=0, preserve_range=True)
                mapped_image = map_label_image(image, label_map)
                imageio.imwrite(os.path.join(output_label_path, str(f) + '.png'), mapped_image)
    print('')
Пример #19
0
def update_matrix():

    temp_data = SensorData()

    sensor_temp_outside = temp_data.temp_outside()
    rain_probability = RainData().rain_probability()
    sensor_temp_inside = temp_data.temp_inside()

    update_list = {
        1: ('Grüne Matrix', matrix_green, 'sensor_temp_outside',
            sensor_temp_outside),
        2:
        ('Orange Matrix', matrix_orange, 'rain_probability', rain_probability),
        3:
        ('Rote Matrix', matrix_red, 'sensor_temp_inside', sensor_temp_inside)
    }

    try:

        for matrix, value in update_list.items():

            value[1].clear()
            value[1].display_16x8_buffer(value[3])
            value[1].write_display()

            log_string('{} updated mit {} - {}'.format(value[0], value[2],
                                                       value[3]))

            blink('red')
            time.sleep(0.25)

    except IOError:

        log_string('Matrix Error')

        return
def preprocess_data(foldername):
    print(foldername)
    os.makedirs(os.path.join('data/imgs', foldername), exist_ok=True)
    os.makedirs(os.path.join('data/depths', foldername), exist_ok=True)
    os.makedirs(os.path.join('data/masks', foldername), exist_ok=True)
    os.makedirs(os.path.join('data/poses', foldername), exist_ok=True)
    os.makedirs(os.path.join('data/intrinsics', foldername), exist_ok=True)

    st = time.time()
    sd = SensorData(
        os.path.join(root_data_dir, foldername, '{}.sens'.format(foldername)))
    sd_loading_time = time.time() - st
    sd.export_poses(os.path.join('data/poses', foldername), FRAMESKIP)
    sd.export_intrinsics(os.path.join('data/intrinsics', foldername))

    st = time.time()
    frame_indices = list(range(0, len(sd.frames), FRAMESKIP))
    sd.extract_color_depth_data(frame_indices, FRAMESKIP)
    color_depth_extract_time = time.time() - st

    zip_path = os.path.join(root_data_dir, foldername,
                            '{}_2d-label-filt.zip'.format(foldername))
    st = time.time()
    filepaths = []
    with ZipFile(zip_path) as zf:
        for filepath in zf.namelist():
            if os.path.splitext(filepath)[1] != '.png':
                continue
            filename = os.path.basename(filepath)
            fileidx = int(os.path.splitext(filename)[0])
            if fileidx % FRAMESKIP != 0:
                continue
            filepaths.append('{} {} {}'.format(zip_path, foldername, filepath))
    with ProcessPoolExecutor(max_workers=POOL_NUM_WORKERS) as processpool:
        processpool.map(extract_mask_data, filepaths)
    mask_extract_time = time.time() - st

    print(foldername, sd_loading_time, color_depth_extract_time,
          mask_extract_time)
Пример #21
0
    def testAddPower1(self):
        # Open connection with the database
        db = MySQLdb.connect("localhost", "root", "reverse", "ecoData")
        cursor = db.cursor()

        # Add a information to the database
        dr = SensorData("1", "throttle", 7, "123.456.789")
        addToDatabase(dr)

        # Get information from the database
        cursor.execute("SELECT * FROM Throttle")
        result = cursor.fetchone()
        dbId = result[0]
        dbType = result[1]
        dbData = result[2]
        dbTimestamp = result[3]

        # Close the connection and wipe the database
        db.close()
        cleardb()

        self.assertTrue(dbId == 1 and dbType == "throttle" and dbData == "7"
                        and dbTimestamp == "123.456.789")
Пример #22
0
    def fetchData(self, time):
        try:
            print "SensorPacket.fetchData.flag1"
            #print self.ser.is_open
            if self.ser.in_waiting > 0:
                incoming = self.ser.readline().strip().rsplit(",")
                print incoming
                #print "Length:" + str(len(incoming))

                self.tim = time

                #				print "SensorPacket.fetchData.flag2"
                if len(incoming) == 4:
                    #					print "SensorPacket.fetchData.flag3"
                    self.rpm = int(incoming[0])
                    self.throttle = int(incoming[1])
                    self.current = float(incoming[2])
                    self.voltage = float(incoming[3])
                    return SensorData(
                        '0', 'all',
                        [self.rpm, self.throttle, self.current, self.voltage],
                        self.tim)

#			print "SensorPacket.fetchData.flag4: No data received."
            return

        except IndexError:
            print "Wrong sensor data received, nothing sent"

        except ValueError:
            print "Wrong sensor data received, could not cast to int"

        except:
            e = sys.exc_info()[0]
            print "Something went wrong."
            print "Error: " + str(e)
def process(scene_name):
    out_path_cur = os.path.join(path_out, scene_name)
    if not os.path.exists(out_path_cur):
        os.makedirs(out_path_cur)

    # load mesh
    mesh = trimesh.load(os.path.join(path_in, scene_name,
                                     scene_name + '_vh_clean.ply'),
                        process=False)
    txt_file = os.path.join(path_in, scene_name, '%s.txt' % scene_name)
    mesh, align_mat = align_axis(txt_file, mesh)
    mesh, scale_mat = scale_to_unit_cube(mesh)
    scale_matrix = np.linalg.inv(scale_mat @ align_mat)

    file_cur = os.path.join(path_in, scene_name, scene_name + '.sens')
    sd = SensorData(file_cur)
    sd.export_depth_images(os.path.join(path_out, scene_name, 'depth'),
                           frame_skip=1)
    sd.process_camera_dict(join(path_out, scene_name), scale_matrix)
    pcl = sample_points(mesh)
    out_file = join(path_out, scene_name, 'pointcloud.npz')
    np.savez(out_file, **pcl)
Пример #24
0
 def getThrottledata(self):
     return SensorData('2', 'throttle', self.throttle, self.tim)
Пример #25
0
 def getRPMdata(self):
     return SensorData('1', 'rpm', self.rpm, self.tim)
def export(scene):
    sens_file = os.path.join(opt.scannet_path, scene, scene + '.sens')
    if not os.path.isfile(sens_file):
        print_error('Error: sens path %s does not exist' % sens_file)

    output_scene_path = os.path.join(opt.scannet_path, scene)
    print(output_scene_path, sens_file)
    ''' pose and color '''
    output_pose_path = os.path.join(opt.scannet_path, scene, 'pose')
    if not os.path.isdir(output_pose_path):
        os.makedirs(output_pose_path)
    output_color_path = os.path.join(opt.scannet_path, scene, 'color')
    if not os.path.isdir(output_color_path):
        os.makedirs(output_color_path)
    ''' depth '''
    if opt.export_depth_images:
        output_depth_path = os.path.join(opt.scannet_path, scene, 'depth')
        if not os.path.isdir(output_depth_path):
            os.makedirs(output_depth_path)
    ''' label '''
    label_path = os.path.join(opt.scannet_path, scene, opt.label_type)
    if opt.export_label_images and not os.path.isdir(label_path):
        print_error(
            'Error: using export_label_images option but label path %s does not exist'
            % label_path)
    if opt.export_label_images:
        output_label_path = os.path.join(opt.scannet_path, scene,
                                         'mapped_' + opt.label_type)
        if opt.export_label_images and not os.path.isdir(output_label_path):
            os.makedirs(output_label_path)

    ## read and export
    #sys.stdout.write('\r[ %d | %d ] %s\tloading...' % ((i + 1), len(scenes), scenes[i]))
    #sys.stdout.flush()
    sd = SensorData(sens_file)
    #sys.stdout.write('\r[ %d | %d ] %s\texporting...' % ((i + 1), len(scenes), scenes[i]))
    #sys.stdout.flush()

    sd.export_intrinsics(output_scene_path)
    sd.export_poses(output_pose_path, frame_skip=opt.frame_skip)
    sd.export_color_images(
        output_color_path,
        image_size=[opt.output_image_height, opt.output_image_width],
        frame_skip=opt.frame_skip)
    if opt.export_depth_images:
        sd.export_depth_images(
            output_depth_path,
            image_size=[opt.output_image_height, opt.output_image_width],
            frame_skip=opt.frame_skip)

    if opt.export_label_images:
        for f in range(0, len(sd.frames), opt.frame_skip):
            label_file = os.path.join(label_path, str(f) + '.png')
            image = np.array(imageio.imread(label_file))
            image = sktf.resize(
                image, [opt.output_image_height, opt.output_image_width],
                order=0,
                preserve_range=True,
                mode='constant')
            mapped_image = map_label_image(image, label_map)
            #print(np.min(mapped_image), np.max(mapped_image))
            imageio.imwrite(os.path.join(output_label_path,
                                         str(f) + '.png'), mapped_image)
Пример #27
0
 def testToString(self):
     self.assertEquals(
         SensorData("1", "power", 5, "123.456").toString(),
         "SensorId: 1, MessageType: power, Data: 5, timestamp: 123.456")
Пример #28
0
 def testGetTimeStamp(self):
     self.assertEquals(
         SensorData("1", "power", 5, "123.456").getTimestamp(), "123.456")
Пример #29
0
 def testGetData(self):
     self.assertEquals(SensorData("1", "power", 5, "123.456").getData(), 5)
Пример #30
0
 def getCurrentdata(self):
     return SensorData('3', 'current', self.current, self.tim)
Пример #31
0
 def getVoltagedata(self):
     return SensorData('4', 'votlage', self.voltage, self.tim)
Пример #32
0
 def testCorrectSensor(self):
     sen = SensorData(1, "power", 2, 3)
     self.assertEqual(writeMessage(sen), "se,1,power,2,3")