我有一个应用程序,应该采取3张照片的用户在一个时间间隔(说200毫秒)。图片时,用户点击一个按钮。
现在,为了确保每200毫秒拍摄一次照片,我想访问照片拍摄的时间,但我正在与文档作斗争。
以下是我正在使用的:
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
print("this is the call Back called when photo is done processing")
if let error = error {
print("error occured : \(error.localizedDescription)")
}
let dataProvider = CGDataProvider(data: dataImage as CFData)
let cgImageRef: CGImage! = CGImage(jpegDataProviderSource: dataProvider!, decode: nil, shouldInterpolate: true, intent: .defaultIntent)
let image = UIImage(cgImage: cgImageRef, scale: 1.0, orientation: UIImage.Orientation.right)
// do any of the above stuff contain time of when image was created? or can I derive it from any of them
}
2条答案
按热度按时间wgmfuz8q1#
实现
photoOutput(_:didCapturePhotoFor:)
并检查Date()
。4ktjp1zp2#
photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?)
委托方法内部您可以访问
photo.timestamp
属性。它不会给予你一个绝对的纪元时间,但你可以使用该值来检查两个连续捕获之间是否遵守了200ms的间隔。