0
我試圖將simplecv和pyqt4整合在一起,並取得了一些成功。我可以通過simplecv在pyqt4中看到捕捉到的攝像頭,我可以用simplecv修改圖像,並且在pyqt4中顯示確定,但是當我嘗試向圖像添加幾何圖形或文本時,它不會在pyqt4中顯示。如果我自己運行simpleCV代碼,它可以正常工作。有人能幫我理解爲什麼它不起作用嗎?順便說一下,正如你所看到的,我是pyqt4和simpleCV的新手。查看我目前擁有的代碼。用simplecv和pyqt4畫線條
#!/usr/bin/env python
import os
import sys
import signal
from PyQt4 import uic, QtGui, QtCore
from webcamGUI3 import *
from SimpleCV import *
class Webcam(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self,parent)
self.MainWindow = Ui_MainWindow()
self.MainWindow.setupUi(self)
self.webcam = Camera(0,{ "width": 640, "height": 480 })
self.timer = QtCore.QTimer()
self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.show_frame)
self.timer.start(1);
def show_frame(self):
ipl_image = self.webcam.getImage()
ipl_image.dl().circle((150, 75), 50, Color.RED, filled = True)
data = ipl_image.getBitmap().tostring()
image = QtGui.QImage(data, ipl_image.width, ipl_image.height, 3 * ipl_image.width, QtGui.QImage.Format_RGB888)
pixmap = QtGui.QPixmap()
pixmap.convertFromImage(image.rgbSwapped())
self.MainWindow.lblWebcam.setPixmap(pixmap)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
webcam = Webcam()
webcam.show()
app.exec_()
任何想法?