Ask Your Question
0

cv2 looking in nonexistent directory for modules

asked 2016-07-03 13:41:55 -0600

Hello, trying first program after a hello world

error: cv2.error: D:\Build\OpenCV\opencv-3.1.0\modules\objdetect\src\cascadedetect.cpp:1639: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale

There is no D drive on my computer, it seems there's some default cv2 path setting and it's looking in nonexistent places. How do I change this?

Code: import numpy as np import cv2

face_cascade = cv2.CascadeClassifier('C:\Invention Work\CV\opencv\build\etc\haarcascades\haarcascade_frontalface_default.xml') eye_cascade = cv2.CascadeClassifier('C:\Invention Work\CV\opencv\build\etc\haarcascades\haarcascade_eye.xml')

img = cv2.imread('test1.jpg') gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale(gray, 1.3, 5) for (x,y,w,h) in faces: cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) roi_gray = gray[y:y+h, x:x+w] roi_color = img[y:y+h, x:x+w] eyes = eye_cascade.detectMultiScale(roi_gray) for (ex,ey,ew,eh) in eyes: cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)

cv2.imshow('img',img) cv2.waitKey(0) cv2.destroyAllWindows()

edit retag flag offensive close merge delete

Comments

your cascade was not loaded (that's the error.) there seems to be no valid xml file at 'C:\Invention Work\CV\opencv\build\etc\haarcascades\haarcascade_frontalface_default.xml' . please check that.

the message might be confusing, but the "wrong" path is just the location of the code while building the python wrappers (on a different machine)

berak gravatar imageberak ( 2016-07-04 00:03:21 -0600 )edit

Thanks for the information about the path! There is a haarcascade_frontalface_default.xml at the specified location, however, and it appears to match the original as hosted on github.

Still haven't been able to solve it.

Ryan Downs gravatar imageRyan Downs ( 2016-07-04 10:51:12 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-12-01 17:16:35 -0600

I have a similar problem. Installed opencv from a hosted wheel. I have no D drive.

error: D:\Build\OpenCV\opencv-3.3.1\modules\imgproc\src\histogram.cpp:3913: error: (-215) _src.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) in function cv::equalizeHist

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-07-03 13:41:55 -0600

Seen: 794 times

Last updated: Jul 03 '16