Yolov3: detect.py --source 0 error, can not use webcam

Created on 28 Oct 2019  路  4Comments  路  Source: ultralytics/yolov3

Thanks for your amazing project, but I have some problem.
First I run "python3 detect.py --cfg cfg/yolov3.cfg --weights weights/yolov3.weights --source xxx.mp4" , it seems good.
But I try "python3 detect.py --cfg cfg/yolov3.cfg --weights weights/yolov3.weights --source 0", i can't work.

Like this:
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='GeForce RTX 2080 Ti', total_memory=10986MB)

1/1: 0... success (640x480 at 30.00 FPS).

Traceback (most recent call last):
File "detect.py", line 165, in
detect()
File "detect.py", line 70, in detect
for path, img, im0s, vid_cap in dataset:
File "/home/aluds/yolov3/utils/datasets.py", line 236, in __next__
if cv2.waitKey(1) == ord('q'): # q to quit
cv2.error: OpenCV(3.4.2) /tmp/build/80754af9/opencv-suite_1535558553474/work/modules/highgui/src/window.cpp:698: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'

I'm not sure how can I do.
Maybe just I do something wrong.

Stale bug

Most helpful comment

@aluds123 @glenn-jocher
Resloved. If you are on a mac, make sure you install opencv-python-headless instead of opencv-python to avoid these errors.

All 4 comments

Seems to be a recent bug in cv2:

import cv2
cam = cv2.VideoCapture(0)

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Same problem in opencv 4.1:

Python 3.7.5 (default, Oct 25 2019, 10:52:18) 
[Clang 4.0.1 (tags/RELEASE_401/final)] on darwin

import cv2
cv2.__version__
Out[3]: '4.1.2'
cam = cv2.VideoCapture(0)

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

@aluds123 @glenn-jocher
Resloved. If you are on a mac, make sure you install opencv-python-headless instead of opencv-python to avoid these errors.

This issue is stale because it has been open 30 days with no activity. Remove Stale label or comment or this will be closed in 5 days.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Deep-Learner picture Deep-Learner  路  5Comments

khalidw picture khalidw  路  5Comments

MichaelCong picture MichaelCong  路  4Comments

yoga-0125 picture yoga-0125  路  4Comments

Alex1101a picture Alex1101a  路  5Comments