Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opencv: AttributeError: module 'cv2' has no attribute 'dnn'

I am just starting with computer vision. While running code I got the following error.

[INFO] loading model... Traceback (most recent call last): File "detect_faces_video.py", line 24, in net = cv2.dnn.readNetFromCaffe(args["prototxt"], args["model"]) AttributeError: module 'cv2' has no attribute 'dnn'

I believe that the error is because my opencv version is 3.1.0 and for this tutorial to work I need at least the 3.3.0 version.

So the better question would be, How can I upgrade my opencv to 3.3.0 from 3.1.0. Do I need to delete the 3.1.0 version first?

I have installed my opencv in a virtual environment.

Thanks

like image 385
mk2683 Avatar asked Sep 30 '18 07:09

mk2683


1 Answers

I got it to work by making another virtual environment. Then Installing the latest version of opencv.

$ mkvirtualenv cv

$ sudo pip3 install opencv-contrib-python

like image 167
mk2683 Avatar answered Nov 20 '22 18:11

mk2683