AVFoundation: don't automatically rotate camera captures.
We shouldn't do this automatically, as different kind of orientations might be wanted (sensor, device, UI). The default should be sensor orientation (no rotation applied). We should add an API to QCamera to enable automatic orientation of captured images. Change-Id: I56fff7f0c4aaaee37eb6ae2628e27073b4946b66 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
#include <QtCore/qqueue.h>
|
||||
#include <QtCore/qsemaphore.h>
|
||||
#include <QtMultimedia/qcameraimagecapturecontrol.h>
|
||||
#include <private/qvideooutputorientationhandler_p.h>
|
||||
#include "avfcamerasession.h"
|
||||
#include "avfstoragelocation.h"
|
||||
|
||||
@@ -72,7 +71,7 @@ private Q_SLOTS:
|
||||
void onNewViewfinderFrame(const QVideoFrame &frame);
|
||||
|
||||
private:
|
||||
void makeCapturePreview(CaptureRequest request, const QVideoFrame &frame, AVFCameraInfo cameraInfo, int screenOrientation);
|
||||
void makeCapturePreview(CaptureRequest request, const QVideoFrame &frame, int rotation);
|
||||
|
||||
AVFCameraSession *m_session;
|
||||
AVFCameraControl *m_cameraControl;
|
||||
@@ -81,7 +80,6 @@ private:
|
||||
AVCaptureStillImageOutput *m_stillImageOutput;
|
||||
AVCaptureConnection *m_videoConnection;
|
||||
AVFStorageLocation m_storageLocation;
|
||||
QVideoOutputOrientationHandler m_orientationHandler;
|
||||
|
||||
QMutex m_requestsMutex;
|
||||
QQueue<CaptureRequest> m_captureRequests;
|
||||
|
||||
@@ -180,21 +180,15 @@ void AVFImageCaptureControl::onNewViewfinderFrame(const QVideoFrame &frame)
|
||||
QtConcurrent::run(this, &AVFImageCaptureControl::makeCapturePreview,
|
||||
request,
|
||||
frame,
|
||||
m_session->activeCameraInfo(),
|
||||
m_orientationHandler.currentOrientation());
|
||||
0 /* rotation */);
|
||||
}
|
||||
|
||||
void AVFImageCaptureControl::makeCapturePreview(CaptureRequest request,
|
||||
const QVideoFrame &frame,
|
||||
AVFCameraInfo cameraInfo,
|
||||
int screenOrientation)
|
||||
int rotation)
|
||||
{
|
||||
QTransform transform;
|
||||
screenOrientation = 360 - screenOrientation;
|
||||
if (cameraInfo.position == QCamera::FrontFace)
|
||||
transform.rotate((screenOrientation + cameraInfo.orientation) % 360);
|
||||
else
|
||||
transform.rotate((screenOrientation + (360 - cameraInfo.orientation)) % 360);
|
||||
transform.rotate(rotation);
|
||||
|
||||
Q_EMIT imageCaptured(request.captureId, qt_imageFromVideoFrame(frame).transformed(transform));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user