Unsolved QCamera + QCameraViewfinder: how to mirror the the image displayed in the viewfinder?
-
@SGaist
No such luck :(viewFinder->mediaObject()
isnullptr
.
IS there a restriction on when I should callmediaObject()
relative to, say,show()
or any other lifecycle-related method of the view finder? -
Did you set the viewFinder on the camera before calling mediaObject ?
-
@SGaist
Nope, i was doing it just before that. So, now I put this code right aftersetViewfinder
, andmediaService
is not null, butmediaService->requestControl<QVideoRendererControl *>()
returnsnullptr
. -
What OS are you running ? It might be that the backend doesn't provide that control.
-
Windows 10.
-
how to mirror the the image displayed in the viewfinder?
+1
Actually
+1000This is a very good question!
I also want to mirror the image (flip it left to right)!PS:
I'm using Debian Testing, which requires these packages, to get QCamera working: qt5-default, libqt5multimedia5, libqt5multimedia5-plugins, libqt5multimediaquick-p5, libqt5multimediawidgets5, qml-module-qtmultimedia, qtmultimedia5-dbg, qtmultimedia5-dev -
Just a quick update:
QVideoRendererControl *rendererControl = camera.service()->requestControl<QVideoRendererControl *>(); if (rendererControl) { QAbstractVideoSurface *surface = rendererControl->surface(); QVideoSurfaceFormat format = surface->surfaceFormat(); format.setProperty("mirrored", true); surface->stop(); surface->start(format); } else { qDebug() << "Backend doesn't provide a video renderer control"; }
-
Thanks, but still no.
rendererControl
is null, and I tried executing your snippet both before and aftercamera.start()
call. -
Can you check what plugin is loaded ? It should be either the WMF or DirectX plugin. IIRC the DX plugin has the control.
-
I can't see either. Here's the complete list of all the .dlls loaded.
I can, however, see an odd warning. I don't have a slightest idea if it's related, but probably not:D3D11CreateDevice: Flags (0x2) were specified which require the D3D11 SDK Layers for Windows 10, but they are not present on the system.
These flags must be removed, or the Windows 10 SDK must be installed.
Flags include: D3D11_CREATE_DEVICE_DEBUG -
Sorry, I meant start your application with QT_DEBUG_PLUGINS set to 1.
-
Is it an environment variable or a project define?
-
Environment variable that you can set in the Run part of the Project panel.
-
Here's the list. Can't see anything named WMF, but I guess I need to know the exact name to look for.
-
@Violet-Giraffe said:
Thanks, but still no.
rendererControl
is nullSame for Debian (and it's variants [Ubuntu, etc.])
-
Maby the way to do this for now...
(i.e. until the qt developers realize the value of extendingQCameraImageProcessing
orQCameraViewfinder
to allow mirroring (flipping) the image)...is to "derive from QAbstractVideoSurface" as shown here: http://doc.qt.io/qt-5/cameraoverview.html#viewfinder (find some example code there, showing rotation)
-
DSEngine -> DirectShow. The plugin it self has the control but it seems it's not accessible yet.
If you are wiling to re-build the plugin, that can be modified.
-
@SGaist, it depends on how difficult it is to build Qt 5 nowadays (I remember it being a pain because of WebKit that I didn't even need, hopefully that's fixed now). Let me check nicesw123's suggestion first.
-
Qt/C++ already provides that functionality. You can easily implement flipping feature if you use the following classes.
QGraphicsView, QGraphicsScene, QCamera, QVideoWidget, QTramsform
-
@Devopia53, how can I connect those to
QCamera
if the only thing camera accepts isQCameraViewfinder
?
P. S. Nvm, it acceptsQVideoWidget
. Still not quite sure how to connect the parts you've listed. A little help, please? :)