face_recognition icon indicating copy to clipboard operation
face_recognition copied to clipboard

TypeError: call(): incompatible function arguments

Open rkuo2000 opened this issue 6 years ago • 7 comments

  • face_recognition version: 1.2.2
  • Python version: 3.6.5
  • Operating System: Windows 7 / Git Bash 2.17.1.2

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

rkuo2000 avatar Jul 04 '18 16:07 rkuo2000

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.

ageitgey avatar Jul 04 '18 16:07 ageitgey

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 :)

rkuo2000 avatar Jul 04 '18 17:07 rkuo2000

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

KyleRAnderson avatar Nov 21 '19 18:11 KyleRAnderson

@KyleRAnderson pretty sure it does

MattPChoy avatar Jan 31 '21 10:01 MattPChoy

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

wechulimaven avatar Oct 04 '21 06:10 wechulimaven

Anyone got any fix? I am getting the same error

agneya-1402 avatar Jun 16 '23 07:06 agneya-1402

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)

OhLawdHeCoding avatar Jul 04 '23 20:07 OhLawdHeCoding