pyskell / slouchy

Slouchy uses your webcam to check if you're slouching and alert you if you are.
GNU General Public License v3.0
800 stars 47 forks source link

Difficulty detecting faces #1

Open granteagon opened 8 years ago

granteagon commented 8 years ago

When I hit setup I get:

('Error:', 'Expected 1 face, found 0 faces. Please make sure your face is in frame, and remove any other things detected as a face from the frame.')

I checked FaceTime to see what's up and half of my face is in shadow from the window next to me. I quit it and relauched, this time facing the window and still got the same error. Looks like face detection needs some work.

pyskell commented 8 years ago

Face detection can always be improved but for the most part this will require a fully lit face.

Going to investigate cascade settings to improve face detection in poor lighting conditions. On Oct 12, 2015 12:19 PM, "Grant Eagon" notifications@github.com wrote:

When I hit setup I get:

('Error:', 'Expected 1 face, found 0 faces. Please make sure your face is in frame, and remove any other things detected as a face from the frame.')

I checked FaceTime to see what's up and half of my face is in shadow from the window next to me. I quit it and relauched, this time facing the window and still got the same error. Looks like face detection needs some work.

— Reply to this email directly or view it on GitHub https://github.com/pyskell/slouchy/issues/1.

13rac1 commented 8 years ago

Same as above, but it seems like a hardware interface issue. The webcam is started and quickly shut off. The green light next to the webcam flashes on momentarily, then I get the above error. Output from the program as it attempts to run:

$ python slouchy.py 
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
"sni-qt/5194" WARN  17:46:07.952 void StatusNotifierItemFactory::connectToSnw() Invalid interface to SNW_SERVICE 
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
('Error:', 'Expected 1 face, found 0 faces. Please make sure your face is in frame, and remove any other things detected as a face from the frame.')
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
13rac1 commented 8 years ago

I'm using the Ubuntu provided package as described in #5. Should OpenCV be compiled?

This stackoverflow says the issue is related to older versions of OpenCV. I am installing the compiled version now.

psihonavt commented 8 years ago

While using https://github.com/mroth/lolcommits faced with the same issue on MBP (too dark images from webcam). Issue was resolved using delay before taking screenshot ... like giving time for webcam to "warm up" (https://github.com/mroth/lolcommits/issues/222). Lolcommits uses some external tool for taking images from webcam, but I'm pretty sure that cv2 also can do the trick. Hope it will help!

pyskell commented 8 years ago

Thank you all for the input and feedback.

There are two possible issues here:

  1. Your system did not have the necessary cascade file. I have adjusted the config to use the local copy. Please repull and test without making a change.
  2. If you're still having issues in a well and evenly lit area then please try adjusting camera_delay in slouchy.ini and let me know if that fixes the issue.
Outridair commented 8 years ago

Working on Mac OSX, setting the Camera deley to 15 did it for me :)

granteagon commented 8 years ago

@The-Outrider don't see camera delay as an option in the .ini. If you're talking about check_frequency, that didn't work for me.

Outridair commented 8 years ago

@granteagon did you git pull recently? (side note, I'm getting a lot of false positives, or my posture is really super bad... maybe because I have my laptop not at a 90 degree angle?)

pyskell commented 8 years ago

@The-Outrider try adjusting the allowed_variance setting in slouchy.ini

The default is set to only allow about 4% variance. Maybe around 0.1 will work for you.

Outridair commented 8 years ago

screen shot 2015-10-13 at 9 22 18 am Here's the debug i'm currently getting, and this is the initial setup when I execute the program.

Outridair commented 8 years ago

And then actual slouching after setup screen shot 2015-10-13 at 9 23 39 am

pyskell commented 8 years ago

I see, your webcam is much higher resolution than mine. So the math is thrown off.

I'm going to try a different way of calculating that is independent of webcam resolution.

granteagon commented 8 years ago

@The-Outrider that was it.. Weird. I cloned yesterday. I just deleted the repo and re-cloned and it worked! Awesome.

Outridair commented 8 years ago

Oh and that data is after upping the variance to .1 (forgot to mention I did as you requested ;))

pyskell commented 8 years ago

OK cool, btw a temporary fix right now is probably setting the variance to about 4.5

pyskell commented 8 years ago

@The-Outrider I've created a new testing branch, can you switch to that branch and let me know if it works better for you now? And provide the output?

For this one you should be able to set variance pretty low (0.02 to 0.1). You'll need to re-run Setup as well.

I've tested this on a 480p and 720p webcam, so hopefully it scales for other resolutions.

Outridair commented 8 years ago

Tested, here's the output. Used a variance of .02. Sat up straight the first time, and slouched the second.

screen shot 2015-10-13 at 12 09 45 pm
pyskell commented 8 years ago

Looks like it's working alright for you now. Just need to tweak the variance so it's a little more sensitive for you. Maybe 0.15 or so.

That part is more up to the user because everyone has a different point they'd consider slouching.

One last question. I see an Exception was thrown at the end. Do you have the full text of it and know if anything you did (such as Ctrl+C) caused it? Or did it just happen while the program was running? On Oct 13, 2015 3:10 PM, "David Rynearson" notifications@github.com wrote:

Tested, here's the output. Used a variance of .02. Sat up straight the first time, and slouched the second. [image: screen shot 2015-10-13 at 12 09 45 pm] https://cloud.githubusercontent.com/assets/6240904/10465374/6e0402bc-71a3-11e5-9dd2-13f9f0604ef5.png

— Reply to this email directly or view it on GitHub https://github.com/pyskell/slouchy/issues/1#issuecomment-147817734.

pyskell commented 8 years ago

Sorry... 0.015... On Oct 13, 2015 3:26 PM, "Anthony Lusardi" ajlusardi@gmail.com wrote:

Looks like it's working alright for you now. Just need to tweak the variance so it's a little more sensitive for you. Maybe 0.15 or so.

That part is more up to the user because everyone has a different point they'd consider slouching.

One last question. I see an Exception was thrown at the end. Do you have the full text of it and know if anything you did (such as Ctrl+C) caused it? Or did it just happen while the program was running? On Oct 13, 2015 3:10 PM, "David Rynearson" notifications@github.com wrote:

Tested, here's the output. Used a variance of .02. Sat up straight the first time, and slouched the second. [image: screen shot 2015-10-13 at 12 09 45 pm] https://cloud.githubusercontent.com/assets/6240904/10465374/6e0402bc-71a3-11e5-9dd2-13f9f0604ef5.png

— Reply to this email directly or view it on GitHub https://github.com/pyskell/slouchy/issues/1#issuecomment-147817734.

Outridair commented 8 years ago

Makes sense, :). Will tweak the variance.

screen shot 2015-10-13 at 1 10 34 pm

There's the screenshot of the exception. With Terminal/Macbook if I use Ctrl+Z to close the app down (Ctrl+C doesn't work in this case like it might in linux :)). Sometimes the program doesn't quit cleanly and I have to grab a process ID and kill -9 it.

So instead an icon appears in the top corner of the macbook, and I just quit the app from there.

screen shot 2015-10-13 at 1 13 17 pm
granteagon commented 8 years ago

@pyskell This could help with face detection possibly. https://developers.google.com/vision/