記錄學習內容。看網路上大大們的文章和影片,做些紀錄。
以下內容還不太懂。
來閱讀這篇大大的程式,先來查看不懂的地方 。還沒實作:
CameraView/Sources/CameraView/CameraView.swift
private struct PreviewHolder: UIViewRepresentable
private var delegate: CameraViewDelegate?
private var cameraType: AVCaptureDevice.DeviceType
private var cameraPosition: AVCaptureDevice.Position
private var view: PreviewView
CameraViewDelegate 是一個作者寫的介面:
//
// CameraViewDelegate.swift
//
//
// Created by Brett Fazio on 3/21/20.
//
import Foundation
public protocol CameraViewDelegate {
func cameraAccessGranted()
func cameraAccessDenied()
func noCameraDetected()
func cameraSessionStarted()
}
cameraAccessGranted() --- >相機權限允許
cameraAccessDenied() ---- > 相機權限否定
noCameraDetected() --- > 手機沒相機
cameraSessionStarted() --- >還不確定,大概是相機開始
接著來看
builtInTripleCamera (三鏡頭)
A device that consists of three cameras of fixed focal length, one ultrawide angle(超廣角?), one wide angle(廣角?), and one telephoto(長焦?)
三鏡頭參考:
小丰子3C俱樂部
angle(超廣角?), one wide angle(廣角?), and one telephoto(長焦?) 的意思應該是指
[廣角RGB+超廣角RGB+望遠Tele]
作者寫的這段:
private class PreviewView: UIView, AVCapturePhotoCaptureDelegate {
裡面有處理權限:
requestAccess(for:completionHandler:)
Day 22: 再次向使用者請求開啟功能的權限。
有 input 、 output設定:
Input 是指這個(相機的前後鏡、幾個鏡頭、video就是錄影或拍照):
let videoDevice = AVCaptureDevice.default(cameraType,
for: .video, position: cameraPosition)
output設定指的是AVCapturePhotoOutput() ,用來判斷輸出的圖片有甚麼功能,像是高解析度、LivePhoto:
photoOutput!.isHighResolutionCaptureEnabled = true
photoOutput!.isLivePhotoCaptureEnabled = photoOutput!.isLivePhotoCaptureSupported
開始相機,應該就是指:
captureSession?.startRunning()
https://developer.apple.com/documentation/avfoundation/avcapturesession
You invoke startRunning() to start the flow of data from the inputs to the outputs, and invoke stopRunning() to stop the flow.
AVCapturePhotoSettings 代表一些 拍照時的設定 ,
像是要不要開閃光、設定圖片類型(jpeg、hevc):
var flashMode: AVCaptureDevice.FlashMode
A setting for whether to fire the flash when capturing photos.
https://developer.apple.com/documentation/avfoundation/avvideocodectype
沒有png?
static let jpeg: AVVideoCodecType
The JPEG video codec.
static let hevc: AVVideoCodecType
The HEVC video codec.
什麼是HEVC ?
[Windows] 如何在Windows10安裝免費模組讀取iPhone的HEIC格式的影片及圖片?
蘋果的 照片-- >.HEIF(高效率影像檔案格式)
影片-- >.HEVC(高效率視訊編碼),亦稱為 H.265
跟這個有關:
previewCGImageRepresentation
https://developer.apple.com/documentation/avfoundation/avcapturephoto/2873945-previewcgimagerepresentation?language=objc
先跳過。
https://developer.apple.com/documentation/uikit/uiview/1622433-didmovetosuperview
24-Any & AnyObject types | is typeCheck operator | as? as! type conversion(casting)operator| Swift
https://www.youtube.com/watch?v=ZryV2Dj2XSA&ab_channel=Appleapps
iOS App 實作(12)錄音功能(AVAudioRecorder)
https://ithelp.ithome.com.tw/articles/10195621
Voice Recorder App In SwiftUI – #1 Implementing The Audio Recorder
https://blckbirds.com/post/voice-recorder-app-in-swiftui-1/
Audio Visualization in Swift Using Metal and Accelerate (Part 1)
https://betterprogramming.pub/audio-visualization-in-swift-using-metal-accelerate-part-1-390965c095d7