Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import struct
- class DataInputStream:
- def __init__(self, stream):
- self.stream = stream
- def read_boolean(self):
- return struct.unpack('?', self.stream.read(1))[0]
- def read_byte(self):
- return struct.unpack('b', self.stream.read(1))[0]
- def read_unsigned_byte(self):
- return struct.unpack('B', self.stream.read(1))[0]
- def read_char(self):
- return chr(struct.unpack('>H', self.stream.read(2))[0])
- def read_double(self):
- return struct.unpack('>d', self.stream.read(8))[0]
- def read_float(self):
- return struct.unpack('>f', self.stream.read(4))[0]
- def read_short(self):
- return struct.unpack('>h', self.stream.read(2))[0]
- def read_unsigned_short(self):
- return struct.unpack('>H', self.stream.read(2))[0]
- def read_long(self):
- return struct.unpack('>q', self.stream.read(8))[0]
- def read_utf(self):
- utf_length = struct.unpack('>H', self.stream.read(2))[0]
- return self.stream.read(utf_length)
- def read_int(self):
- return struct.unpack('>i', self.stream.read(4))[0]
- #data = data_preparation_TIPA_protocol('../../../Downloads/data1.dat',320,240)
- # width x height
- #print(np.shape((data.thermal_matrix)))
- matrix = None
- #import csv
- with open('../../../Downloads/data.csv', 'rb') as bfile:
- dis = DataInputStream(bfile)
- row_count = dis.read_int()
- matrix = np.empty([640, 480, row_count])
- f = 0
- for f in range(0,row_count):
- print("Processed Frame: "+str(f))
- for i in range(0,640):
- for j in range(0,480):
- val = dis.read_double()
- #print(val)
- matrix[i][j][f] = val
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement