質問編集履歴
1
コードの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -57,61 +57,10 @@
|
|
57
57
|
|
58
58
|
java
|
59
59
|
ソースコード
|
60
|
-
public void run() {
|
61
|
-
try {
|
62
|
-
ArrayList<Classifier.Recognition> results = null;
|
63
60
|
|
64
|
-
results = classifier.RecognizeImage(Gbitmap);
|
65
|
-
|
66
|
-
Gbitmap = processBitmap(Gbitmap, 304, 0);
|
67
|
-
Gbitmap = Bitmap.createBitmap(Gbitmap);
|
68
|
-
final Canvas canvas = new Canvas(Gbitmap);
|
69
|
-
final Paint paint = new Paint();
|
70
|
-
paint.setColor(Color.RED);
|
71
|
-
paint.setStyle(Paint.Style.STROKE);
|
72
|
-
paint.setStrokeWidth(2.0f);
|
73
|
-
final Paint mPaint = new Paint();
|
74
|
-
mPaint.setColor(Color.RED);
|
75
|
-
|
76
|
-
final Paint paint_OK = new Paint();
|
77
|
-
paint_OK.setColor(Color.rgb(0, 112, 192));
|
78
|
-
paint_OK.setStyle(Paint.Style.STROKE);
|
79
|
-
paint_OK.setStrokeWidth(2.0f);
|
80
|
-
final Paint mPaint_OK = new Paint();
|
81
|
-
mPaint_OK.setColor(Color.rgb(0, 112, 192));
|
82
|
-
|
83
|
-
final Paint mPaint_white = new Paint();
|
84
|
-
mPaint_white.setTextSize(20);
|
85
|
-
mPaint_white.setColor(Color.WHITE);
|
86
|
-
|
87
|
-
for (final Classifier.Recognition result : results) {
|
88
|
-
final RectF location = result.getLocation();
|
89
|
-
final int detectedClass = result.getdetectedClass();
|
90
|
-
final float confidence = result.getConfidence();
|
91
|
-
|
92
|
-
final int confidence_int;
|
93
|
-
if(confidence>=0.95){
|
94
|
-
confidence_int=99;
|
95
|
-
}else{
|
96
|
-
confidence_int=Math.round(confidence*10)*10;
|
97
|
-
}
|
98
|
-
|
99
|
-
if (location != null && result.getConfidence() >= 0.1) {
|
100
|
-
if(classifier.mLabelList.get(detectedClass).contains("OK")){
|
101
|
-
canvas.drawRect(location.left/2, location.top/2, location.right/2, location.bottom/2, paint_OK);
|
102
|
-
canvas.drawRect(location.left/2, location.top/2, (location.left+100)/2, (location.top-30)/2, mPaint_OK);
|
103
|
-
canvas.drawText(String.valueOf(confidence_int), location.left/2, location.top/2, mPaint_white);
|
104
|
-
}else{
|
105
|
-
canvas.drawRect(location.left/2, location.top/2, location.right/2, location.bottom/2, paint);
|
106
|
-
canvas.drawRect(location.left/2, location.top/2, (location.left+100)/2, (location.top-30)/2, mPaint);
|
107
|
-
canvas.drawText(String.valueOf(confidence_int), location.left/2, location.top/2, mPaint_white);
|
108
|
-
}
|
109
|
-
}
|
110
|
-
}
|
111
61
|
mHandler.post(new Runnable() {
|
112
62
|
@Override
|
113
63
|
public void run() {
|
114
|
-
// mContentView.setImageBitmap(resized_image);
|
115
64
|
}
|
116
65
|
});
|
117
66
|
|
@@ -127,7 +76,6 @@
|
|
127
76
|
//run()の中の処理はメインスレッドで動作されます。
|
128
77
|
public void run() {
|
129
78
|
Intent newintent = new Intent(getApplication(), men2Activity.class);
|
130
|
-
// Bitmap croppedBitmap = processBitmap(resized_image, 300);
|
131
79
|
newintent.putExtra("resized_image", Gbitmap);
|
132
80
|
startActivity(newintent); <------ここでエラーが発生してしまっています。
|
133
81
|
|