0

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.

slalomchip
  • 779
  • 2
  • 9
  • 25
  • Is it Windows 10 N? What version of PyQt? Can you try to create an instance of a QApplication before querying the cameras? – musicamante Oct 27 '21 at 03:16
  • @musicamante - My PyQt is v5.12.13. I revised my script (above) to add a QApplication instance, but the result was still an empty list – slalomchip Oct 27 '21 at 11:42
  • I can see various reports on a similar problem, often related to different causes. I suggest you to do some research, including the C++ questions (most of the times is just trivial code). You didn't answer about Windows N, btw. – musicamante Oct 27 '21 at 11:45
  • @musicamante - I'm not using Windows 10 N. I researched it, but will research it further. – slalomchip Oct 27 '21 at 11:51
  • Anaconda was the issue. See the solution. – slalomchip Nov 05 '21 at 13:38
  • Good. For future reference, always remember mentioning the full environment: it's generally assumed that the setup uses standard *official* installations (system python or downloaded from the official website, then pip). – musicamante Nov 05 '21 at 13:57
  • Will do. Thanks – slalomchip Nov 06 '21 at 02:18

1 Answers1

0

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).

slalomchip
  • 779
  • 2
  • 9
  • 25