arunponnusamy / cvlib

A simple, high level, easy to use, open source Computer Vision library for Python.
http://arunponnusamy.com/cvlib/
MIT License
656 stars 126 forks source link

No object detected #27

Open ujaque opened 5 years ago

ujaque commented 5 years ago

Hello, First of all I am beginner in this field and thanks in advance.

I have just tried the same code you provided but, the picture I am getting as an output is the same is the input. there are no squares indicating objects.

The output I get is: (the arrays are empty so it seems nothing gets detected) (base) Davids-MacBook-Pro:Object_Detection davidlopez$ cd /Users/davidlopez/Documents/Object_Detection ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /anaconda3/bin/python /Users/davidlopez/.vscode/extensions/ms-python.python-2019.1.0/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 56195 /Users/davidlopez/Documents/Object_Detection/Obj_detection.py Using TensorFlow backend. [] [] []

my code is:

import cvlib as cv from cvlib.object_detection import draw_bbox import sys import cv2

read input image

image = cv2.imread('varios1.jpg')

apply object detection

bbox, label, conf = cv.detect_common_objects(image)

print(bbox, label, conf)

draw bounding box over detected objects

out = draw_bbox(image, bbox, label, conf)

display output

press any key to close window

cv2.imshow("object_detection", out) cv2.waitKey()

save output

cv2.imwrite("object_detection.jpg", out)

release resources

cv2.destroyAllWindows()

rymoore commented 4 years ago

Same issue. I'm also on a Macbook - I assume it must be Mac related?

rafacompu commented 4 years ago

Try this:

bbox, label, conf = cv.detect_common_objects(image, confidence=0.25, model='yolov3-tiny')

I couldn't make it work in my macbook either until I tried this approach.

yudingyuyihan commented 4 years ago

如果你有看object_detection.py这个原代码,你可以发现运行detect_common_objects()函数需要下载yolov3.cfg和yolov3.weights这两个支持文件的。但是如果首次运行,你没有完全下载,那么这两个文件虽然会存在,但是内容不全。所以会导致运行detect_common_objects()返回为空。这时候你需要按shift+command+g输入/user/XXXX/.cvlib/object_detection/yolo/yolov3(如果你有看源代码的话你可以发现yolov3.cfg和yolov3.weights保存在这个隐藏文件夹下。)进入这个目录。然后通过源代码里面的连接下载好后,放在这个目录下就好了。

yudingyuyihan commented 4 years ago

Hello, First of all I am beginner in this field and thanks in advance.

I have just tried the same code you provided but, the picture I am getting as an output is the same is the input. there are no squares indicating objects.

The output I get is: (the arrays are empty so it seems nothing gets detected) (base) Davids-MacBook-Pro:Object_Detection davidlopez$ cd /Users/davidlopez/Documents/Object_Detection ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /anaconda3/bin/python /Users/davidlopez/.vscode/extensions/ms-python.python-2019.1.0/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 56195 /Users/davidlopez/Documents/Object_Detection/Obj_detection.py Using TensorFlow backend. [] [] []

my code is:

import cvlib as cv from cvlib.object_detection import draw_bbox import sys import cv2

read input image

image = cv2.imread('varios1.jpg')

apply object detection

bbox, label, conf = cv.detect_common_objects(image)

print(bbox, label, conf)

draw bounding box over detected objects

out = draw_bbox(image, bbox, label, conf)

display output

press any key to close window

cv2.imshow("object_detection", out) cv2.waitKey()

save output

cv2.imwrite("object_detection.jpg", out)

release resources

cv2.destroyAllWindows()

If you look at the original code of object_detection.py, you can find that to run the detect_common_objects () function, you need to download the two supporting files yolov3.cfg and yolov3.weights. But if you do n’t download it completely for the first time, these two files will exist, but the content is not complete. So it will cause detect_common_objects () to return null. At this time, you need to press shift + command + g to enter /user/XXXX/.cvlib/object_detection/yolo/yolov3 (if you have seen the source code, you can find yolov3.cfg and yolov3.weights saved in this hidden folder. ) Enter this directory. Then download it through the connection in the source code and put it in this directory.

Nwankwo-Nnaemeka commented 7 months ago

@yudingyuyihan Please how do I do that for windows I am facing the same issue but I have not found any directory like the one you mentioned. I am using Vscode and a virtual environment