[Interest] QML Camera: resulting image is rotated

René Hansen renehh at gmail.com
Mon Dec 10 09:51:44 CET 2018


Forgot to add, that m_filter->camera() in the snippet above, is just a
reference to a Camera QML component.

On Mon, 10 Dec 2018 at 09:48 René Hansen <renehh at gmail.com> wrote:

> You can get the Camera orientation like so:
>
> QCamera *cam = qvariant_cast<QCamera
> *>(m_filter->camera()->property("mediaObject"));
> QCameraInfo(*cam).orientation()
>
> Then in case orientation is not % 180, you can rotate the image.
>
>
> /René
>
>
> On Mon, 10 Dec 2018 at 09:42 ekke <ekke at ekkes-corner.org> wrote:
>
>> Am 10.12.18 um 02:08 schrieb Alexander Ivash:
>>
>> Thanks!
>>
>> But frankly speaking this is not the answer I hoped to get :).
>>
>> ;-)
>>
>> Have you tried to extract rotation from exif / metadata? This is what I'm
>> going to do if don't find better way.
>>
>> have not tried this. please let me know if you'll find a way
>>
>> In my case VideoOutput always shows preview in correct orientation,
>>
>> have you tested on iOS and FrontFace Camera ? in my use-cases I needed
>> rotation of 180 for preview (VideoOutput)
>>
>> so looks like Qt *knows* how to rotate preview frames properly (why
>> doesn't it use this knowledge to rotate saved image or why doesn't it
>> expose it - this is another question). But if Qt knows - there should be
>> some source of information where it gets such a knowledge.
>>
>> haven't found any info about
>>
>> ciao
>>
>> ekke
>>
>>
>> Regards, Alexander
>>
>> On Dec 9 2018, at 8:17 pm, ekke <ekke at ekkes-corner.org>
>> <ekke at ekkes-corner.org> wrote:
>>
>>
>> Am 09.12.18 um 16:57 schrieb Alexander Ivash:
>>
>>
>> Is it possible to understand the angle to un-rotate? I've tried to
>> un-rotate based on orientation from VideoOtput but it doesn't work
>> uniformly on all the devices.
>>
>> Regards, Alexander
>> [image: Open Tracking]
>>
>> _______________________________________________
>> Interest mailing listInterest at lists.qt-project.org <https://link.getmailspring.com/link/1544403647.local-a741a368-81fb-v1.5.3-420ce003@getmailspring.com/0?redirect=mailto%3AInterest%40lists.qt-project.org&recipient=ZWtrZUBla2tlcy1jb3JuZXIub3Jn>https://lists.qt-project.org/listinfo/interest <https://link.getmailspring.com/link/1544403647.local-a741a368-81fb-v1.5.3-420ce003@getmailspring.com/1?redirect=https%3A%2F%2Flists.qt-project.org%2Flistinfo%2Finterest&recipient=ZWtrZUBla2tlcy1jb3JuZXIub3Jn>
>>
>> Alexander,
>>
>> from my experiences it's not so easy.
>>
>> it depends from device and how the camera module is physically mounted
>>
>> so I'm doing it for my customers hardcoded while waiting that QML will
>> handle this
>>
>> here's some code from customer app
>>
>> it's on my TODO to extract the code and create example app and blog and
>> create all the specific issues - but expect 2019
>>
>> To get some ideas:
>>
>> // V I D E O   O U T P U T
>> VideoOutput {
>>     source: camera
>>     anchors.fill: parent
>>     focus : visible
>>     autoOrientation: true
>>     rotation: isIos && isFrontFace ? 180:0
>> } // Video Output
>>
>>
>> // P R E V I E W   I M A G E
>> Image {
>>     id: photoPreview
>>     fillMode: Image.PreserveAspectFit
>>      anchors.fill: parent
>>      property bool isPortraitAtCaptureTime: false
>>     // i O S   BUG
>>     // on iOS we don't use autoTransform - otherwise orientation would be
>> wrong
>>     // instead we're calculating rotation of Image
>>     // we also must calculate rotation 180 for VideoOutput if iOS and
>> FrontFace
>>    // see also
>>    // https://bugreports.qt.io/browse/QTBUG-50056
>> <https://link.getmailspring.com/link/1544403647.local-a741a368-81fb-v1.5.3-420ce003@getmailspring.com/2?redirect=https%3A%2F%2Fbugreports.qt.io%2Fbrowse%2FQTBUG-50056&recipient=ZWtrZUBla2tlcy1jb3JuZXIub3Jn>
>>    // test also front camera bugs
>> https://bugreports.qt.io/browse/QTBUG-37955
>> <https://link.getmailspring.com/link/1544403647.local-a741a368-81fb-v1.5.3-420ce003@getmailspring.com/3?redirect=https%3A%2F%2Fbugreports.qt.io%2Fbrowse%2FQTBUG-37955&recipient=ZWtrZUBla2tlcy1jb3JuZXIub3Jn>
>> and https://bugreports.qt.io/browse/QTBUG-67985
>> <https://link.getmailspring.com/link/1544403647.local-a741a368-81fb-v1.5.3-420ce003@getmailspring.com/4?redirect=https%3A%2F%2Fbugreports.qt.io%2Fbrowse%2FQTBUG-67985&recipient=ZWtrZUBla2tlcy1jb3JuZXIub3Jn>
>>    autoTransform: isIos? false : true
>>    rotation: 0
>>  } // photoPreview
>>
>> // ROTATE BEFORE CAPTURE
>> // iOS rotation calculated in cpp:
>> int PhotoUtil::cameraScreenRotation(const bool isBackFace, const int
>> cameraOrientation)
>> {
>>     const int screenAngle =
>> mScreen->angleBetween(mScreen->nativeOrientation(), mScreen->orientation());
>>     int rotation;
>>     if (isBackFace) {
>>         rotation = (360 - cameraOrientation + screenAngle) % 360;
>>     } else {
>>         rotation = (cameraOrientation - screenAngle) % 360;
>>     }
>>     return rotation;
>> }
>> if(isIos) {
>>
>> photoUtil.rotateScaleSaveCapturedImage(camera.imageCapture.capturedImagePath,
>> requestId, theEntity, photoPreview.rotation)
>> } else {
>>     // X C O V E R
>>     if(isSamsungXCover) {
>>         if(photoPreview.isPortraitAtCaptureTime) {
>>             if(isBackFace) {
>>                 // PORTRAIT BACK: rotate 90°
>>
>> photoUtil.rotateScaleSaveCapturedImage(camera.imageCapture.capturedImagePath,
>> requestId, theEntity, 90)
>>             } else {
>>                 // PORTRAIT FRONT: rotate -90°
>>
>> photoUtil.rotateScaleSaveCapturedImage(camera.imageCapture.capturedImagePath,
>> requestId, theEntity, -90)
>>             }
>>         } else {
>>             // LANDSCAPE BACK or FRONT: rotate 180°
>>
>> photoUtil.rotateScaleSaveCapturedImage(camera.imageCapture.capturedImagePath,
>> requestId, theEntity, 180)
>>         }
>>     }
>>     // P I X E L    C
>>     else if(isPixelC) {
>>         if(photoPreview.isPortraitAtCaptureTime) {
>>             if(isBackFace) {
>>                 // PORTRAIT BACK: rotate 90°
>>
>> photoUtil.rotateScaleSaveCapturedImage(camera.imageCapture.capturedImagePath,
>> requestId, theEntity, 90)
>>             } else {
>>                 // PORTRAIT FRONT: rotate -90°
>>
>> photoUtil.rotateScaleSaveCapturedImage(camera.imageCapture.capturedImagePath,
>> requestId, theEntity, -90)
>>             }
>>         } else {
>>             // LANDSCAPE BACK or FRONT: OK
>>
>> photoUtil.rotateScaleSaveCapturedImage(camera.imageCapture.capturedImagePath,
>> requestId, theEntity, 0)
>>         }
>>     }
>>     // NO SPECIAL DEVICE WITH MANAGED ORIENTATION
>>     else {
>>
>> photoUtil.rotateScaleSaveCapturedImage(camera.imageCapture.capturedImagePath,
>> requestId, theEntity, 0)
>>     }
>> }
>>
>> have tried with some devices and also created a Settings Page where
>> customer can enter rotation needed for FrontFace or BackFace camera for a
>> specific model, so I can add this
>>
>> ekke
>> _______________________________________________
>> Interest mailing list
>> Interest at lists.qt-project.org
>> https://lists.qt-project.org/listinfo/interest
>>
>> [image: Open Tracking]
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at lists.qt-project.org
>> https://lists.qt-project.org/listinfo/interest
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181210/9e072eba/attachment.html>


More information about the Interest mailing list