How to get camera supported resolutions using Qt5?
-
Just for your information... the output of my test from Windows 7 using your code. Same result, no resolutions:
Starting C:\tupi\build-sample-Desktop_Qt_5_3_0_MinGW_32bit-Debug\debug\camera.exe...
Camera description: "Webcam C170"
Camera status: QCamera::UnavailableStatus
Camera resolution list size: 0
mediaObject QCamera(0x59e820)
media service DSCameraService(0x59a970)
encoderControl QObject(0x0)
C:\tupi\build-sample-Desktop_Qt_5_3_0_MinGW_32bit-Debug\debug\camera.exe exited with code 0 -
Today I was running some tests from my Linux system (Ubuntu 14.04 x64). This is my report:
-
List of gstreamer dependencies installed:
http://www.maefloresta.com/tmp/gstreamer-dependencies.txt -
Using Qt 4.8 and the package qtmobility-dev the piece of code of my first post works perfectly.
@
QList<QSize> resolutions = imageCapture->supportedResolutions();
@
I got the list of resolutions for three different cameras I'm using with accurate values.
Note: The dependencies required by the package "qtmobility-dev" are:
libqtconnectivity1 libqtcontacts1 libqtfeedback1 libqtgallery1 libqtlocation1 libqtmultimediakit1 libqtorganizer1 libqtpublishsubscribe1 libqtsensors1 libqtserviceframework1 libqtsysteminfo1 libqtversit1 libqtversitorganizer1 servicefw-
Using either Qt 5.2.1 or Qt 5.3.0 and removing the package qtmobility-dev the function QCameraImageCapture::supportedResolutions() doesn't work any more.
Note: I tried two options: the Qt Ubuntu packages and the Qt online installer. -
I was checking the source code of the package qtmobility-dev running: apt-get source qtmobility-dev and comparing the structure and classes against the Qt 5.2.1/5.3.0 and I got the same code:
@
QList<QSize> QCameraImageCapture::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const
{
if (continuous)
*continuous = false;return d_func()->encoderControl ?
d_func()->encoderControl->supportedResolutions(settings, continuous) : QList<QSize>();
}
@
All the Qt versions I checked have the module "plugins/multimedia/gstreamer" included, so the problem shouldn't be there.
I tried the same test from MS Windows installing all the directshow compounds and the result is the same: an empty list.
So, what happened between Qt 4.8.x and Qt 5.2.x with this feature? Is this feature already working for someone using Qt 5.x?
-
-
Today I had the chance to test my sample from OSX and I got the same result, the method QCameraImageCapture::supportedResolutions() doesn't work here neither:
$ uname -a
Darwin MacBook-Pro.local 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64$ qmake -version
QMake version 3.0
Using Qt version 5.3.0 in /Users/test/Qt5.3.0/5.3/clang_64/lib$ ./camera.app/Contents/MacOS/camera
Camera description: "Cámara FaceTime HD (integrada)"
Camera status: QCamera::LoadedStatus
Camera resolution list size: 0 -
Testing the same example but this time using Qt 5.3.1 from Linux, same result:
$ ./camera
Camera description: "USB2.0 UVC WebCam"
Camera status: QCamera::LoadedStatus
CameraBinImageEncoder::supportedResolutions()
Camera resolution list size: 0The method supportedResolutions() always returns an empty list :(
-
Surprisingly I couldn't find a bug report about this (for linux)...
Now here it is:
https://bugreports.qt-project.org/browse/QTBUG-40545Follow, upvote, comment. Make some noise!
(There is a bug report for windows, but there it is just not supported...
https://bugreports.qt-project.org/browse/QTBUG-32743 ) -
It looks like that gstreamer on Linux is not returing any value in: camerabinsession.cpp
@ GstCaps *supportedCaps = 0;
g_object_get(G_OBJECT(m_camerabin),
(mode == QCamera::CaptureStillImage) ?
SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY : SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY,
&supportedCaps, NULL);
if (!supportedCaps)
return res;@I was trying calling gstreamer out of QT and was getting NULL as well. Is it a bug in GStreamer?
-
It looks like that gstreamer on Linux is not returing any value in: camerabinsession.cpp
@ GstCaps *supportedCaps = 0;
g_object_get(G_OBJECT(m_camerabin),
(mode == QCamera::CaptureStillImage) ?
SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY : SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY,
&supportedCaps, NULL);
if (!supportedCaps)
return res;@I was trying calling gstreamer out of QT and was getting NULL as well. Is it a bug in GStreamer?
-
Hi,
Either that or the device doesn't return the information. Do you have any other way to retrieve that information on your system ?
-
Hi,
Either that or the device doesn't return the information. Do you have any other way to retrieve that information on your system ?
-
Well, v4l2 is returning:
@$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUV 4:2:2 (YUYV)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 640x360
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
...@The structure GstCaps *supportedCaps from previous code, has 0 length, but it's valid but @gst_caps_is_any(supportedCaps) == true@
-
Well, v4l2 is returning:
@$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUV 4:2:2 (YUYV)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 640x360
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
...@The structure GstCaps *supportedCaps from previous code, has 0 length, but it's valid but @gst_caps_is_any(supportedCaps) == true@
-
I've digged deeper into GStreamer plugin gstcamerabin2.c, here it's querying for pad capabilities @pad = gst_element_get_static_pad (element, padname);
caps = gst_pad_query_caps (pad, NULL);@ and then the query failing "GstPAd.html":http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstPad.html
...gst_pad_query_caps returns all possible caps a pad can operate with, using the pad's CAPS query function, If the query fails, this function will return filter , if not NULL, otherwise ANY.
And this ANY is what's returned into QT and then returned as empty QList. I thing we should use another gstreamer input element aka v4l2src which is stable. Camerabin2 is marked as unstable and under development.
-
I've digged deeper into GStreamer plugin gstcamerabin2.c, here it's querying for pad capabilities @pad = gst_element_get_static_pad (element, padname);
caps = gst_pad_query_caps (pad, NULL);@ and then the query failing "GstPAd.html":http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstPad.html
...gst_pad_query_caps returns all possible caps a pad can operate with, using the pad's CAPS query function, If the query fails, this function will return filter , if not NULL, otherwise ANY.
And this ANY is what's returned into QT and then returned as empty QList. I thing we should use another gstreamer input element aka v4l2src which is stable. Camerabin2 is marked as unstable and under development.
-
Thanks for sharing your findings !
Do you have that with gstreamer0.1 ? Did you check gstreamer 1 ?
-
Thanks for sharing your findings !
Do you have that with gstreamer0.1 ? Did you check gstreamer 1 ?