def load_detection_model(model_path='/usr/local/opt/opencv3/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml'):
if not os.path.exists(model_path):
# Try alternative file path
local_cascade_path = 'face.xml'
if not os.path.exists(local_cascade_path):
raise NameError('File not found:', local_cascade_path)
model_path = local_cascade_path
detection_model = cv2.CascadeClassifier(model_path)
return detection_model
评论列表
文章目录