Using python OpenCV binding to display webcam stream in PySide widgets

Hey, if anyone can help me that would be great. I am trying to use OpenCV to take a webcam stream and then display it in a PySide app by updating the image.

cv.NamedWindow('Raw', cv.CV_WINDOW_AUTOSIZE)
self.cap = cv.CaptureFromCAM(0)

      

This works and I am updating the named window in a while loop with show image function.

while True:
    frame = cv.QueryFrame(self.cap)
    img = cv.CreateImage(cv.GetSize(frame),cv.IPL_DEPTH_8U,1)
    if frame is None:
        print "Frame is none"
        sys.exit(1)
    # display webcam image
    cv.ShowImage('Raw', frame)

      

But when I try to display images in a PySide application, I just see a blank black image (The following code is in the same while loop as above)

image = QImage(frame.tostring(), frame.width, frame.height, QImage.Format_RGB888).rgbSwapped()
self.pixmap = QPixmap.fromImage(image)
grid = QGridLayout()
grid.setSpacing(10)
imageBox = QLabel(self)
imageBox.setGeometry(0,0,300,200)
imageBox.setPixmap(self.pixmap.scaled(300,200))
grid.addWidget(imageBox)
self.widget.setLayout(grid)
self.repaint()            

      

Does anyone know why the image is not updating?

+3
python opencv pyside


source to share


No one has answered this question yet

Check out similar questions:

338
Simple OCR character recognition in OpenCV-Python
nineteen
How to display OpenCV video efficiently in Qt?
nine
python: tkinter to display webcam video and scan QR code
five
open webcamera with OpenCV and show it with QLabel - white window
4
Displaying video stream in QLabel with PySide
3
opencv / python: draw image via webcam stream
2
Displaying OpenCV video with PyQt5
1
Problem capturing images from webcam with Arch Linux and OpenCV (node.js)
1
Show camera stream in QLabel
0
Terminating OpenCV Camera Stream in Full Screen Mode



All Articles
Loading...
X
Show
Funny
Dev
Pics