我正在使用qthread显示从usb摄像头捕获的图像
问题是在使用以下命令终止线程后出现的:
th.terminate()
摄像头指示灯仍亮,表示仍在使用(跳过以释放捕获)
尝试做:
cap = cv2.VideoCapture(0)
cap.release()
终止后,问题仍然存在
if(self.monitoringToggle == False):
self.monitoringToggle = True
self.monitoringButton.setText("Stop Monitoring")
self.th.changePixmap.connect(self.setImage)
self.th.start()
else:
self.monitoringToggle = False
self.monitoringButton.setText("Monitoring")
self.th.terminate()
cap = cv2.VideoCapture(0)
cap.release()
qImg = QImage("white_background.png")
self.videoLabel.setPixmap(QtGui.QPixmap(qImg))
class MonitoringThread(QThread):
def run(self):
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cap.release()
目前没有回答
相关问题 更多 >
编程相关推荐