[PySide] Minimal QCamera code?

Cristián Maureira-Fredes Cristian.Maureira-Fredes at qt.io
Thu May 23 11:48:46 CEST 2019



On 5/22/19 11:18 PM, Jason H wrote:
> Hi all, I am experimenting with a PySide2. I've got experience with the C++ and QML APIs.
> 
> I started to port a small minimal image camera capture sample I have over, but immediately I got:
> 
> AttributeError: module 'PySide2.QtMultimedia' has no attribute 'availableCameras'
> https://doc.qt.io/qt-5/qml-qtmultimedia-qtmultimedia.html#availableCameras-prop
> https://doc.qt.io/qtforpython/PySide2/QtMultimedia/index.html does not list this either.
> 
> #!/usr/bin/env python3.7
> from PySide2.QtCore import *
> from PySide2.QtMultimedia import *
> 
>>>> dir(PySide2.QtMultimedia)
> ['QAbstractAudioDeviceInfo', 'QAbstractAudioInput', 'QAbstractAudioOutput', 'QAbstractVideoBuffer', 'QAbstractVideoFilter', 'QAbstractVideoSurface', 'QAudio', 'QAudioBuffer', 'QAudioDecoder', 'QAudioDecoderControl', 'QAudioDeviceInfo', 'QAudioEncoderSettings', 'QAudioEncoderSettingsControl', 'QAudioFormat', 'QAudioInput', 'QAudioInputSelectorControl', 'QAudioOutput', 'QAudioOutputSelectorControl', 'QAudioProbe', 'QAudioRecorder', 'QAudioRoleControl', 'QCamera', 'QCameraCaptureBufferFormatControl', 'QCameraCaptureDestinationControl', 'QCameraControl', 'QCameraExposureControl', 'QCameraFeedbackControl', 'QCameraFocusZone', 'QCameraImageCapture', 'QCameraImageCaptureControl', 'QCameraImageProcessingControl', 'QCameraInfo', 'QCameraInfoControl', 'QCameraLocksControl', 'QCameraViewfinderSettings', 'QCameraViewfinderSettingsControl', 'QCameraViewfinderSettingsControl2', 'QCameraZoomControl', 'QCustomAudioRoleControl', 'QImageEncoderControl', 'QImageEncoderSettings', 'QMediaAudioProbeControl', 'QMediaAvailabilityControl', 'QMediaBindableInterface', 'QMediaContainerControl', 'QMediaContent', 'QMediaControl', 'QMediaGaplessPlaybackControl', 'QMediaNetworkAccessControl', 'QMediaObject', 'QMediaPlayer', 'QMediaPlayerControl', 'QMediaPlaylist', 'QMediaRecorder', 'QMediaRecorderControl', 'QMediaResource', 'QMediaService', 'QMediaServiceCameraInfoInterface', 'QMediaServiceDefaultDeviceInterface', 'QMediaServiceFeaturesInterface', 'QMediaServiceProviderHint', 'QMediaServiceSupportedDevicesInterface', 'QMediaServiceSupportedFormatsInterface', 'QMediaStreamsControl', 'QMediaTimeInterval', 'QMediaTimeRange', 'QMediaVideoProbeControl', 'QMetaDataReaderControl', 'QMetaDataWriterControl', 'QMultimedia', 'QRadioData', 'QRadioDataControl', 'QRadioTuner', 'QRadioTunerControl', 'QSound', 'QSoundEffect', 'QVideoDeviceSelectorControl', 'QVideoEncoderSettings', 'QVideoEncoderSettingsControl', 'QVideoFilterRunnable', 'QVideoFrame', 'QVideoProbe', 'QVideoRendererControl', 'QVideoSurfaceFormat', 'QVideoWindowControl', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']
> 
> print (PySide2.QtMultimedia.availableCameras)
> 
> I just want to acquire a single image and pass that to OpenCV for processing. There are multiple cameras installed on my computer.
> 
> Any help would be appreciated.


Hello Jason,

I don't know if this helps you,
but inside the examples that comes with PySide2
you can find one related to QCamera:

https://code.qt.io/cgit/pyside/pyside-setup.git/tree/examples/multimedia/camera.py

At least locally (I don't have a camera)
I can access to that method through QCameraInfo:

 >>> from PySide2.QtMultimedia import QCameraInfo
 >>> QCameraInfo.availableCameras()
[]

let us know how it goes!

Cheers



-- 
Dr. Cristian Maureira-Fredes
Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin

Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B
--


More information about the PySide mailing list