Beispiel #1
0
def shot(w=224, h=224):
    cam = Camera()
    cam.resolution = (w, h)
    cam.vflip, cam.hflip = True, True
    try:
        cam.capture('./test.png', resize=(w, h))
        # cam.capture('./test.png')
    finally:
        cam.close()
    return send_file('./test.png')
Beispiel #2
0
class Window(QDialog):
    def __init__(self):
        super().__init__()
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        db = Database(host='localhost',
                      database='eardoor',
                      user='******',
                      password='******',
                      table='records')
        slm = QStringListModel()

        self.ui.records.setModel(slm)
        self.updater = Updater(self.ui, db, slm)

        self.camera = Camera(0, self.ui.camera.width(),
                             self.ui.camera.height())
        self.recognizer = Recognizer()

        self.fps = 50
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.update)
        self.timer.start(1000 // self.fps)

    def update(self):
        frame = self.camera.capture()
        name, frame = self.recognizer.detect(frame)
        self.updater.update(name, frame)