Skip to content

Class QfCameraOrientationNormalizer

ClassList > QfCameraOrientationNormalizer

Compensates for incorrect camera orientation on iOS and Windows, and applies user-requested photo adjustments on all platforms. More...

  • #include <qfcameraorientationnormalizer.h>

Inherits the following classes: QObject

Public Types

Type Name
enum CameraPosition
Camera position, matching the integer values of QCameraDevice::Position.

Public Properties

Type Name
property QfCameraOrientationNormalizer::CameraPosition cameraPosition
property int previewRotation

Public Signals

Type Name
signal void cameraPositionChanged
signal void previewRotationChanged

Public Functions

Type Name
QfCameraOrientationNormalizer (QObject * parent=nullptr)
Constructs the normalizer and starts tracking screen orientation.
Q_INVOKABLE bool applyEditsToImage (const QString & path, int rotation, bool mirror)
QfCameraOrientationNormalizer::CameraPosition cameraPosition () const
Q_INVOKABLE bool normalizeImageOrientation (const QString & path)
int previewRotation () const
Q_INVOKABLE void recordCaptureOrientation ()
void setCameraPosition (QfCameraOrientationNormalizer::CameraPosition position)

Detailed Description

On iOS and Windows, Qt Multimedia's backend produces an inverted camera preview in landscape mode and writes captured photos with incorrect orientation or bogus EXIF tags (QTBUG-118594). The preview and saved-image corrections below are limited to those platforms.

Separately, and on all platforms, this class can bake a user-chosen rotation and mirror into a captured photo before it is saved.

This class provides: previewRotation for correcting the live VideoOutput orientation (iOS and Windows only) cameraPosition to distinguish the front-facing camera, which needs an additional mirror correction normalizeImageOrientation() for correcting saved JPEG files (iOS and Windows only) applyEditsToImage() for baking a user-chosen rotation and mirror into a saved JPEG (all platforms)

Public Types Documentation

enum CameraPosition

Camera position, matching the integer values of QCameraDevice::Position.

enum QfCameraOrientationNormalizer::CameraPosition {
    UnspecifiedPosition = 0,
    BackFace = 1,
    FrontFace = 2
};


Public Properties Documentation

property cameraPosition [1/2]

QfCameraOrientationNormalizer::CameraPosition QfCameraOrientationNormalizer::cameraPosition;

property previewRotation [1/2]

int QfCameraOrientationNormalizer::previewRotation;

Public Signals Documentation

signal cameraPositionChanged

void QfCameraOrientationNormalizer::cameraPositionChanged;

signal previewRotationChanged

void QfCameraOrientationNormalizer::previewRotationChanged;

Public Functions Documentation

function QfCameraOrientationNormalizer

Constructs the normalizer and starts tracking screen orientation.

explicit QfCameraOrientationNormalizer::QfCameraOrientationNormalizer (
    QObject * parent=nullptr
) 


function applyEditsToImage

Q_INVOKABLE bool QfCameraOrientationNormalizer::applyEditsToImage (
    const QString & path,
    int rotation,
    bool mirror
) 

Bakes a user-chosen adjustment into the JPEG at path, letting the user manually correct a photo before saving. Unlike the orientation compensation, this applies on all platforms. rotation is a clockwise angle in degrees (any multiple of 90) and mirror applies a horizontal flip. The mirror is applied before the rotation to match the live preview.

Returns false without touching the file when there is nothing to apply (zero rotation and no mirror).


function cameraPosition [2/2]

QfCameraOrientationNormalizer::CameraPosition QfCameraOrientationNormalizer::cameraPosition () const

Returns the active camera's position (front, back, or unspecified), used to apply the additional horizontal mirror correction that front-facing cameras require when normalizing saved photos.


function normalizeImageOrientation

Q_INVOKABLE bool QfCameraOrientationNormalizer::normalizeImageOrientation (
    const QString & path
) 

Ensures the JPEG at path has pixels matching the orientation recorded by recordCaptureOrientation(). Rotates the image if pixel dimensions contradict the capture orientation and strips any non-identity EXIF orientation tag.

Returns false without touching the file when no correction is needed.


function previewRotation [2/2]

int QfCameraOrientationNormalizer::previewRotation () const

Returns the rotation in degrees that the live camera preview (VideoOutput) must be rotated by to appear upright, compensating for the incorrect preview orientation on iOS and Windows.


function recordCaptureOrientation

Q_INVOKABLE void QfCameraOrientationNormalizer::recordCaptureOrientation () 

Records the current screen orientation. Call at shutter press so that normalizeImageOrientation() has a ground-truth reference.


function setCameraPosition

void QfCameraOrientationNormalizer::setCameraPosition (
    QfCameraOrientationNormalizer::CameraPosition position
) 

Sets the active camera's position. Bound from the QML camera's device position so orientation correction can distinguish the front-facing camera.



The documentation for this class was generated from the following file src/core/qfcameraorientationnormalizer.h