質問編集履歴

3

利用規約違反

2017/09/26 05:21

投稿

giant
giant

スコア132

test CHANGED
File without changes
test CHANGED
@@ -221,5 +221,3 @@
221
221
 
222
222
 
223
223
  ```
224
-
225
- 回答と、同時にこれについて都内で3000円/時で教えてくれる人も探しています。

2

コードの追加

2017/09/26 05:21

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -60,4 +60,166 @@
60
60
 
61
61
  ```
62
62
 
63
+
64
+
65
+ ```java
66
+
67
+ //いろんなサンプルをみて試して見たのですがダメでした。
68
+
69
+ @Override
70
+
71
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
72
+
73
+ screen_width = width;
74
+
75
+ screen_height = height;
76
+
77
+ Log.e(TAG, "surfaceChanged");
78
+
79
+ }
80
+
81
+
82
+
83
+ public void drawFace(Face face) {
84
+
85
+ try {
86
+
87
+ canvas = surfaceHolder.lockCanvas();
88
+
89
+
90
+
91
+ Paint paint = new Paint();
92
+
93
+
94
+
95
+ try {
96
+
97
+ paint.setStyle(Paint.Style.STROKE);
98
+
99
+ Rect L=face.getBounds();
100
+
101
+ canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
102
+
103
+ paint.setColor(Color.GRAY);
104
+
105
+
106
+
107
+ L=faceRect2PixelRect(L);
108
+
109
+
110
+
111
+
112
+
113
+ //変換
114
+
115
+ Matrix matrix = new Matrix();
116
+
117
+ // スケールの算出
118
+
119
+ matrix.postScale(screen_width / 2000f, screen_height / 2000f);
120
+
121
+ // 座標の移動
122
+
123
+ matrix.postTranslate(screen_width / 2f, screen_height / 2f);
124
+
125
+ // Canvas の保存
126
+
127
+ int saveCount = canvas.save();
128
+
129
+ // Matrix を適用
130
+
131
+ canvas.concat(matrix);
132
+
133
+ // 描画
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ // 検出した顔を中心に矩形と認識精度を描画
144
+
145
+ float x = (L.right + L.left) / 2;
146
+
147
+ float y = (L.top + L.bottom) / 2;
148
+
149
+ String score = String.valueOf(face.getScore());
150
+
151
+ canvas.drawText(score, x, y, paint);
152
+
153
+
154
+
155
+ canvas.drawRect(L, paint);
156
+
157
+
158
+
159
+ // リストア//これ以降はcanvasを使えない
160
+
161
+ canvas.restoreToCount(saveCount);
162
+
163
+
164
+
165
+
166
+
167
+ } finally {
168
+
169
+ surfaceHolder.unlockCanvasAndPost(canvas);
170
+
171
+ }
172
+
173
+
174
+
175
+ } catch (IllegalArgumentException e) {
176
+
177
+ Log.w(TAG, e.toString());
178
+
179
+ }
180
+
181
+ }
182
+
183
+ private Rect faceRect2PixelRect(Rect L) {
184
+
185
+
186
+
187
+ Rect rectss = new Rect();
188
+
189
+
190
+
191
+
192
+
193
+ // // フロントカメラなので左右反転、portraitなので座標軸反転
194
+
195
+ // rectss.left = screen_width * (-L.top + 1000) / 2000;
196
+
197
+ // rectss.right = screen_width * (-L.bottom + 1000) / 2000;
198
+
199
+ // rectss.top = screen_height * (-L.left + 1000) / 2000;
200
+
201
+ // rectss.bottom = screen_height * (-L.right + 1000) / 2000;
202
+
203
+
204
+
205
+ // フロントカメラなので左右反転、portraitなので座標軸反転してないようにできてる?
206
+
207
+ rectss.left = screen_width * (-L.right + 1000) / 2000;
208
+
209
+ rectss.right = screen_width * (-L.left + 1000) / 2000;
210
+
211
+ rectss.top = screen_height * (-L.top + 1000) / 2000;
212
+
213
+ rectss.bottom = screen_height * (-L.bottom + 1000) / 2000;
214
+
215
+
216
+
217
+ return rectss;
218
+
219
+ }
220
+
221
+
222
+
223
+ ```
224
+
63
225
  回答と、同時にこれについて都内で3000円/時で教えてくれる人も探しています。

1

説明の追加

2017/09/23 05:13

投稿

giant
giant

スコア132

test CHANGED
File without changes
test CHANGED
@@ -59,3 +59,5 @@
59
59
  }
60
60
 
61
61
  ```
62
+
63
+ 回答と、同時にこれについて都内で3000円/時で教えてくれる人も探しています。