使用PyQt4的OpenCV视频捕获

使用PyQt4的OpenCV视频捕获,第1张

使用PyQt4的OpenCV视频捕获
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)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5662048.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存