質問編集履歴

4

コードの編集

2017/02/13 11:25

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -27,8 +27,6 @@
27
27
          do {
28
28
 
29
29
              try myDevice.lockForConfiguration()
30
-
31
-             // tapで設定された値で撮影する
32
30
 
33
31
              myDevice.setExposureModeCustomWithDuration(AVCaptureExposureDurationCurrent, iso: curentISO, completionHandler: {(time) -> Void in
34
32
 

3

コード修正

2017/02/13 11:25

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -10,10 +10,6 @@
10
10
 
11
11
 
12
12
 
13
- 色々調べて、CMSampleBufferGetAudioBufferListWithRetainedBlockBufferという関数を使うのだと出てきましたが、これはキャプチャした後にUIImageからexif情報を読み出すためのものなのでしょうか。
14
-
15
-
16
-
17
13
  宜しくお願いします。
18
14
 
19
15
 
@@ -22,85 +18,57 @@
22
18
 
23
19
  ```Swift3
24
20
 
21
+         let maxISO = myDevice.activeFormat.maxISO
25
22
 
23
+         let minISO = myDevice.activeFormat.minISO
26
24
 
27
- // タップで露出を合わせる
28
-
29
- var adjustingExposure: Bool!
30
-
31
-     func focusWithMode(focusMode : AVCaptureFocusMode, exposeWithMode expusureMode :AVCaptureExposureMode, atDevicePoint point:CGPoint, motiorSubjectAreaChange monitorSubjectAreaChange:Bool) {
32
-
33
-         DispatchQueue.main.async(execute: {
34
-
35
-             let device : AVCaptureDevice = self.myDevice
25
+         let currentISO = (maxISO + minISO)/2
36
-
37
-             do {
38
-
39
-                 try device.lockForConfiguration()
40
-
41
-                 if(device.isExposurePointOfInterestSupported && device.isExposureModeSupported(expusureMode)) {
42
-
43
-                     self.adjustingExposure = true
44
-
45
-                     device.exposurePointOfInterest = point
46
-
47
-                     device.exposureMode = expusureMode
48
-
49
-                 }
50
-
51
-                 device.isSubjectAreaChangeMonitoringEnabled = monitorSubjectAreaChange
52
-
53
-                 device.unlockForConfiguration()
54
-
55
-             } catch let error as NSError {
56
-
57
-                 print(error.debugDescription)
58
-
59
-             }
60
-
61
-         })
62
-
63
-     }
64
-
65
-     
66
-
67
-         func observeValueForKeyPath(keyPath: String, ofObject object: Any, change: [NSKeyValueChangeKey : Any], context: UnsafeMutableRawPointer) {
68
-
69
-         if !self.adjustingExposure {
70
-
71
-             return
72
-
73
-         }
74
-
75
-         if keyPath == "adjustingExposure" {
76
-
77
-             let isNew = change[NSKeyValueChangeKey.newKey] as! Bool
78
-
79
-             if !isNew {
80
-
81
-                 self.adjustingExposure = false
82
-
83
-             }
84
-
85
-         }
86
26
 
87
27
          do {
88
28
 
89
29
              try myDevice.lockForConfiguration()
90
30
 
31
+             // tapで設定された値で撮影する
32
+
33
+             myDevice.setExposureModeCustomWithDuration(AVCaptureExposureDurationCurrent, iso: curentISO, completionHandler: {(time) -> Void in
34
+
35
+             })
36
+
37
+             if var _:AVCaptureConnection? = myOutput.connection(withMediaType: AVMediaTypeVideo) {
38
+
39
+                 UIImageWriteToSavedPhotosAlbum(self.imageView.image!, self, nil, nil)
40
+
41
+             }
42
+
91
-             myDevice.exposureMode = AVCaptureExposureMode.locked
43
+             myDevice.setExposureModeCustomWithDuration(AVCaptureExposureDurationCurrent, iso: maxISO, completionHandler: {(time) -> Void in
44
+
45
+             })
46
+
47
+             if var _:AVCaptureConnection? = myOutput.connection(withMediaType: AVMediaTypeVideo) {
48
+
49
+                 UIImageWriteToSavedPhotosAlbum(self.imageView.image!, self, nil, nil)
50
+
51
+             }
52
+
53
+             myDevice.setExposureModeCustomWithDuration(AVCaptureExposureDurationCurrent, iso: minISO, completionHandler: {(time) -> Void in
54
+
55
+             })
56
+
57
+             if var _:AVCaptureConnection? = myOutput.connection(withMediaType: AVMediaTypeVideo) {
58
+
59
+                 UIImageWriteToSavedPhotosAlbum(self.imageView.image!, self, nil, nil)
60
+
61
+             }
92
62
 
93
63
              myDevice.unlockForConfiguration()
94
64
 
95
-         } catch let error as NSError {
65
+         } catch let error {
96
66
 
97
-                 print(error.debugDescription)
67
+             print("lock error: \(error)")
98
68
 
99
69
          }
100
70
 
101
-     }
71
+    
102
-
103
-
104
72
 
105
73
 
106
74
 

2

2017/02/13 11:20

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -104,72 +104,4 @@
104
104
 
105
105
 
106
106
 
107
- // 露出時間
108
-
109
-         let myExposure:Float = //ここに反映させたい
110
-
111
-         let Exposure1 = myExposure * 2
112
-
113
-         let Exposure2 = myExposure / 2
114
-
115
-         do {
116
-
117
-             try myDevice.lockForConfiguration()
118
-
119
-             myDevice.exposureMode = AVCaptureExposureMode.locked
120
-
121
-             // tapで設定された値で撮影
122
-
123
-             myDevice.setExposureTargetBias(myExposure, completionHandler: {(time) -> Void in
124
-
125
-             })
126
-
127
-             if var _:AVCaptureConnection? = myOutput.connection(withMediaType: AVMediaTypeVideo) {
128
-
129
-                 UIImageWriteToSavedPhotosAlbum(self.imageView.image!, self, nil, nil)
130
-
131
-             }
132
-
133
-              print("myExposure: \(myExposure)")
134
-
135
-             // Exposure1
136
-
137
-             myDevice.setExposureTargetBias(Exposure1, completionHandler: {(time) -> Void in
138
-
139
-             })
140
-
141
-             if var _:AVCaptureConnection? = myOutput.connection(withMediaType: AVMediaTypeVideo) {
142
-
143
-                 UIImageWriteToSavedPhotosAlbum(self.imageView.image!, self, nil, nil)
144
-
145
-             }
146
-
147
-              print("Exposure1: \(Exposure1)")
148
-
149
-             // Exposure2で撮影する
150
-
151
-             myDevice.setExposureTargetBias(Exposure2, completionHandler: {(time) -> Void in
152
-
153
-             })
154
-
155
-  
156
-
157
-             if var _:AVCaptureConnection? = myOutput.connection(withMediaType: AVMediaTypeVideo) {
158
-
159
-                 UIImageWriteToSavedPhotosAlbum(self.imageView.image!, self, nil, nil)
160
-
161
-             }
162
-
163
-             print("Exposure2: \(Exposure2)")
164
-
165
-             myDevice.unlockForConfiguration()
166
-
167
-         } catch let error {
168
-
169
-             print("lock error: \(error)")
170
-
171
-         }
172
-
173
-
174
-
175
107
  ```

1

ためしたこと

2017/02/10 03:02

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -7,6 +7,10 @@
7
7
  その露出時間での撮影と、その露出時間から±1の露出時間での撮影を行いたいです。
8
8
 
9
9
  そこでカメラ画面をタップしたとき(キャプチャする前)の露光時間を取得したいのですが、やり方がわかりません。
10
+
11
+
12
+
13
+ 色々調べて、CMSampleBufferGetAudioBufferListWithRetainedBlockBufferという関数を使うのだと出てきましたが、これはキャプチャした後にUIImageからexif情報を読み出すためのものなのでしょうか。
10
14
 
11
15
 
12
16
 
@@ -169,9 +173,3 @@
169
173
 
170
174
 
171
175
  ```
172
-
173
-
174
-
175
- ###試したこと
176
-
177
- 色々調べて、CMSampleBufferGetAudioBufferListWithRetainedBlockBufferという関数を使うのだと出てきましたが、これはキャプチャした後にUIImageからexif情報を読み出すためのものなのでしょうか。