質問編集履歴
1
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -116,115 +116,13 @@
|
|
116
116
|
|
117
117
|
ソースコード
|
118
118
|
|
119
|
-
public void run() {
|
120
119
|
|
121
|
-
try {
|
122
|
-
|
123
|
-
ArrayList<Classifier.Recognition> results = null;
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
results = classifier.RecognizeImage(Gbitmap);
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
Gbitmap = processBitmap(Gbitmap, 304, 0);
|
132
|
-
|
133
|
-
Gbitmap = Bitmap.createBitmap(Gbitmap);
|
134
|
-
|
135
|
-
final Canvas canvas = new Canvas(Gbitmap);
|
136
|
-
|
137
|
-
final Paint paint = new Paint();
|
138
|
-
|
139
|
-
paint.setColor(Color.RED);
|
140
|
-
|
141
|
-
paint.setStyle(Paint.Style.STROKE);
|
142
|
-
|
143
|
-
paint.setStrokeWidth(2.0f);
|
144
|
-
|
145
|
-
final Paint mPaint = new Paint();
|
146
|
-
|
147
|
-
mPaint.setColor(Color.RED);
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
final Paint paint_OK = new Paint();
|
152
|
-
|
153
|
-
paint_OK.setColor(Color.rgb(0, 112, 192));
|
154
|
-
|
155
|
-
paint_OK.setStyle(Paint.Style.STROKE);
|
156
|
-
|
157
|
-
paint_OK.setStrokeWidth(2.0f);
|
158
|
-
|
159
|
-
final Paint mPaint_OK = new Paint();
|
160
|
-
|
161
|
-
mPaint_OK.setColor(Color.rgb(0, 112, 192));
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
final Paint mPaint_white = new Paint();
|
166
|
-
|
167
|
-
mPaint_white.setTextSize(20);
|
168
|
-
|
169
|
-
mPaint_white.setColor(Color.WHITE);
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
for (final Classifier.Recognition result : results) {
|
174
|
-
|
175
|
-
final RectF location = result.getLocation();
|
176
|
-
|
177
|
-
final int detectedClass = result.getdetectedClass();
|
178
|
-
|
179
|
-
final float confidence = result.getConfidence();
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
final int confidence_int;
|
184
|
-
|
185
|
-
if(confidence>=0.95){
|
186
|
-
|
187
|
-
confidence_int=99;
|
188
|
-
|
189
|
-
}else{
|
190
|
-
|
191
|
-
confidence_int=Math.round(confidence*10)*10;
|
192
|
-
|
193
|
-
}
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
if (location != null && result.getConfidence() >= 0.1) {
|
198
|
-
|
199
|
-
if(classifier.mLabelList.get(detectedClass).contains("OK")){
|
200
|
-
|
201
|
-
canvas.drawRect(location.left/2, location.top/2, location.right/2, location.bottom/2, paint_OK);
|
202
|
-
|
203
|
-
canvas.drawRect(location.left/2, location.top/2, (location.left+100)/2, (location.top-30)/2, mPaint_OK);
|
204
|
-
|
205
|
-
canvas.drawText(String.valueOf(confidence_int), location.left/2, location.top/2, mPaint_white);
|
206
|
-
|
207
|
-
}else{
|
208
|
-
|
209
|
-
canvas.drawRect(location.left/2, location.top/2, location.right/2, location.bottom/2, paint);
|
210
|
-
|
211
|
-
canvas.drawRect(location.left/2, location.top/2, (location.left+100)/2, (location.top-30)/2, mPaint);
|
212
|
-
|
213
|
-
canvas.drawText(String.valueOf(confidence_int), location.left/2, location.top/2, mPaint_white);
|
214
|
-
|
215
|
-
}
|
216
|
-
|
217
|
-
}
|
218
|
-
|
219
|
-
}
|
220
120
|
|
221
121
|
mHandler.post(new Runnable() {
|
222
122
|
|
223
123
|
@Override
|
224
124
|
|
225
125
|
public void run() {
|
226
|
-
|
227
|
-
// mContentView.setImageBitmap(resized_image);
|
228
126
|
|
229
127
|
}
|
230
128
|
|
@@ -256,8 +154,6 @@
|
|
256
154
|
|
257
155
|
Intent newintent = new Intent(getApplication(), men2Activity.class);
|
258
156
|
|
259
|
-
// Bitmap croppedBitmap = processBitmap(resized_image, 300);
|
260
|
-
|
261
157
|
newintent.putExtra("resized_image", Gbitmap);
|
262
158
|
|
263
159
|
startActivity(newintent); <------ここでエラーが発生してしまっています。
|