Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

Why does faceCascade.detectMultiScale abort on call?

$
0
0
The code is: import cv2 import sys cascPath = sys.argv[1] faceCascade = cv2.CascadeClassifier(cascPath) video_capture = cv2.VideoCapture(1) while True: # Capture frame-by-frame ret, frame = video_capture.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) faces = faceCascade.detectMultiScale( gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE ) # Draw a rectangle around the faces for (x, y, w, h) in faces: cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2) # Display the resulting frame cv2.imshow('Video', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break # When everything is done, release the capture video_capture.release() cv2.destroyAllWindows() Code was from https://realpython.com/blog/python/face-detection-in-python-using-a-webcam/ The original code did not work because of deprication of cv2.cv.CV_HAAR_SCALE_IMAGE which is replaced with cv2.CASCADE_SCALE_IMAGE from guidance at https://stackoverflow.com/questions/41341409/where-is-cv-haar-scale-image-in-opencv-3-1-0-with-python-3-5 However, cv::CascadeClassifier::detectMultiScale causes exception with assertion (!empty()) at cascadedetect.cpp line 1681 I am using windoze 10, OpenCV 3.2, Python 2.7.9 64bit (stackless) Any ideas please? It is a fresh install of OpenCV binaries. Cheers, B

Viewing all articles
Browse latest Browse all 2088

Latest Images

Trending Articles



Latest Images