YOLOv3-github
上記のgithubから持ってきたYOLOv3のwebcamera版をUbuntuで実行したところ,
qを押して終了すると,"fatal exception not rethrown"というエラーが出て,abortedしてしまいます.
おそらく下記の,utilのdatasets.pyのThreadに問題があると思うのですが,調べてみても理解できませんでした.
何か解決方法があれば,教えていただきたいです.
よろしくお願いいたします.
追記
Windowsのvscodeで実行したところこのエラーは起きませんでした.
OpenCVのバージョンをpython -m pip install opencv-pythonで更新してみたり,
vscodeではなく,直接Pythonから実行などを試していたところ
vscodeでqを押して終了すると,そこでプログラムが終了せずに止まってしまうようになりました.
そして,このような状態になってしまってからは"1/1: 0... success (1920x1080 at 30.00 FPS)."の
FPSは0と表示されています.
ターミナルの表示はこのようになっています
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') Using CUDA device0 _CudaDeviceProperties(name='Xavier', total_memory=15698MB) 1/1: 0... success (1920x1080 at 30.00 FPS). QStandardPaths: wrong ownership on runtime directory /run/user/1000, 1000 instead of 0 0: 256x416 1 persons, 1 bottles, Done. (0.075s) 0: 256x416 1 persons, 1 bottles, Done. (0.072s) 0: 256x416 1 persons, 1 bottles, Done. (0.072s) 0: 256x416 1 persons, 1 bottles, Done. (0.072s) 0: 256x416 1 persons, 1 bottles, Done. (0.073s) 0: 256x416 1 persons, 1 bottles, Done. (0.074s) 0: 256x416 1 persons, 1 bottles, Done. (0.072s) 0: 256x416 1 persons, 1 bottles, Done. (0.072s) 0: 256x416 1 persons, 1 bottles, Done. (0.071s) ・ ・ ・ ・ "ここでqを押す” Done. (21.684s) FATAL: exception not rethrown Aborted
Python
1class LoadStreams: # multiple IP or RTSP cameras 2 def __init__(self, sources='streams.txt', img_size=416, half=False): 3 self.mode = 'images' 4 self.img_size = img_size 5 self.half = half # half precision fp16 images 6 7 if os.path.isfile(sources): 8 with open(sources, 'r') as f: 9 sources = [x.strip() for x in f.read().splitlines() if len(x.strip())] 10 else: 11 sources = [sources] 12 13 n = len(sources) 14 self.imgs = [None] * n 15 self.sources = sources 16 for i, s in enumerate(sources): 17 # Start the thread to read frames from the video stream 18 print('%g/%g: %s... ' % (i + 1, n, s), end='') 19 cap = cv2.VideoCapture(0 if s == '0' else s) 20 #if s == '0': 21 #cap.set(3,1280) 22 #cap.set(4,720) 23 assert cap.isOpened(), 'Failed to open %s' % s 24 w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) 25 h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) 26 fps = cap.get(cv2.CAP_PROP_FPS) % 100 27 _, self.imgs[i] = cap.read() # guarantee first frame 28 thread = Thread(target=self.update, args=([i, cap]), daemon=True) 29 print(' success (%gx%g at %.2f FPS).' % (w, h, fps)) 30 thread.start() 31 print('') # newline 32 33 def update(self, index, cap): 34 # Read next stream frame in a daemon thread 35 while cap.isOpened(): 36 _, self.imgs[index] = cap.read() 37 time.sleep(0.030) # 33.3 FPS to keep buffer empty 38 39 def __iter__(self): 40 self.count = -1 41 return self 42 43 def __next__(self): 44 self.count += 1 45 img0 = self.imgs.copy() 46 if cv2.waitKey(1) == ord('q'): # q to quit 47 cv2.destroyAllWindows() 48 raise StopIteration 49 50 # Letterbox 51 img = [letterbox(x, new_shape=self.img_size)[0] for x in img0] 52 53 # Stack 54 img = np.stack(img, 0) 55 56 # Normalize RGB 57 img = img[:, :, :, ::-1].transpose(0, 3, 1, 2) # BGR to RGB 58 img = np.ascontiguousarray(img, dtype=np.float16 if self.half else np.float32) # uint8 to fp16/fp32 59 img /= 255.0 # 0 - 255 to 0.0 - 1.0 60 61 return self.sources, img, img0, None 62 63 def __len__(self): 64 return 0 # 1E12 frames = 32 streams at 30 FPS for 30 years 65
あなたの回答
tips
プレビュー