LoginSignup
0
3

More than 1 year has passed since last update.

iOSでカメラのフォーカス距離(焦点距離)を固定する方法

Last updated at Posted at 2021-05-26

iOS8以降からフォーカス距離の固定が可能になりました。

camera.swift
var camera: AVCaptureDevice

// 略

do {
  // AVCaptureDeviceをロックして設定
  try camera.lockForConfiguration()
  // 現在のフォーカス(焦点)距離
  print("\(camera.lensPosition)")
  // フォーカス(焦点)距離設定(0.0~1.0の間)
  camera.setFocusModeLocked(lensPosition: 0.8) { _ in
    // フォーカス(焦点)距離が固定されたら呼ばれるコールバック
    print("\(camera.lensPosition)")
  }
  camera.unlockForConfiguration()
} catch _ {
}
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3