質問編集履歴

5

windowsエラーの詳細

2019/10/09 06:40

投稿

aqufiz
aqufiz

スコア70

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のエラー追加

2019/10/09 06:40

投稿

aqufiz
aqufiz

スコア70

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

エラーの追加

2019/10/09 06:37

投稿

aqufiz
aqufiz

スコア70

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

追記

2019/10/09 06:32

投稿

aqufiz
aqufiz

スコア70

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の変更

2019/10/09 03:53

投稿

aqufiz
aqufiz

スコア70

test CHANGED
File without changes
test CHANGED
@@ -16,59 +16,85 @@
16
16
 
17
17
  ```Python
18
18
 
19
- class LoadImages: # for inference
19
+ class LoadStreams: # multiple IP or RTSP cameras
20
20
 
21
- def __init__(self, path, img_size=416, half=False):
21
+ def __init__(self, sources='streams.txt', img_size=416, half=False):
22
22
 
23
- path = str(Path(path)) # os-agnostic
23
+ self.mode = 'images'
24
24
 
25
- files = []
25
+ self.img_size = img_size
26
26
 
27
- if os.path.isdir(path):
28
-
29
- files = sorted(glob.glob(os.path.join(path, '*.*')))
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
- images = [x for x in files if os.path.splitext(x)[-1].lower() in img_formats]
31
+ if os.path.isfile(sources):
38
32
 
39
- videos = [x for x in files if os.path.splitext(x)[-1].lower() in vid_formats]
33
+ with open(sources, 'r') as f:
40
34
 
41
- nI, nV = len(images), len(videos)
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
- self.img_size = img_size
43
+ n = len(sources)
46
44
 
47
- self.files = images + videos
45
+ self.imgs = [None] * n
48
46
 
49
- self.nF = nI + nV # number of files
47
+ self.sources = sources
50
48
 
51
- self.video_flag = [False] * nI + [True] * nV
49
+ for i, s in enumerate(sources):
52
50
 
53
- self.mode = 'images'
51
+ # Start the thread to read frames from the video stream
54
52
 
55
- self.half = half # half precision fp16 images
53
+ print('%g/%g: %s... ' % (i + 1, n, s), end='')
56
54
 
57
- if any(videos):
55
+ cap = cv2.VideoCapture(0 if s == '0' else s)
58
56
 
59
- self.new_video(videos[0]) # new video
57
+ #if s == '0':
60
58
 
61
- else:
59
+ #cap.set(3,1280)
62
60
 
63
- self.cap = None
61
+ #cap.set(4,720)
64
62
 
65
- assert self.nF > 0, 'No images or videos found in ' + path
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 = 0
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
- if self.count == self.nF:
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
- path = self.files[self.count]
119
+ img = [letterbox(x, new_shape=self.img_size)[0] for x in img0]
84
120
 
85
121
 
86
122
 
87
- if self.video_flag[self.count]:
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
- img0 = cv2.imread(path) # BGR
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(2, 0, 1) # BGR to RGB
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 path, img, img0, self.cap
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 self.nF # number of files
145
+ return 0 # 1E12 frames = 32 streams at 30 FPS for 30 years
146
+
147
+
170
148
 
171
149
  ```