Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'module' object has no attribute 'load'

Tags:

python

opencv

I am using opencv3.1.0. While I am trying to run:

import cv2.cv as cv  
import cv2 

cascade = cv.Load('/usr/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml')

I find that cv2.cv is not in opencv3, so I change cv2.cv to cv2 and then I get the error message in the title.

Any thoughts? Many thanks.

like image 222
appleleaves Avatar asked Feb 11 '26 22:02

appleleaves


1 Answers

You are trying to load a classifier from a file, correct? According to the OpenCV3 documentation you should use CascadeClassifier for this. Example:

import cv2
cascade = cv2.CascadeClassifier('/usr/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml')

Source: http://docs.opencv.org/3.0-beta/modules/objdetect/doc/cascade_classification.html

like image 147
DowntownDev Avatar answered Feb 14 '26 15:02

DowntownDev