Python OpenCV face detection code sometimes raises `'tuple' object has no attribute 'shape'`

前端 未结 4 1020
花落未央
花落未央 2020-12-21 21:54

I am trying to build a face detection application in python using opencv.
Please see below for my code snippets:

 # Loading the Haar Cascade Classifier
c         


        
4条回答
  •  無奈伤痛
    2020-12-21 22:36

    To get the number of faces it should be:

    print "Number of faces found in-> ", img_fname, " are ", len(faces).

    I would also recommend that to convert image to gray scale you should write:

    gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) instead of gray = cv2.cvtColor(im, cv2.COLOR_RGB2GRAY) as color images are loaded by openCV in BGR mode.

提交回复
热议问题