class Capture(): def __init__(self): self.capturing = False self.c = cv2.VideoCapture(0) def startCapture(self): print "pressed start" self.capturing = True cap = self.c while(self.capturing): ret, frame = cap.read() cv2.imshow("Capture", frame) cv2.waitKey(5) cv2.destroyAllWindows() def endCapture(self): print "pressed End" self.capturing = False # cv2.destroyAllWindows() def quitCapture(self): print "pressed Quit" cap = self.c cv2.destroyAllWindows() cap.release() QtCore.QCoreApplication.quit()
在窗口中:
self.capture = Capture()self.start_button = QtGui.QPushButton('Start',self)self.start_button.clicked.connect(self.capture.startCapture)self.end_button = QtGui.QPushButton('End',self)self.end_button.clicked.connect(self.capture.endCapture)self.quit_button = QtGui.QPushButton('Quit',self)self.quit_button.clicked.connect(self.capture.quitCapture)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)