def __init__(self, parent=None): super(FaceDection, self).__init__(parent) # gui connections self.ui = Ui_FaceDetection() self.ui.setupUi(self) self.ui.speed_dial.sliderMoved.connect(self.set_fan_speed) self.ui.horizontal_speed.sliderReleased.connect(self.horizontal_stop) self.ui.vertical_speed.sliderReleased.connect(self.vertical_stop) self.ui.horizontal_speed.valueChanged.connect(self.set_hor_speed) self.ui.vertical_speed.valueChanged.connect(self.set_ver_speed) self.ui.serial_select.currentIndexChanged.connect(self.port_select) self.ui.command_edit.returnPressed.connect(self.command_send) # video and face recognition self.faces = [] self.ui.video.face_callback = self.video_face_callback self.ui.video.image_callback = self.video_image_callback # serial connection self.serial = SerialConnection() for port in self.serial.list_ports(): self.ui.serial_select.addItem(port) self.listener_timer = QTimer(self) self.listener_timer.timeout.connect(self.serial_read) self.listener_timer.start(50)
def __init__(self): threading.Thread.__init__(self) self.SerialConnection = SerialConnection() self.WifiConnection = WifiConnection() self.BluetoothConnection = Bluetooth_Connection() self.WifiConnection.connect() self.wifiIsConnected = True self.BluetoothConnection.setupConnection() self.bluetoothIsConnected = True self.SerialConnection.connect() self.serialIsConnected = True
self.pan = msg.getRelativePan() self.tilt = msg.getRelativeTilt() # print("pan=" + str(self.pan) + ", tilt=" + str(self.tilt)) self.putMessage(msg) self.update() def update(self): with self.lock: if (self.timer is None): self.timer = threading.Timer(0.05, self.doCommunication) self.timer.start() def doCommunication(self): with self.lock: self.serialConnection.setPan(self.pan) self.serialConnection.setTilt(self.tilt) self.timer.cancel() self.timer = None if __name__ == "__main__": serialConnection = SerialConnection.SerialConnection() serialConnection.requestUserConnection() # cv = CurrentValue.CurrentValue() handler = MessageHandler(serialConnection) # app = defaultWebsocketApp.defaultWebsocketApp(handler.handleMessage) # app.start() lpc = longPollClient.longPollClient() while (True): point = lpc.getLatestPoint() handler.handleMessage(point)