Esempio n. 1
0
 def discover_loop(self):
     self.splash.show()
     self.splash.ensure_first_paint()
     print(self.init_message)
     splash_thread = DiscoverThread(self)
     splash_thread.start()
     while splash_thread.isRunning():
         QThread.usleep(250)
         QApplication.processEvents()
     self.num_devices = len(self.devices)
     if self.num_devices == 0:
         self.splash.hide()
         print("No devices found")
         reply = QMessageBox.question(
             self,
             "catt-qt",
             "No devices found. Retry?",
             QMessageBox.Yes | QMessageBox.No,
             QMessageBox.Yes,
         )
         if reply == QMessageBox.Yes:
             self.discover_loop()
             return
         else:
             sys.exit(1)
Esempio n. 2
0
    def run(self):
        while True:
            status, frame = self.dev.read()
            if not status:
                self.dev.open("data/t.mp4")
                continue

            h, w, c = frame.shape
            data = frame.tobytes()
            self.sign_show.emit(h, w, c, data)
            QThread.usleep(100000)
Esempio n. 3
0
 def run(self):
     while not self.is_ok:
         # 采集视频
         status, frame = self.dev.read()
         if not status:
             self.is_ok = True
             continue
         # 发送信号
         h, w, c = frame.shape
         # 做登录检测,与验证,
         home_ok = False
         # frame = self.detector.detect_mark(frame)
         pred = self.detector.detect(frame)
         if pred is not None:
             # 循环处理识别结果
             for x1, y1, x2, y2, p, cls_id in pred:
                 # 概率过滤
                 if p > 0.2:
                     cls_id = int(cls_id)
                     name = self.detector.get_name(cls_id)
                     self.gestures.append(name)
                     self.counter += 1
                     # 实现标注
                     x1 = int(x1)
                     y1 = int(y1)
                     x2 = int(x2)
                     y2 = int(y2)
                     cv2.rectangle(frame,
                                   pt1=(x1, y1),
                                   pt2=(x2, y2),
                                   color=(0, 0, 255),
                                   thickness=4)
                     cv2.putText(frame,
                                 F"{name}:{p:.2f}",
                                 org=(x1, y1 - 50),
                                 fontFace=cv2.FONT_HERSHEY_SIMPLEX,
                                 fontScale=0.5,
                                 color=(0, 0, 255),
                                 thickness=1)
         if self.counter >= 1:
             # 验证/先取识别最多的人名
             most_name = max(self.gestures, key=self.gestures.count)
             # 调用业务模块,验证
             home_ok = self.dao.validate(most_name, self.num)
             self.counter = 0
             self.gestures = []
         frame = frame[:, :, ::-1]
         # frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
         self.signal_gesture.emit(h, w, c, frame.tobytes(), home_ok)
         if home_ok:
             QThread.sleep(1)
         QThread.usleep(10000)
Esempio n. 4
0
    def run(self):

        # 循环 逐帧捕获
        while True:
            # 拿到每一帧图片数据
            status, frame = self.dev.read()
            h, w, c = frame.shape

            #3 发送信号 传递数据
            self.sign_show.emit(h, w, c, frame.tobytes())

            # 等待 0.1秒  100000微妙
            QThread.usleep(100000)
Esempio n. 5
0
    def run(self):
        while True:
            status, frame = self.dev.read()
            if status:
                h, w, c = frame.shape
                # 做一个图像处理
                frame[100:200, :, 0] = 0
                frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

                self.signal_video.emit(h, w, c, frame.tobytes())
            else:
                print("设备故障!")
                break  # 结束线程
            QThread.usleep(100000)
 def run(self):
     for i in range(20):
         self.ok = False
         num = (int)(random() * 10)
         self.filename = lis[num]
         self.signal_num.emit(num)
         self.img = cv2.imread(self.filename)
         self.img = cv2.cvtColor(self.img, cv2.COLOR_BGR2RGB)
         h, w, c = self.img.shape
         self.signal_display.emit(h, w, c, self.img.tobytes())
         for i in range(80):
             if self.ok:
                 QThread.sleep(1)
                 break
             QThread.usleep(100000)
     self.signal_change.emit()
Esempio n. 7
0
 def run(self):
     """Collect bpm data, should work in rate logic"""
     x = []
     y = []
     i = 0
     test_x = TEST_X.pop(0)
     test_y = TEST_Y.pop(0)
     while i < self.readings:
         if DEBUG:
             x.append(test_x)
             y.append(test_y)
         else:
             x.append(self.bpm.x)
             y.append(self.bpm.y)
         i += 1
         QThread.usleep(SETTLE)
     self.signal.emit(np.mean(x), np.mean(y), 1.0, 1.0)
Esempio n. 8
0
    def run(self):
        # 循环 逐帧捕获数据
        while True:

            # 一帧数据
            status, frame = self.dev.read()
            # frame opencv numpy 数组
            # 数据处理
            h, w, c = frame.shape
            data = frame.tobytes()

            # 2、发送信号(真实数据)  触发信号
            self.sign_show.emit(h, w, c, data, self.th_id)

            #等待若干 时间 0.1秒
            # usleep(微妙) 1秒=1000000微妙
            QThread.usleep(100000)
Esempio n. 9
0
 def count_down(self, t):
     self.filename = dic[t]
     self.img = cv2.imread(self.filename)
     h, w, c = self.img.shape
     self.signal_judge.emit(h, w, c, self.img.tobytes())
     for i in range(10):
         QThread.usleep(100000)
         if self.ok:
             if t > 4:
                 self.filename = dic["perfect"]
                 self.signal_score.emit(5)
             else:
                 self.filename = dic["great"]
                 self.signal_score.emit(3)
             self.img = cv2.imread(self.filename)
             h, w, c = self.img.shape
             self.signal_judge.emit(h, w, c, self.img.tobytes())
             break
Esempio n. 10
0
 def run(self):
     while True:
         status, frame = self.dev.read()
         if status:
             h, w, c = frame.shape
             # 做一个图像处理
             # frame[100:200,:,0] = 0
             frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
             # 图像的特征处理
             # frame = cv2.GaussianBlur(frame, ksize=(11, 11), sigmaX=5)
             frame = cv2.Sobel(frame,
                               ddepth=-1,
                               dx=2,
                               dy=2,
                               ksize=5,
                               delta=80)
             self.signal_video.emit(h, w, c, frame.tobytes())
         else:
             print("设备故障!")
             break  # 结束线程
         QThread.usleep(100000)
Esempio n. 11
0
 def run(self):
     while not self.isOver:
         # 抓取视频
         status, img = self.dev.read()
         if not status:
             print("读取失败, 结束线程!")
             self.dev.release()
             self.exit(0)
             break
         # 发送图像到窗体显示
         if self.type == 0:
             self.sign_show.emit(img.shape[0], img.shape[1], img.shape[2],
                                 img.tobytes())
         elif self.type == 1:
             img = toGray(img)
             self.sign_show.emit(img.shape[0], img.shape[1], 1,
                                 img.tobytes())
         elif self.type == 2:
             img = toBorder(img)
             self.sign_show.emit(img.shape[0], img.shape[1], 1,
                                 img.tobytes())
         elif self.type == 3:
             img = toGauss(img)
             self.sign_show.emit(img.shape[0], img.shape[1], img.shape[2],
                                 img.tobytes())
         elif self.type == 4:
             img = toLaplace(img)
             self.sign_show.emit(img.shape[0], img.shape[1], img.shape[2],
                                 img.tobytes())
         elif self.type == 5:
             img = toConv(img)
             self.sign_show.emit(img.shape[0], img.shape[1], img.shape[2],
                                 img.tobytes())
         else:
             self.sign_show.emit(img.shape[0], img.shape[1], img.shape[2],
                                 img.tobytes())
         QThread.usleep(100000)
Esempio n. 12
0
    def run(self):
        print("starting countdown...")
        s = Timer.strToSec(self.window.timerEdit.text())
        t = s
        t2 = t

        self.continue_run = True
        start_time = datetime.now()
        while t != 0 and self.continue_run:
            if t != t2:
                print("timer still running...")
                t = t2
                mins, secs = divmod(t, 60)
                timeformat = '{:02d}:{:02d}'.format(mins, secs)
                self.window.timerEdit.setText(timeformat)
                QThread.usleep(20)
            t2 = s - (datetime.now() - start_time).seconds
        if t == 0:
            self.window.timerEdit.setText("00:00")
            QThread.sleep(1)
            print("countdown done!")
            self.window.done.emit()
        else:
            print("stopped timer")
Esempio n. 13
0
 def run(self):
     # run结束线程死亡
     while True:
         self.signal_open.emit()
         self.open_mouth()
         QThread.usleep(10000)
Esempio n. 14
0
 def run(self):
     """Wait until we're in tol, then start get bpm thread"""
     self.sol.bctrl = self.bval
     while abs(self.bval-self.sol.bact) > self.sol.tol:
         QThread.usleep(SETTLE)
Esempio n. 15
0
 def ensure_first_paint(self):
     while not self.painted:
         QThread.usleep(250)
         QApplication.processEvents()
     self.animation_trigger_timer.start(1000)
Esempio n. 16
0
 def _ensure_painted(self) -> None:
     while not self._painted:
         QThread.usleep(1000)
         QApplication.processEvents()
Esempio n. 17
0
 def run(self):
     while True:
         QThread.usleep(50)
         self.update.emit()