質問編集履歴
3
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
FATAL EXCEPTION: main
|
8
8
|
|
9
|
-
Process: com.example.yser.
|
9
|
+
Process: com.example.yser., PID: 21654
|
10
10
|
|
11
11
|
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.yser.basketballtimer/com.example.yser.basketballtimer.MainActivity}: java.lang.InstantiationException: class com.example.yser.basketballtimer.MainActivity cannot be instantiated
|
12
12
|
|
@@ -59,209 +59,3 @@
|
|
59
59
|
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
|
60
60
|
|
61
61
|
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
追記:ソースコードはこれです。ストリーム配信した映像から円を検出しようとしています。
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
import android.os.Bundle;
|
76
|
-
|
77
|
-
import android.support.v7.app.AppCompatActivity;
|
78
|
-
|
79
|
-
import android.util.Log;
|
80
|
-
|
81
|
-
import org.opencv.android.BaseLoaderCallback;
|
82
|
-
|
83
|
-
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
|
84
|
-
|
85
|
-
import org.opencv.android.LoaderCallbackInterface;
|
86
|
-
|
87
|
-
import org.opencv.android.OpenCVLoader;
|
88
|
-
|
89
|
-
import org.opencv.core.CvType;
|
90
|
-
|
91
|
-
import org.opencv.core.Core;
|
92
|
-
|
93
|
-
import org.opencv.core.Mat;
|
94
|
-
|
95
|
-
import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
|
96
|
-
|
97
|
-
import org.opencv.core.Scalar;
|
98
|
-
|
99
|
-
import org.opencv.imgproc.Imgproc;
|
100
|
-
|
101
|
-
import org.opencv.core.Point;
|
102
|
-
|
103
|
-
import org.opencv.videoio.VideoCapture;
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
public abstract class MainActivity extends AppCompatActivity implements CvCameraViewListener {
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
private final BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
|
112
|
-
|
113
|
-
@Override
|
114
|
-
|
115
|
-
public void onManagerConnected(int status) {
|
116
|
-
|
117
|
-
switch (status) {
|
118
|
-
|
119
|
-
case LoaderCallbackInterface.SUCCESS:
|
120
|
-
|
121
|
-
{
|
122
|
-
|
123
|
-
Log.i("Opencv", "loaded successfully");
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
break;
|
128
|
-
|
129
|
-
default:
|
130
|
-
|
131
|
-
{
|
132
|
-
|
133
|
-
super.onManagerConnected(status);
|
134
|
-
|
135
|
-
}
|
136
|
-
|
137
|
-
break;
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
}};
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
@Override
|
146
|
-
|
147
|
-
public void onResume() {
|
148
|
-
|
149
|
-
super.onResume();
|
150
|
-
|
151
|
-
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, this, mLoaderCallback);
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
private Mat mCameraFrame;
|
160
|
-
|
161
|
-
public final VideoCapture capture =new VideoCapture("http://????action=stream");
|
162
|
-
|
163
|
-
public void onCreate(Bundle savedInstanceState){
|
164
|
-
|
165
|
-
super.onCreate(savedInstanceState);
|
166
|
-
|
167
|
-
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
168
|
-
|
169
|
-
if( capture.isOpened()){
|
170
|
-
|
171
|
-
capture.read(mCameraFrame);
|
172
|
-
|
173
|
-
if( !mCameraFrame.empty() ) {
|
174
|
-
|
175
|
-
capture.open(0);
|
176
|
-
|
177
|
-
setContentView(R.layout.activity_main);
|
178
|
-
|
179
|
-
}
|
180
|
-
|
181
|
-
else{
|
182
|
-
|
183
|
-
System.out.println(" -- No captured frame -- ");
|
184
|
-
|
185
|
-
setContentView(R.layout.activity_main);
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
else{
|
192
|
-
|
193
|
-
System.out.println(" -- Can't boot -- ");
|
194
|
-
|
195
|
-
setContentView(R.layout.activity_main);
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
@Override
|
206
|
-
|
207
|
-
public void onCameraViewStarted(int width, int height) {
|
208
|
-
|
209
|
-
mCameraFrame = new Mat(height, width, CvType.CV_8UC1);
|
210
|
-
|
211
|
-
}
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
@Override
|
216
|
-
|
217
|
-
public void onCameraViewStopped() {
|
218
|
-
|
219
|
-
mCameraFrame.release();
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
@Override
|
226
|
-
|
227
|
-
public void onCameraFrame(CvCameraViewFrame inputFrame) {
|
228
|
-
|
229
|
-
Mat circles = new Mat();
|
230
|
-
|
231
|
-
Imgproc.cvtColor(mCameraFrame, mCameraFrame, Imgproc.COLOR_RGB2GRAY);
|
232
|
-
|
233
|
-
Imgproc.HoughCircles(mCameraFrame, circles, Imgproc.CV_HOUGH_GRADIENT, 2, 10, 160, 50, 10, 20);
|
234
|
-
|
235
|
-
fncDrwCircles(circles, mCameraFrame);
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
private void fncDrwCircles(Mat circles, Mat mCameraFrame) {
|
242
|
-
|
243
|
-
double[] data;
|
244
|
-
|
245
|
-
double rho;
|
246
|
-
|
247
|
-
Point pt = new Point();
|
248
|
-
|
249
|
-
for (int i = 0; i < circles.cols(); i++) {
|
250
|
-
|
251
|
-
data = circles.get(0, i);
|
252
|
-
|
253
|
-
pt.x = data[0];
|
254
|
-
|
255
|
-
pt.y = data[1];
|
256
|
-
|
257
|
-
rho = data[2];
|
258
|
-
|
259
|
-
Imgproc.circle(mCameraFrame, pt, (int) rho, new Scalar(255, 0, 0), 2);
|
260
|
-
|
261
|
-
}
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
}
|
266
|
-
|
267
|
-
}
|
1
ソースコードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -59,3 +59,209 @@
|
|
59
59
|
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
|
60
60
|
|
61
61
|
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
追記:ソースコードはこれです。ストリーム配信した映像から円を検出しようとしています。
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
import android.os.Bundle;
|
76
|
+
|
77
|
+
import android.support.v7.app.AppCompatActivity;
|
78
|
+
|
79
|
+
import android.util.Log;
|
80
|
+
|
81
|
+
import org.opencv.android.BaseLoaderCallback;
|
82
|
+
|
83
|
+
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
|
84
|
+
|
85
|
+
import org.opencv.android.LoaderCallbackInterface;
|
86
|
+
|
87
|
+
import org.opencv.android.OpenCVLoader;
|
88
|
+
|
89
|
+
import org.opencv.core.CvType;
|
90
|
+
|
91
|
+
import org.opencv.core.Core;
|
92
|
+
|
93
|
+
import org.opencv.core.Mat;
|
94
|
+
|
95
|
+
import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
|
96
|
+
|
97
|
+
import org.opencv.core.Scalar;
|
98
|
+
|
99
|
+
import org.opencv.imgproc.Imgproc;
|
100
|
+
|
101
|
+
import org.opencv.core.Point;
|
102
|
+
|
103
|
+
import org.opencv.videoio.VideoCapture;
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
public abstract class MainActivity extends AppCompatActivity implements CvCameraViewListener {
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
private final BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
|
112
|
+
|
113
|
+
@Override
|
114
|
+
|
115
|
+
public void onManagerConnected(int status) {
|
116
|
+
|
117
|
+
switch (status) {
|
118
|
+
|
119
|
+
case LoaderCallbackInterface.SUCCESS:
|
120
|
+
|
121
|
+
{
|
122
|
+
|
123
|
+
Log.i("Opencv", "loaded successfully");
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
break;
|
128
|
+
|
129
|
+
default:
|
130
|
+
|
131
|
+
{
|
132
|
+
|
133
|
+
super.onManagerConnected(status);
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
break;
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
}};
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
@Override
|
146
|
+
|
147
|
+
public void onResume() {
|
148
|
+
|
149
|
+
super.onResume();
|
150
|
+
|
151
|
+
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, this, mLoaderCallback);
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
private Mat mCameraFrame;
|
160
|
+
|
161
|
+
public final VideoCapture capture =new VideoCapture("http://????action=stream");
|
162
|
+
|
163
|
+
public void onCreate(Bundle savedInstanceState){
|
164
|
+
|
165
|
+
super.onCreate(savedInstanceState);
|
166
|
+
|
167
|
+
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
168
|
+
|
169
|
+
if( capture.isOpened()){
|
170
|
+
|
171
|
+
capture.read(mCameraFrame);
|
172
|
+
|
173
|
+
if( !mCameraFrame.empty() ) {
|
174
|
+
|
175
|
+
capture.open(0);
|
176
|
+
|
177
|
+
setContentView(R.layout.activity_main);
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
else{
|
182
|
+
|
183
|
+
System.out.println(" -- No captured frame -- ");
|
184
|
+
|
185
|
+
setContentView(R.layout.activity_main);
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
else{
|
192
|
+
|
193
|
+
System.out.println(" -- Can't boot -- ");
|
194
|
+
|
195
|
+
setContentView(R.layout.activity_main);
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
@Override
|
206
|
+
|
207
|
+
public void onCameraViewStarted(int width, int height) {
|
208
|
+
|
209
|
+
mCameraFrame = new Mat(height, width, CvType.CV_8UC1);
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
@Override
|
216
|
+
|
217
|
+
public void onCameraViewStopped() {
|
218
|
+
|
219
|
+
mCameraFrame.release();
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
@Override
|
226
|
+
|
227
|
+
public void onCameraFrame(CvCameraViewFrame inputFrame) {
|
228
|
+
|
229
|
+
Mat circles = new Mat();
|
230
|
+
|
231
|
+
Imgproc.cvtColor(mCameraFrame, mCameraFrame, Imgproc.COLOR_RGB2GRAY);
|
232
|
+
|
233
|
+
Imgproc.HoughCircles(mCameraFrame, circles, Imgproc.CV_HOUGH_GRADIENT, 2, 10, 160, 50, 10, 20);
|
234
|
+
|
235
|
+
fncDrwCircles(circles, mCameraFrame);
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
private void fncDrwCircles(Mat circles, Mat mCameraFrame) {
|
242
|
+
|
243
|
+
double[] data;
|
244
|
+
|
245
|
+
double rho;
|
246
|
+
|
247
|
+
Point pt = new Point();
|
248
|
+
|
249
|
+
for (int i = 0; i < circles.cols(); i++) {
|
250
|
+
|
251
|
+
data = circles.get(0, i);
|
252
|
+
|
253
|
+
pt.x = data[0];
|
254
|
+
|
255
|
+
pt.y = data[1];
|
256
|
+
|
257
|
+
rho = data[2];
|
258
|
+
|
259
|
+
Imgproc.circle(mCameraFrame, pt, (int) rho, new Scalar(255, 0, 0), 2);
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
}
|