質問編集履歴
5
windowsエラーの詳細
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,6 +24,10 @@
|
|
24
24
|
|
25
25
|
vscodeでqを押して終了すると,そこでプログラムが終了せずに止まってしまうようになりました.
|
26
26
|
|
27
|
+
そして,このような状態になってしまってからは"1/1: 0... success (1920x1080 at 30.00 FPS)."の
|
28
|
+
|
29
|
+
FPSは0と表示されています.
|
30
|
+
|
27
31
|
|
28
32
|
|
29
33
|
ターミナルの表示はこのようになっています
|
4
Windowsのエラー追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,9 +14,15 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
|
17
|
+
追記
|
18
|
-
|
18
|
+
|
19
|
-
Windowsのvscodeで実行したところこのエラーは起きませんでした.
|
19
|
+
~~Windowsのvscodeで実行したところこのエラーは起きませんでした~~.
|
20
|
+
|
21
|
+
OpenCVのバージョンをpython -m pip install opencv-pythonで更新してみたり,
|
22
|
+
|
23
|
+
vscodeではなく,直接Pythonから実行などを試していたところ
|
24
|
+
|
25
|
+
vscodeでqを押して終了すると,そこでプログラムが終了せずに止まってしまうようになりました.
|
20
26
|
|
21
27
|
|
22
28
|
|
3
エラーの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,6 +20,62 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
+
ターミナルの表示はこのようになっています
|
24
|
+
|
25
|
+
```
|
26
|
+
|
27
|
+
Namespace(cfg='cfg/yolov3.cfg', conf_thres=0.3, data='data/coco.data', device='', fourcc='mp4v', half=False, img_size=416, nms_thres=0.5, output='output', source='0', view_img=False, weights='weights/yolov3.weights')
|
28
|
+
|
29
|
+
Using CUDA device0 _CudaDeviceProperties(name='Xavier', total_memory=15698MB)
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
1/1: 0... success (1920x1080 at 30.00 FPS).
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
QStandardPaths: wrong ownership on runtime directory /run/user/1000, 1000 instead of 0
|
40
|
+
|
41
|
+
0: 256x416 1 persons, 1 bottles, Done. (0.075s)
|
42
|
+
|
43
|
+
0: 256x416 1 persons, 1 bottles, Done. (0.072s)
|
44
|
+
|
45
|
+
0: 256x416 1 persons, 1 bottles, Done. (0.072s)
|
46
|
+
|
47
|
+
0: 256x416 1 persons, 1 bottles, Done. (0.072s)
|
48
|
+
|
49
|
+
0: 256x416 1 persons, 1 bottles, Done. (0.073s)
|
50
|
+
|
51
|
+
0: 256x416 1 persons, 1 bottles, Done. (0.074s)
|
52
|
+
|
53
|
+
0: 256x416 1 persons, 1 bottles, Done. (0.072s)
|
54
|
+
|
55
|
+
0: 256x416 1 persons, 1 bottles, Done. (0.072s)
|
56
|
+
|
57
|
+
0: 256x416 1 persons, 1 bottles, Done. (0.071s)
|
58
|
+
|
59
|
+
・
|
60
|
+
|
61
|
+
・
|
62
|
+
|
63
|
+
・
|
64
|
+
|
65
|
+
・
|
66
|
+
|
67
|
+
"ここでqを押す”
|
68
|
+
|
69
|
+
Done. (21.684s)
|
70
|
+
|
71
|
+
FATAL: exception not rethrown
|
72
|
+
|
73
|
+
Aborted
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
|
78
|
+
|
23
79
|
```Python
|
24
80
|
|
25
81
|
class LoadStreams: # multiple IP or RTSP cameras
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,6 +11,12 @@
|
|
11
11
|
何か解決方法があれば,教えていただきたいです.
|
12
12
|
|
13
13
|
よろしくお願いいたします.
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
**追記
|
18
|
+
|
19
|
+
Windowsのvscodeで実行したところこのエラーは起きませんでした.**
|
14
20
|
|
15
21
|
|
16
22
|
|
1
間違ったcodeの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,59 +16,85 @@
|
|
16
16
|
|
17
17
|
```Python
|
18
18
|
|
19
|
-
class Load
|
19
|
+
class LoadStreams: # multiple IP or RTSP cameras
|
20
20
|
|
21
|
-
def __init__(self,
|
21
|
+
def __init__(self, sources='streams.txt', img_size=416, half=False):
|
22
22
|
|
23
|
-
|
23
|
+
self.mode = 'images'
|
24
24
|
|
25
|
-
fi
|
25
|
+
self.img_size = img_size
|
26
26
|
|
27
|
-
if os.path.isdir(path):
|
28
|
-
|
29
|
-
f
|
27
|
+
self.half = half # half precision fp16 images
|
30
|
-
|
31
|
-
elif os.path.isfile(path):
|
32
|
-
|
33
|
-
files = [path]
|
34
28
|
|
35
29
|
|
36
30
|
|
37
|
-
i
|
31
|
+
if os.path.isfile(sources):
|
38
32
|
|
39
|
-
|
33
|
+
with open(sources, 'r') as f:
|
40
34
|
|
41
|
-
|
35
|
+
sources = [x.strip() for x in f.read().splitlines() if len(x.strip())]
|
36
|
+
|
37
|
+
else:
|
38
|
+
|
39
|
+
sources = [sources]
|
42
40
|
|
43
41
|
|
44
42
|
|
45
|
-
|
43
|
+
n = len(sources)
|
46
44
|
|
47
|
-
self.
|
45
|
+
self.imgs = [None] * n
|
48
46
|
|
49
|
-
self.
|
47
|
+
self.sources = sources
|
50
48
|
|
51
|
-
|
49
|
+
for i, s in enumerate(sources):
|
52
50
|
|
53
|
-
|
51
|
+
# Start the thread to read frames from the video stream
|
54
52
|
|
55
|
-
|
53
|
+
print('%g/%g: %s... ' % (i + 1, n, s), end='')
|
56
54
|
|
57
|
-
|
55
|
+
cap = cv2.VideoCapture(0 if s == '0' else s)
|
58
56
|
|
59
|
-
|
57
|
+
#if s == '0':
|
60
58
|
|
61
|
-
|
59
|
+
#cap.set(3,1280)
|
62
60
|
|
63
|
-
|
61
|
+
#cap.set(4,720)
|
64
62
|
|
65
|
-
assert se
|
63
|
+
assert cap.isOpened(), 'Failed to open %s' % s
|
64
|
+
|
65
|
+
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
66
|
+
|
67
|
+
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
68
|
+
|
69
|
+
fps = cap.get(cv2.CAP_PROP_FPS) % 100
|
70
|
+
|
71
|
+
_, self.imgs[i] = cap.read() # guarantee first frame
|
72
|
+
|
73
|
+
thread = Thread(target=self.update, args=([i, cap]), daemon=True)
|
74
|
+
|
75
|
+
print(' success (%gx%g at %.2f FPS).' % (w, h, fps))
|
76
|
+
|
77
|
+
thread.start()
|
78
|
+
|
79
|
+
print('') # newline
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
def update(self, index, cap):
|
84
|
+
|
85
|
+
# Read next stream frame in a daemon thread
|
86
|
+
|
87
|
+
while cap.isOpened():
|
88
|
+
|
89
|
+
_, self.imgs[index] = cap.read()
|
90
|
+
|
91
|
+
time.sleep(0.030) # 33.3 FPS to keep buffer empty
|
66
92
|
|
67
93
|
|
68
94
|
|
69
95
|
def __iter__(self):
|
70
96
|
|
71
|
-
self.count =
|
97
|
+
self.count = -1
|
72
98
|
|
73
99
|
return self
|
74
100
|
|
@@ -76,71 +102,33 @@
|
|
76
102
|
|
77
103
|
def __next__(self):
|
78
104
|
|
79
|
-
|
105
|
+
self.count += 1
|
106
|
+
|
107
|
+
img0 = self.imgs.copy()
|
108
|
+
|
109
|
+
if cv2.waitKey(1) == ord('q'): # q to quit
|
110
|
+
|
111
|
+
cv2.destroyAllWindows()
|
80
112
|
|
81
113
|
raise StopIteration
|
82
114
|
|
115
|
+
|
116
|
+
|
117
|
+
# Letterbox
|
118
|
+
|
83
|
-
|
119
|
+
img = [letterbox(x, new_shape=self.img_size)[0] for x in img0]
|
84
120
|
|
85
121
|
|
86
122
|
|
87
|
-
|
123
|
+
# Stack
|
88
124
|
|
89
|
-
# Read video
|
90
|
-
|
91
|
-
self.mode = 'video'
|
92
|
-
|
93
|
-
ret_val, img0 = self.cap.read()
|
94
|
-
|
95
|
-
if not ret_val:
|
96
|
-
|
97
|
-
self.count += 1
|
98
|
-
|
99
|
-
self.cap.release()
|
100
|
-
|
101
|
-
if self.count == self.nF: # last video
|
102
|
-
|
103
|
-
raise StopIteration
|
104
|
-
|
105
|
-
else:
|
106
|
-
|
107
|
-
path = self.files[self.count]
|
108
|
-
|
109
|
-
self.new_video(path)
|
110
|
-
|
111
|
-
ret_val, img0 = self.cap.read()
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
self.frame += 1
|
116
|
-
|
117
|
-
print('video %g/%g (%g/%g) %s: ' % (self.count + 1, self.nF, self.frame, self.nframes, path), end='')
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
else:
|
122
|
-
|
123
|
-
# Read image
|
124
|
-
|
125
|
-
self.count += 1
|
126
|
-
|
127
|
-
|
125
|
+
img = np.stack(img, 0)
|
128
|
-
|
129
|
-
assert img0 is not None, 'Image Not Found ' + path
|
130
|
-
|
131
|
-
print('image %g/%g %s: ' % (self.count, self.nF, path), end='')
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
# Padded resize
|
136
|
-
|
137
|
-
img, *_ = letterbox(img0, new_shape=self.img_size)
|
138
126
|
|
139
127
|
|
140
128
|
|
141
129
|
# Normalize RGB
|
142
130
|
|
143
|
-
img = img[:, :, ::-1].transpose(
|
131
|
+
img = img[:, :, :, ::-1].transpose(0, 3, 1, 2) # BGR to RGB
|
144
132
|
|
145
133
|
img = np.ascontiguousarray(img, dtype=np.float16 if self.half else np.float32) # uint8 to fp16/fp32
|
146
134
|
|
@@ -148,24 +136,14 @@
|
|
148
136
|
|
149
137
|
|
150
138
|
|
151
|
-
# cv2.imwrite(path + '.letterbox.jpg', 255 * img.transpose((1, 2, 0))[:, :, ::-1]) # save letterbox image
|
152
|
-
|
153
|
-
return
|
139
|
+
return self.sources, img, img0, None
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
def new_video(self, path):
|
158
|
-
|
159
|
-
self.frame = 0
|
160
|
-
|
161
|
-
self.cap = cv2.VideoCapture(path)
|
162
|
-
|
163
|
-
self.nframes = int(self.cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
164
140
|
|
165
141
|
|
166
142
|
|
167
143
|
def __len__(self):
|
168
144
|
|
169
|
-
return
|
145
|
+
return 0 # 1E12 frames = 32 streams at 30 FPS for 30 years
|
146
|
+
|
147
|
+
|
170
148
|
|
171
149
|
```
|