MCPcopy
hub / github.com/PyQt5/PyQt / startCapture

Method startCapture

Demo/FacePoints.py:85–103  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

83 self.setText('已下载:{} %'.format(round(bytesRead / 64040097 * 100, 2)))
84
85 def startCapture(self):
86 self.setText("请稍候,正在初始化数据和摄像头。。。")
87 try:
88 # 检测相关
89 self.detector = dlib.get_frontal_face_detector()
90 self.predictor = dlib.shape_predictor(
91 "Data/shape_predictor_68_face_landmarks.dat")
92 cascade_fn = "Data/lbpcascades/lbpcascade_frontalface.xml"
93 self.cascade = cv2.CascadeClassifier(cascade_fn)
94 if not self.cascade:
95 return QMessageBox.critical(self, "错误", cascade_fn + " 无法找到")
96 self.cap = cv2.VideoCapture(0)
97 if not self.cap or not self.cap.isOpened():
98 return QMessageBox.critical(self, "错误", "打开摄像头失败")
99 # 开启定时器定时捕获
100 self.timer = QTimer(self, timeout=self.onCapture)
101 self.timer.start(1000 / self.fps)
102 except Exception as e:
103 QMessageBox.critical(self, "错误", str(e))
104
105 def closeEvent(self, event):
106 if hasattr(self, "_reply") and self._reply:

Callers 2

__init__Method · 0.95
httpFinishedMethod · 0.95

Calls 2

setTextMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected