I want to display streaming video using QtMultimedia modules in Python on a Windows 10 platform. However, the first most fundamental step is not working for me – identifying available cameras.
Windows Device Manager confirms that there are two cameras attached to my laptop computer – a webcam and a USB capture device.
My script does not identify any available cameras with the following script:
from PyQt5.QtMultimedia import QCameraInfo
from PyQt5.QtWidgets import QApplication, QWidget
import sys
class MainWindow(QWidget):
def __init__(self):
super().__init__()
myList = QCameraInfo.availableCameras()
print('List = ', myList)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
mw = MainWindow()
sys.exit(app.exec())
Result:
List = []
Is there a fundamental issue with QtMultimedia cameras and Windows 10 that I’m unaware of?
Note: I have successfully used QtMultimedia to display a video read from a file. Now I want to display from a video stream.
I found a solution that works for me.
I read here that Anaconda does not include the full set PtQt5 modules. The solution was to uninstall Anaconda (or Miniconda), install the basic Python and pip install
all the needed packages. I also downloaded Spyder from PyPI, so very little has changed.
When in Anaconda, this QCamera example would not execute because of several import errors. It works flawlessly now after replacing the Anaconda environment with a basic Python environment (and installing the needed packages).