def __init__(self): super(MainWindow,self).__init__() self.ui = loadUi(os.path.join(THIS_DIR, 'mainwindow.ui'), self) self.thread = QThread() try: self.camera = CameraDevice() except ValueError: self.ui.video.setText("Device not found!\n\nIs FFMPEG available?") else: self.camera.frame_ready.connect(self.update_video_label) self.ui.video.setMinimumSize(*self.camera.size) self.camera.moveToThread(self.thread)
def __init__(self): super(MainWindow, self).__init__() self.recognizer = Recognizer() self.recognizer.learn() self.ui = loadUi(os.path.join(THIS_DIR, 'mainwindow.ui'), self) self.thread = QThread() try: self.camera = CameraDevice() except ValueError: self.ui.video.setText("Device not found!\n\nIs FFMPEG available?") else: self.camera.frame_ready.connect(self.update_video_label) self.ui.video.setMinimumSize(640 * 2, 480) self.camera.moveToThread(self.thread) self.ui.t_max.setValue(0) self.ui.t_min.setValue(255) self.ui.s_max.setValue(200) self.ui.s_min.setValue(3) self.update_values()
class MainWindow(QMainWindow): def __init__(self): super().__init__() self.ui = loadUi(os.path.join(THIS_DIR, 'mainwindow.ui'), self) self.thread = QThread() try: self.camera = CameraDevice() except ValueError: self.ui.video.setText("Device not found!\n\nIs FFMPEG available?") else: self.camera.frame_ready.connect(self.update_video_label) self.ui.video.setMinimumSize(*self.camera.size) self.camera.moveToThread(self.thread) @pyqtSlot(QImage) def update_video_label(self, image): pixmap = QPixmap.fromImage(image) self.ui.video.setPixmap(pixmap) self.ui.video.update()
class MainWindow(QMainWindow): def __init__(self): super(MainWindow,self).__init__() self.ui = loadUi(os.path.join(THIS_DIR, 'mainwindow.ui'), self) self.thread = QThread() try: self.camera = CameraDevice() except ValueError: self.ui.video.setText("Device not found!\n\nIs FFMPEG available?") else: self.camera.frame_ready.connect(self.update_video_label) self.ui.video.setMinimumSize(*self.camera.size) self.camera.moveToThread(self.thread) @pyqtSlot() def start_recog(self): self.camera.set_recog(self.recognizer) @pyqtSlot() def stop_recog(self): self.camera.remove_recog() @pyqtSlot() def train_start(self): self.recognizer = FaceRec() self.recognizer.learn() @pyqtSlot() def make_data(self): name = str(self.ui.nameText.toPlainText()) if len(name) == 0: self.ui.nameText.setText("enter name!") return; print("train btn pushed.") train = FaceTrain(name) self.camera.set_train(train) @pyqtSlot(QImage) def update_video_label(self, image): pixmap = QPixmap.fromImage(image) self.ui.video.setPixmap(pixmap) self.ui.video.update()
app = web.Application(middlewares=auth) app.on_shutdown.append(on_shutdown) app.router.add_get('/', server.index) app.router.add_get('/favicon.png', server.favicon) app.router.add_get('/balena-logo.svg', server.balena_logo) app.router.add_get('/balena-cam.svg', server.balena) app.router.add_get('/client.js', server.javascript) app.router.add_get('/style.css', server.stylesheet) app.router.add_post('/offer', offer) app.router.add_get('/mjpeg', mjpeg_handler) app.router.add_get('/ice-config', config) web.run_app(app, access_log=None, port=80) pcs = set() # open media source if "CAMERA" in os.environ: checkDeviceReadiness() #Load Camera based on environment variable, default to /dev/video0 player = CameraDevice(int(os.getenv('CAMERA', 0))) else: player = CameraDevice("/usr/src/video/construction.mp4") # Factory to create peerConnections depending on the iceServers set by user pc_factory = PeerConnectionFactory() if __name__ == '__main__': main()
class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.ui = loadUi(os.path.join(THIS_DIR, 'mainwindow.ui'), self) self.thread = QThread() try: self.camera = CameraDevice() except ValueError: self.ui.video.setText("Device not found!\n\nIs FFMPEG available?") else: self.camera.frame_ready.connect(self.update_video_label) self.ui.video.setMinimumSize(640 * 2, 480) self.camera.moveToThread(self.thread) self.ui.t_max.setValue(0) self.ui.t_min.setValue(255) self.ui.s_max.setValue(200) self.ui.s_min.setValue(3) self.update_values() @pyqtSlot() def start_recog(self): if self.recognizer is not None: self.camera.set_recog(self.recognizer) else: print("plz do load recogi") @pyqtSlot() def stop_recog(self): self.camera.remove_recog() @pyqtSlot() def train_start(self): self.recognizer = DigitRecognizer() self.recognizer.learn() @pyqtSlot() def make_data(self): print("Not supported.") @pyqtSlot(int) def t_max_changed(self, val): if val < self.ui.t_min.value(): self.ui.t_min.setValue(val) self.update_values() @pyqtSlot(int) def t_min_changed(self, val): if val > self.ui.t_max.value(): self.ui.t_max.setValue(val) self.update_values() @pyqtSlot(int) def s_max_changed(self, val): if val < self.ui.s_min.value(): self.ui.s_min.setValue(val) self.update_values() @pyqtSlot(int) def s_min_changed(self, val): if val > self.ui.s_max.value(): self.ui.s_max.setValue(val) self.update_values() @pyqtSlot(QImage) def update_video_label(self, image): pixmap = QPixmap.fromImage(image) self.ui.video.setPixmap(pixmap) self.ui.video.update() def update_values(self): self.camera.set_values(self.ui.t_max.value(), self.ui.t_min.value(), self.ui.s_max.value(), self.ui.s_min.value())