boltgolt / howdy

🛡️ Windows Hello™ style facial authentication for Linux
MIT License
5.86k stars 300 forks source link

Howdy entirely broken after recent update #132

Closed NatSquared closed 5 years ago

NatSquared commented 5 years ago

Please describe the issue in as much detail as possible, including any errors and traces

Just ran apt update && apt upgrade, and howdy immediately stopped working. I don't think OpenCV was upgraded this time around. Happy to post any additional infomation, but here's the traceback thrown to console:

Traceback (most recent call last):
  File "/lib/security/howdy/compare.py", line 210, in <module>
    face_locations = face_detector(gsframe, 1)
RuntimeError: Unsupported image type, must be 8bit gray or RGB image.
Unknown error: 1 

I've searched for similar issues already, and my issue has not been reported yet.

Linux distribution (if applicable):

Mint 18.3 sylvia x86_64 Linux 4.15.0-42-generic

Howdy version: 2.5.0

boltgolt commented 5 years ago

Well, that's bad. This version of Howdy removes all color information from the incoming frames so they can me analyzed quicker, but sometimes this can lead to issues.

Could you try changing the line (line number 186)

        gsframe = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

to

        gsframe = frame

in /lib/security/howdy/compare.py? This will probably break some other parts of Howdy but i'd like to see what error it'll give.

NatSquared commented 5 years ago

Amazingly, that actually fixed it. My IR camera happens already to return values in greyscale, so this doesn't affect anything. Won't work globally, but thank you for finding a fix that works for me...

I'll let you decide whether to close this issue or not

boltgolt commented 5 years ago

I'll keep it open for now as you probably won't be the last to encounter this. In 2.6.0 i'll add a catch for the runtime error.

NatSquared commented 5 years ago

@boltgolt Update; output from sudo howdy test:

Opening a window with a test feed

Press ctrl+C in this terminal to quit
Click on the image to enable or disable slow mode

Traceback (most recent call last):
  File "/usr/local/bin/howdy", line 101, in <module>
    import cli.test
  File "/lib/security/howdy/cli/test.py", line 159, in <module>
    face_locations = face_detector(frame, 1) # upsample 1 time
RuntimeError: Unsupported image type, must be 8bit gray or RGB image.
boltgolt commented 5 years ago

Same problem, with about the same fix. In /lib/security/howdy/cli/test.py remove line 109:

frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
ntrepid8 commented 5 years ago

I'm seeing this as well on a Dell XPS 13 9370 with a grey scale IR camera.

$ v4l2-ctl --device=/dev/video1 -D --list-formats
Driver Info (not using libv4l2):
    Driver name   : uvcvideo
    Card type     : Integrated_Webcam_HD: Integrate
    Bus info      : usb-0000:00:14.0-5
    Driver version: 4.15.18
    Capabilities  : 0x84200001
        Video Capture
        Streaming
        Extended Pix Format
        Device Capabilities
    Device Caps   : 0x04200001
        Video Capture
        Streaming
        Extended Pix Format
ioctl: VIDIOC_ENUM_FMT
    Index       : 0
    Type        : Video Capture
    Pixel Format: ''
    Name        : 00000032-0002-0010-8000-00aa003

Would it help to have detailed output from lsusb or anything? It's a Realtek camera:

Bus 001 Device 002: ID 0bda:58f4 Realtek Semiconductor Corp.
boltgolt commented 5 years ago

The next version of Howdy will try to convert to gray, but will catch the runtime error instead of crashing all together. Besides code, i don't need much right now

anarchist912 commented 5 years ago

I also have the Bus 001 Device 002: ID 0bda:58f4 Realtek Semiconductor Corp. Camera in an XPS 13 9370.

I played around with howdy/cli/test.py a bit, after getting this same error message:

File "/lib/security/howdy/cli/test.py", line 109, in <module>
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.0.0) /home/svensebastian/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

Removing line 109 does not do the trick here. The problem seems to be that the capturing of the first frame fails. After this line (108): ret, frame = video_capture.read() print(frame) would return None

Could it be that we need to wait a bit with this camera, before its ready to capture the first frame?

boltgolt commented 5 years ago

The XPSs have some really funky GREY8 encoded cameras that until fairly recently did not have a linux driver. A new driver was merged in march last year (see this comment) so only the newest systems will come with the right kernel by default.

ntrepid8 commented 5 years ago

I think version 4.19 is the first Linux kernel with GREY8 support.

boltgolt commented 5 years ago

Should be fixed by 2.5.1, let me know if it isn't