Thanks for reading.
I am creating a custom camera using AVFoundation.
When I maximize the wide angle with the ultra wide angle camera (when videoZoomFactor is minimized), the wide angle field of view is narrower compared to the apple default camera.
Looking at the metadata from the album, the focal length is 13mm for the apple default camera, while it is 16mm for the one I created.
Below is an excerpt of the code.
Camera Settings
if let captureDevice = AVCaptureDevice.default(
.builtInTripleCamera,
for: .video,
position: .back
) {
self.captureDevice = captureDevice
} else if let captureDevice = AVCaptureDevice.default(
.builtInDualWideCamera,
for: .video,
position: .back
) {
self.captureDevice = captureDevice
} else if let captureDevice = AVCaptureDevice.default(
.builtInWideAngleCamera,
for: .video,
position: .back
) {
self.captureDevice = captureDevice
}
do {
let input = try AVCaptureDeviceInput(device: captureDevice)
let videoDataOutput = AVCaptureVideoDataOutput()
// Omitted
photoOutput = AVCapturePhotoOutput()
guard let photoOutput = photoOutput else { return }
photoOutput.isHighResolutionCaptureEnabled = true
session.sessionPreset = .photo
// Omitted
} catch {
}
for connection in session.connections {
connection.preferredVideoStabilizationMode = .cinematicExtended
}
zoom function
func zoom(zoomFactor: CGFloat, ramping: Bool = false) {
do {
try captureDevice?.lockForConfiguration()
self.zoomFactor = zoomFactor
if ramping {
captureDevice?.ramp(toVideoZoomFactor: zoomFactor, withRate: 10.0)
} else {
captureDevice?.videoZoomFactor = zoomFactor
}
captureDevice?.unlockForConfiguration()
} catch {
errorReportingService.reportError(error: error)
}
}
Test devices: iPhone 11, 12mini
Thanks for reading this far.
I want to make it as wide angle as the apple default camera!
This app allows for a wider angle than the one I created. So I believe there is a way.
Post
Replies
Boosts
Views
Activity
I want to store the number of images being composited with HDR in kCGImagePropertyExifSourceImageNumberOfCompositeImage.
But I don't know how to get the composite number.
Could you please tell me how to do that?
I use AVCapturePhotoOutput to take still pictures.
I print metadata with the following code.
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
guard let data = photo.fileDataRepresentation() else { return }
let ciImage = CIImage(data: data)
print(ciImage?.properties)
The following CompositeImage can be obtained
CompositeImage = 2
However, CompositeImage will always be 2 even if HDR is turned off as shown below.
device.automaticallyAdjustsVideoHDREnabled = false
device.isVideoHDREnabled = false
The expected value is 1.
Could you find the cause of this?
When using XCTestExpectation, is there a difference between writing XCTAssert in sink or after wait?
My example:
let exp = expectation(description: "test")
repository.delete(id: "2")
.sink { [unowned self] in
print("in sink closure")
XCTAssertEqual(repository.object.count, 2)
XCTAssertFalse(repository.object.contains { $0.id == "2" })
exp.fulfill()
}
.store(in: &cancellables)
wait(for: [exp], timeout: 1.0)
print("after wait")
XCTAssertEqual(repository.object.count, 2)
XCTAssertFalse(repository.object.contains { $0.id == "2" })
XCTAssert in sink succeeds, but XCTAssert after wait fails.
So I thought the code after wait would be executed without waiting for wait.
However, the console outputs the following in the following order
in sink closure
after wait
Why does XCTAssert fail after wait?
How can I add a new Package Product to a Package that has already been added?
For example:
I have been using Firebase itself, but I want to add
FirebaseCrashlytics to it.
Do I have to delete the Package and then add it again?
Xcode13.1
simulator iPhone12(iOS 15.0)
When run, simulator is external display and black screen.
I want to undo it, but I don't know how.
I/O -> External Displays -> Disabled
isSelected
When crash by assertNoFailure, I cannot see the message.
smaple code
View
import SwiftUI
struct ContentView: View {
@ObservedObject private var viewModel = ContentViewModel()
var body: some View {
Button(action: { viewModel.crash() }, label: { Text("button") })
}
}
ViewModel
import Foundation
import Combine
class ContentViewModel: ObservableObject {
var cancellables = Set<AnyCancellable>()
private enum AddOneError: Swift.Error {
case error
}
private func addOnePublisher(_ n: Int) -> AnyPublisher<Int, AddOneError> {
Deferred {
Future { (promise) in
guard n < 10 else {
promise(.failure(AddOneError.error))
return
}
promise(.success(n + 1))
}
}
.eraseToAnyPublisher()
}
func crash() {
addOnePublisher(10)
.assertNoFailure("I want to disply this message.")
.sink { (completion) in
switch completion {
case .finished:
break
case .failure(let error):
print(error)
}
} receiveValue: { (n) in
print(n)
}
.store(in: &cancellables)
}
}
when crash
if I use
.catch { error -> AnyPublisher<Int, Never> in fatalError("I can see this message") }
instead of assertNoFailure
I can see log
Fatal error: I can see this message
How can I see the prefix of assertNoFailure? And if not, when is it used?
When using VStack in a button in iOS15, alignment is buggy.
struct ContentView: View {
var body: some View {
Button(action: {}, label: {
VStack(alignment: .leading, spacing: 10) {
Text("こんにちはこんにちはこんにちは")
Text("これはテストです。これはテストです。これはテストです。これはテストです。これはテストです。これはテストです。これはテストです。これはテストです。これはテストです。")
}
})
}
}
iOS14
iOS15
I use .onInsert now.
I want to delete green (+) icon that displayed by default.
Is it possible?