ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.59k stars 13.51k forks source link

TypeError: call(): incompatible function arguments #557

Open rkuo2000 opened 6 years ago

rkuo2000 commented 6 years ago

Description

return face_detector(img, number_of_times_to_upsample)

TypeError: call(): incompatible function arguments. The following argument types are supported:

  1. (self: dlib.fhog_object_detector, image: array, upsample_num_times: int=0)

How to fix this ?

What I Did

$pip3 install dlib (version is 19.13.1) $pip3 install face_recognition (version 1.2.2) $cd ~/cv2 (my sample code is in https://github.com/rkuo2000/cv2/cam_eye_tracking.py) $python cam_eye_tracking.py

Traceback (most recent call last): File "cam_eye_tracking.py", line 11, in face_landmarks_list = face_recognition.face_landmarks(image) File "C:\Program Files\Python36\lib\site-packages\face_recognition\api.py", line 173, in face_landmarks landmarks = _raw_face_landmarks(face_image, face_locations) File "C:\Program Files\Python36\lib\site-packages\face_recognition\api.py", line 153, in _raw_face_landmarks face_locations = _raw_face_locations(face_image) File "C:\Program Files\Python36\lib\site-packages\face_recognition\api.py", line 102, in _raw_face_locations return face_detector(img, number_of_times_to_upsample) TypeError: call(): incompatible function arguments. The following argument types are supported:

  1. (self: dlib.fhog_object_detector, image: array, upsample_num_times: int=0) -> dlib.rectangles

Invoked with: <dlib.fhog_object_detector object at 0x000000000A3D6570>, None, 1

ageitgey commented 6 years ago

The image you are passing in is null. Most likely your call to read from the camera with OpenCV is failing and returning None instead of an array. Add some code to make sure the call to the camera worked before going to the next step.

Once you fix that, you still have one other bug. OpenCV returns BGR images but this library needs RGB images. Check the examples here for how to convert BGR to RGB.

rkuo2000 commented 6 years ago

My bad, somehow my camera doesn't work, I replug in, and it runs fine now. Thanks ! BTW, using face landmark can not recognize oriental faces well, (cause some has small eyes :)

KyleRAnderson commented 5 years ago

Does this library also work with greyscale images? I'm trying to run this on a raspberry PI and full colour is pretty slow.

MattPChoy commented 3 years ago

@KyleRAnderson pretty sure it does

wechulimaven commented 3 years ago

Am getting the same error. return face_detector(img, number_of_times_to_upsample) TypeError: call(): incompatible function arguments. The following argument types are supported:

  1. (self: _dlib_pybind11.fhog_object_detector, image: array, upsample_num_times: int=0) -> _dlib_pybind11.rectangles

Invoked with: <_dlib_pybind11.fhog_object_detector object at 0x0000028F747D7D30>, array([[[ 21, 19, 20], [ 27, 25, 26], [ 39, 37, 38], ..., [ 10, 5, 9], [ 8, 3, 7], [ 18, 13, 17]],

   [[ 29,  27,  28],
    [ 34,  32,  33],
    [ 43,  41,  42],
    ...,
    [  7,   2,   6],
    [  3,   0,   2],
    [  8,   3,   7]],

   [[ 35,  33,  34],
    [ 37,  35,  36],
    [ 45,  43,  44],
    ...,
    [ 14,   9,  13],
    [  7,   2,   6],
    [  9,   4,   8]],

   ...,

   [[ 95, 102, 118],
    [ 97, 104, 120],
    [ 99, 106, 122],
    ...,
    [  5,   1,   2],
    [  5,   1,   2],
    [  5,   1,   2]],

   [[ 95, 102, 118],
    [ 94, 101, 117],
    [ 92,  99, 115],
    ...,
    [  5,   1,   2],
    [  5,   1,   2],
    [  5,   1,   2]],

   [[100, 107, 123],
    [ 94, 101, 117],
    [ 88,  95, 111],
    ...,
    [  5,   1,   2],
    [  5,   1,   2],
    [  5,   1,   2]]], dtype=uint8), <function hog at 0x0000028F0FE93040>

Thats the error am using unknown_face_encodings = face_recognition.face_locations(unknown_image, hog) unknown_face_encoding = face_recognition.face_encodings(unknown_face_encodings)[0] print(f"Image 3 {unknown_face_encoding}")

what am trying to do here is detecting a face in an image after which I want to encode it and then compare faces. am quite stranded. any help

agneya-1402 commented 1 year ago

Anyone got any fix? I am getting the same error

OhLawdHeCoding commented 1 year ago

Anyone got any fix? I am getting the same error

I was also getting this issue with a non-empty image. What fixed it was casting the image to RGB since CV2 uses BGR. rgb_small_frame = cv2.cvtColor(small_frame, cv2.COLOR_BGR2RGB)