OPC(Olympus Air)用望遠鏡アプリ。
Revision | 6bb3cf7c73aa9f1ad35eed444e80aab1c1072ee6 (tree) |
---|---|
Zeit | 2018-10-05 00:05:11 |
Autor | MRSa <mrsa@myad...> |
Commiter | MRSa |
シャッター半押し機能を追加する途中。
@@ -10,4 +10,5 @@ public interface IFocusingControl | ||
10 | 10 | { |
11 | 11 | boolean driveAutoFocus(MotionEvent motionEvent); |
12 | 12 | void unlockAutoFocus(); |
13 | + void halfPressShutter(boolean isPressed); | |
13 | 14 | } |
@@ -69,4 +69,39 @@ public class OlyCameraFocusControl implements IFocusingControl | ||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | + @Override | |
73 | + public void halfPressShutter(boolean isPressed) | |
74 | + { | |
75 | + if (isPressed) | |
76 | + { | |
77 | + // 中心にフォーカスを合わせる | |
78 | + if (frameDisplay != null) | |
79 | + { | |
80 | + Thread thread = new Thread(new Runnable() { | |
81 | + @Override | |
82 | + public void run() { | |
83 | + PointF point = new PointF(0.5f, 0.5f); | |
84 | + if (frameDisplay.isContainsPoint(point)) | |
85 | + { | |
86 | + afControl.lockAutoFocus(point); | |
87 | + } | |
88 | + } | |
89 | + }); | |
90 | + try | |
91 | + { | |
92 | + thread.start(); | |
93 | + } | |
94 | + catch (Exception e) | |
95 | + { | |
96 | + e.printStackTrace(); | |
97 | + } | |
98 | + } | |
99 | + } | |
100 | + else | |
101 | + { | |
102 | + // フォーカスを解除する | |
103 | + unlockAutoFocus(); | |
104 | + } | |
105 | + } | |
106 | + | |
72 | 107 | } |
@@ -50,4 +50,10 @@ public class RicohGr2CameraFocusControl implements IFocusingControl | ||
50 | 50 | { |
51 | 51 | afControl.unlockAutoFocus(); |
52 | 52 | } |
53 | + | |
54 | + @Override | |
55 | + public void halfPressShutter(boolean isPressed) | |
56 | + { | |
57 | + afControl.halfPressShutter(isPressed); | |
58 | + } | |
53 | 59 | } |
@@ -5,7 +5,6 @@ import android.graphics.RectF; | ||
5 | 5 | import android.support.annotation.NonNull; |
6 | 6 | import android.util.Log; |
7 | 7 | |
8 | -import net.osdn.gokigen.a01d.camera.sony.operation.takepicture.SonyAutoFocusControl; | |
9 | 8 | import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient; |
10 | 9 | import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay; |
11 | 10 | import net.osdn.gokigen.a01d.liveview.IIndicatorControl; |
@@ -17,8 +16,9 @@ public class RicohGr2AutoFocusControl | ||
17 | 16 | private static final String TAG = RicohGr2AutoFocusControl.class.getSimpleName(); |
18 | 17 | private final IIndicatorControl indicator; |
19 | 18 | private final IAutoFocusFrameDisplay frameDisplayer; |
20 | - private String lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/lock"; | |
19 | + private String lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/lock"; // Pentax機の場合は /v1/lens/focus | |
21 | 20 | private String unlockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/unlock"; |
21 | + private String halfPressShutterUrl = "http://192.168.0.1/_gr"; | |
22 | 22 | private int timeoutMs = 6000; |
23 | 23 | |
24 | 24 |
@@ -132,6 +132,43 @@ public class RicohGr2AutoFocusControl | ||
132 | 132 | * |
133 | 133 | * |
134 | 134 | */ |
135 | + public void halfPressShutter(final boolean isPressed) | |
136 | + { | |
137 | + Log.v(TAG, "halfPressShutter() " + isPressed); | |
138 | + try | |
139 | + { | |
140 | + Thread thread = new Thread(new Runnable() | |
141 | + { | |
142 | + @Override | |
143 | + public void run() | |
144 | + { | |
145 | + try | |
146 | + { | |
147 | + String postData = (isPressed) ? "cmd=baf 1" : "cmd=baf 0"; | |
148 | + String result = SimpleHttpClient.httpPost(halfPressShutterUrl, postData, timeoutMs); | |
149 | + if ((result == null)||(result.length() < 1)) | |
150 | + { | |
151 | + Log.v(TAG, "halfPressShutter() [" + isPressed + "] reply is null."); | |
152 | + } | |
153 | + } | |
154 | + catch (Exception e) | |
155 | + { | |
156 | + e.printStackTrace(); | |
157 | + } | |
158 | + } | |
159 | + }); | |
160 | + thread.start(); | |
161 | + } | |
162 | + catch (Exception e) | |
163 | + { | |
164 | + e.printStackTrace(); | |
165 | + } | |
166 | + } | |
167 | + | |
168 | + /** | |
169 | + * | |
170 | + * | |
171 | + */ | |
135 | 172 | private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration) |
136 | 173 | { |
137 | 174 | frameDisplayer.showFocusFrame(rect, status, duration); |
@@ -65,4 +65,18 @@ public class SonyCameraFocusControl implements IFocusingControl | ||
65 | 65 | e.printStackTrace(); |
66 | 66 | } |
67 | 67 | } |
68 | + | |
69 | + @Override | |
70 | + public void halfPressShutter(boolean isPressed) | |
71 | + { | |
72 | + Log.v(TAG, "halfPressShutter() " + isPressed); | |
73 | + try | |
74 | + { | |
75 | + afControl.halfPressShutter(isPressed); | |
76 | + } | |
77 | + catch (Exception e) | |
78 | + { | |
79 | + e.printStackTrace(); | |
80 | + } | |
81 | + } | |
68 | 82 | } |
@@ -111,6 +111,47 @@ public class SonyAutoFocusControl | ||
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
114 | + * シャッター半押し処理 | |
115 | + * | |
116 | + */ | |
117 | + public void halfPressShutter(final boolean isPressed) | |
118 | + { | |
119 | + Log.v(TAG, "halfPressShutter() : " + isPressed); | |
120 | + if (cameraApi == null) | |
121 | + { | |
122 | + Log.v(TAG, "ISonyCameraApi is null..."); | |
123 | + return; | |
124 | + } | |
125 | + try | |
126 | + { | |
127 | + Thread thread = new Thread(new Runnable() | |
128 | + { | |
129 | + @Override | |
130 | + public void run() | |
131 | + { | |
132 | + try | |
133 | + { | |
134 | + JSONObject resultsObj = (isPressed) ? cameraApi.actHalfPressShutter() : cameraApi.cancelHalfPressShutter(); | |
135 | + if (resultsObj == null) | |
136 | + { | |
137 | + Log.v(TAG, "lockAutoFocus() [" + isPressed + "] reply is null."); | |
138 | + } | |
139 | + } | |
140 | + catch (Exception e) | |
141 | + { | |
142 | + e.printStackTrace(); | |
143 | + } | |
144 | + } | |
145 | + }); | |
146 | + thread.start(); | |
147 | + } | |
148 | + catch (Exception e) | |
149 | + { | |
150 | + e.printStackTrace(); | |
151 | + } | |
152 | + } | |
153 | + | |
154 | + /** | |
114 | 155 | * |
115 | 156 | * |
116 | 157 | */ |
@@ -21,6 +21,9 @@ public interface ISonyCameraApi | ||
21 | 21 | JSONObject getTouchAFPosition(); |
22 | 22 | JSONObject cancelTouchAFPosition(); |
23 | 23 | |
24 | + JSONObject actHalfPressShutter(); | |
25 | + JSONObject cancelHalfPressShutter(); | |
26 | + | |
24 | 27 | JSONObject setFocusMode(String focusMode); |
25 | 28 | JSONObject getFocusMode(); |
26 | 29 | JSONObject getSupportedFocusMode(); |
@@ -209,6 +209,34 @@ class SonyCameraApi implements ISonyCameraApi | ||
209 | 209 | } |
210 | 210 | |
211 | 211 | @Override |
212 | + public JSONObject actHalfPressShutter() | |
213 | + { | |
214 | + try | |
215 | + { | |
216 | + return (communicateJSON("camera", "actHalfPressShutter", new JSONArray(), "1.0", -1)); | |
217 | + } | |
218 | + catch (Exception e) | |
219 | + { | |
220 | + e.printStackTrace(); | |
221 | + } | |
222 | + return (new JSONObject()); | |
223 | + } | |
224 | + | |
225 | + @Override | |
226 | + public JSONObject cancelHalfPressShutter() | |
227 | + { | |
228 | + try | |
229 | + { | |
230 | + return (communicateJSON("camera", "cancelHalfPressShutter", new JSONArray(), "1.0", -1)); | |
231 | + } | |
232 | + catch (Exception e) | |
233 | + { | |
234 | + e.printStackTrace(); | |
235 | + } | |
236 | + return (new JSONObject()); | |
237 | + } | |
238 | + | |
239 | + @Override | |
212 | 240 | public JSONObject setFocusMode(String focusMode) |
213 | 241 | { |
214 | 242 | try |
@@ -143,6 +143,11 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi | ||
143 | 143 | actionZoomout(); |
144 | 144 | break; |
145 | 145 | |
146 | + case R.id.focus_indicator: | |
147 | + // フォーカスインジケータをクリックした | |
148 | + actionFocusButton(); | |
149 | + break; | |
150 | + | |
146 | 151 | default: |
147 | 152 | Log.v(TAG, "onClick() : " + id); |
148 | 153 | break; |
@@ -246,6 +251,17 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi | ||
246 | 251 | } |
247 | 252 | |
248 | 253 | /** |
254 | + * フォーカスボタンが押されたとき... | |
255 | + * | |
256 | + */ | |
257 | + private void actionFocusButton() | |
258 | + { | |
259 | + | |
260 | + | |
261 | + | |
262 | + } | |
263 | + | |
264 | + /** | |
249 | 265 | * お気に入り設定ダイアログの表示 |
250 | 266 | * |
251 | 267 | */ |
@@ -151,6 +151,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo | ||
151 | 151 | view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener); |
152 | 152 | view.findViewById(R.id.btn_zoomin).setOnClickListener(onClickTouchListener); |
153 | 153 | view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener); |
154 | + view.findViewById(R.id.focus_indicator).setOnClickListener(onClickTouchListener); | |
154 | 155 | |
155 | 156 | manualFocus = view.findViewById(R.id.focusing_button); |
156 | 157 | changeLiveViewScale = view.findViewById(R.id.live_view_scale_button); |
@@ -0,0 +1,9 @@ | ||
1 | +<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | + android:width="24dp" | |
3 | + android:height="24dp" | |
4 | + android:viewportWidth="24.0" | |
5 | + android:viewportHeight="24.0"> | |
6 | + <path | |
7 | + android:fillColor="#FF000000" | |
8 | + android:pathData="M12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2v4h2L5,5zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4z"/> | |
9 | +</vector> |
@@ -0,0 +1,9 @@ | ||
1 | +<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | + android:width="24dp" | |
3 | + android:height="24dp" | |
4 | + android:viewportWidth="24.0" | |
5 | + android:viewportHeight="24.0"> | |
6 | + <path | |
7 | + android:fillColor="#FF000000" | |
8 | + android:pathData="M3,5v4h2L5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2z"/> | |
9 | +</vector> |
@@ -123,13 +123,31 @@ | ||
123 | 123 | android:visibility="visible" |
124 | 124 | /> |
125 | 125 | |
126 | + <ImageView | |
127 | + android:id="@+id/focus_indicator" | |
128 | + android:layout_width="wrap_content" | |
129 | + android:layout_height="wrap_content" | |
130 | + android:layout_alignLeft="@id/live_view_scale_button" | |
131 | + android:layout_alignStart="@id/live_view_scale_button" | |
132 | + android:layout_marginStart="8pt" | |
133 | + android:layout_marginLeft="8pt" | |
134 | + android:layout_marginBottom="3pt" | |
135 | + android:layout_above="@id/live_view_scale_button" | |
136 | + android:clickable="true" | |
137 | + android:contentDescription="@string/button" | |
138 | + android:focusable="true" | |
139 | + android:gravity="center" | |
140 | + android:scaleType="fitCenter" | |
141 | + android:src="@drawable/ic_crop_free_black_24dp" | |
142 | + android:visibility="visible" /> | |
143 | + | |
126 | 144 | <TextView |
127 | 145 | android:id="@+id/focal_length_with_digital_zoom_view" |
128 | 146 | android:layout_width="match_parent" |
129 | 147 | android:layout_height="wrap_content" |
130 | 148 | android:layout_marginRight="2pt" |
131 | 149 | android:layout_marginEnd="2pt" |
132 | - android:layout_above="@id/live_view_scale_button" | |
150 | + android:layout_above="@id/focus_indicator" | |
133 | 151 | android:layout_alignLeft="@id/live_view_scale_button" |
134 | 152 | android:layout_alignStart="@id/live_view_scale_button" |
135 | 153 | android:layout_marginLeft="4pt" |
@@ -51,10 +51,10 @@ | ||
51 | 51 | <ImageView |
52 | 52 | android:id="@+id/focusing_button" |
53 | 53 | android:layout_width="wrap_content" |
54 | - android:layout_height="match_parent" | |
54 | + android:layout_height="wrap_content" | |
55 | 55 | android:layout_alignParentLeft="true" |
56 | 56 | android:layout_alignParentStart="true" |
57 | - android:layout_alignParentTop="true" | |
57 | + android:layout_alignParentBottom="true" | |
58 | 58 | android:layout_marginLeft="2pt" |
59 | 59 | android:layout_marginStart="2pt" |
60 | 60 | android:clickable="true" |
@@ -144,6 +144,23 @@ | ||
144 | 144 | android:visibility="visible" |
145 | 145 | android:src="@drawable/ic_zoom_in_black_24dp" /> |
146 | 146 | |
147 | + <ImageView | |
148 | + android:id="@+id/focus_indicator" | |
149 | + android:layout_width="wrap_content" | |
150 | + android:layout_height="wrap_content" | |
151 | + android:layout_alignTop="@id/live_view_scale_button" | |
152 | + android:layout_alignParentStart="true" | |
153 | + android:layout_alignParentLeft="true" | |
154 | + android:layout_marginStart="4pt" | |
155 | + android:layout_marginLeft="4pt" | |
156 | + android:clickable="true" | |
157 | + android:contentDescription="@string/button" | |
158 | + android:focusable="true" | |
159 | + android:gravity="center" | |
160 | + android:scaleType="fitEnd" | |
161 | + android:src="@drawable/ic_crop_free_black_24dp" | |
162 | + android:visibility="visible" /> | |
163 | + | |
147 | 164 | </RelativeLayout> |
148 | 165 | |
149 | 166 | <RelativeLayout |