036856aed5
* Move everything into package * Remove .DS_Store * Move scripts and eslintrc to package * Create CODE_OF_CONDUCT.md * fix some links * Update all links (I think) * Update generated docs * Update notice-yarn-changes.yml * Update validate-android.yml * Update validate-cpp.yml * Delete notice-yarn-changes.yml * Update validate-cpp.yml * Update validate-cpp.yml * Update validate-js.yml * Update validate-cpp.yml * Update validate-cpp.yml * wrong c++ style * Revert "wrong c++ style" This reverts commit 55a3575589c6f13f8b05134d83384f55e0601ab2.
46 lines
1.3 KiB
Swift
46 lines
1.3 KiB
Swift
//
|
|
// CameraView+Orientation.swift
|
|
// VisionCamera
|
|
//
|
|
// Created by Marc Rousavy on 04.01.22.
|
|
// Copyright © 2022 mrousavy. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
extension CameraView {
|
|
/// Orientation of the input connection (preview)
|
|
private var inputOrientation: UIInterfaceOrientation {
|
|
return .portrait
|
|
}
|
|
|
|
// Orientation of the output connections (photo, video, frame processor)
|
|
var outputOrientation: UIInterfaceOrientation {
|
|
if let userOrientation = orientation as String?,
|
|
let parsedOrientation = try? UIInterfaceOrientation(withString: userOrientation) {
|
|
// user is overriding output orientation
|
|
return parsedOrientation
|
|
} else {
|
|
// use same as input orientation
|
|
return inputOrientation
|
|
}
|
|
}
|
|
|
|
func updateOrientation() {
|
|
// Updates the Orientation for all rotable
|
|
let isMirrored = videoDeviceInput?.device.position == .front
|
|
|
|
let connectionOrientation = outputOrientation
|
|
captureSession.outputs.forEach { output in
|
|
output.connections.forEach { connection in
|
|
if connection.isVideoMirroringSupported {
|
|
connection.automaticallyAdjustsVideoMirroring = false
|
|
connection.isVideoMirrored = isMirrored
|
|
}
|
|
connection.setInterfaceOrientation(connectionOrientation)
|
|
}
|
|
}
|
|
}
|
|
}
|