class CoordinateReciverProtocol(Protocol): def __init__(self): self.frame_count = 0 self.calibrate = Calibrate(**camera) def connectionMade(self): self.transport.write("ACK") def dataReceived(self, data): """As soon as any data is received, write it back.""" # print("Received request from: {}", data) # print(json.loads(data)) self.frame_count += 1 if self.frame_count % 10 == 0: frame_positions = json.loads(data) abs_locations = [] for position in frame_positions: lat_lng = {'lat': position[0], 'lng': position[1]} abs_locations.append(self.calibrate.get_abs_position(lat_lng)) for client in websocket_clients: client.sendMessage(json.dumps(abs_locations))
def __init__(self): self.frame_count = 0 self.calibrate = Calibrate(**camera)