From: ozzloy Date: Sun, 7 Feb 2010 09:16:07 +0000 (-0800) Subject: cleanup. mostly notes, not code X-Git-Url: http://challenge-bot.com/repos/?p=ozzloy%40gmail.com%2Foble;a=commitdiff_plain;h=124727d2f74737f74687c15ff824758dbebe7146 cleanup. mostly notes, not code separated README into {TODO,README,NOTES} added oble.h modified Makefile --- diff --git a/.gitignore b/.gitignore index a32d98a..c2d6ae6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .*.sw? -hello-world -gnome-screensaver/ +oble diff --git a/Makefile b/Makefile index 3f6e743..7391fbd 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,14 @@ -all:oble +all: oble -oble:oble.cpp - gcc `pkg-config --cflags opencv dbus-glib-1` -o oble oble.cpp `pkg-config --libs dbus-glib-1 opencv` - -gnome-screensaver-poke: gnome-screensaver-poke.c - gcc `pkg-config --cflags dbus-glib-1` -o gnome-screensaver-poke gnome-screensaver-poke.c `pkg-config --libs dbus-glib-1` +oble: oble.cpp oble.h + gcc `pkg-config --cflags opencv` -o oble oble.cpp `pkg-config --libs opencv` test: all ./oble /usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml clean: - rm -rf oble gnome-screensaver-poke + rm -rf oble new: clean all diff --git a/NOTES b/NOTES new file mode 100644 index 0000000..7554836 --- /dev/null +++ b/NOTES @@ -0,0 +1,10 @@ +(screensaver activation and deactivation) has 2 managers right now. oble and +gnome-screensaver have independent criteria for activation and deactivation. +oble relies only on time since face detected, gss relies on time since keyboard +or mouse state change. this causes annoying problems. + * example: gss activates screensaver on timeout even though face is clearly + detected the whole time. + * workaround: make gss timeout be as long as possible +there are other problems. +the real fix is to combine the two. user activity should be any of {keyboard, +mouse, face detection}. diff --git a/README b/README index 8fe0c86..7ca1538 100644 --- a/README +++ b/README @@ -1,28 +1,5 @@ prevent the system from sleeping when a user is looking at the screen. -this is accomplished using the built-in camera on my laptop screen's top bezel -and opencv to detect a face. i'm going to use the API used by the default movie -player in ubuntu for preventing system sleeps. +this is accomplished using a camera and opencv to detect a face. -OTHER IDEAS: -* detecting a face could simulate user activity. this would prevent sleeping -and bring up the password prompt when the system is already asleep. - * how cool would that be? if the system is asleep and you sit down at it, the - password prompt comes up before you touch anything! - * or if the screen saver doesn't lock the screen, then the laptop just wakes - up. - * DONE! -* fire up the face detector only just before going to inactive mode. - * that way the camera isn't running all the time - * maybe start 10 seconds before going inactive, then run until activity -* authenticating a user based on face recognition (as opposed to face -detection) - * much more difficult to do reliably -* be more aggressive with turning off the screen. dim the screen as soon as -it's not being looked at. turn it off soon thereafter. - * could be enough to save battery. would need to power the camera sometimes, - but would save on backlight. need to test. -* don't prevent sleep when face is detected, but user isn't actually looking at -screen. - * requires pose estimation. - * also requires estimating the direction of the eye. +this readme is woefully short. feel free to write more diff --git a/TODO b/TODO new file mode 100644 index 0000000..34ac061 --- /dev/null +++ b/TODO @@ -0,0 +1,40 @@ +FOR SCREENSAVER: +* use [Un]Inhibit together as a SimulateUserActivity workalike +* xdg-screensaver suspend / resume to SimulateUserActivity + * http://tronche.com/gui/x/xlib-tutorial/2nd-program-anatomy.html + * http://portland.freedesktop.org/xdg-utils-1.0beta3/xdg-screensaver.html +* SimulateUserActivity + * does it work on other people's machines? + * find if other people have their gnome-screensaver run even if they set + screensaver timeout to 1 minute and run: + for ((i = 0; i < 999; i++)); do + sleep 50; + gnome-screensaver-command --poke; + done; + * find irc channel to ask if my understanding is correct + * file bug + * track down bug + * compile gnome-screensaver +* cli opt parse + * quiet mode + * no display window + * no text printed to terminal +* fire up the face detector only just before going to inactive mode. + * that way the camera isn't running all the time + * maybe start 10 seconds before going inactive, then run until activity +* be more aggressive with turning off the screen. dim the screen as soon as +it's not being looked at. turn it off soon thereafter. + * could be enough to save battery. would need to power the camera sometimes, + but would save on backlight. need to test. +* don't prevent sleep when face is detected, but user isn't actually looking at +screen. + * requires pose estimation. + * also requires estimating the direction of the eye. + +OTHER IDEAS: +* authenticating a user based on face recognition (as opposed to face +detection) + * much more difficult to do reliably + * use object tracking and emotion estimation to require a set of facial + expressions as authentication. + * awesome for people who find typing hard, eg: no hands diff --git a/activate_screensaver.bash b/activate_screensaver.bash deleted file mode 100755 index f94b86f..0000000 --- a/activate_screensaver.bash +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -gnome-screensaver-command -a diff --git a/monitor_idle.pl b/monitor_idle.pl deleted file mode 100755 index 25eba62..0000000 --- a/monitor_idle.pl +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env perl - -my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\""; - -open (IN, "$cmd |"); - -while () { - if (m/^\s+boolean true/) { - `./hello-world`; - } elsif (m/^\s+boolean false/) { - print "*** Session is no longer idle ***\n"; - } -} diff --git a/oble.cpp b/oble.cpp index c710b4e..ffc61f0 100644 --- a/oble.cpp +++ b/oble.cpp @@ -39,10 +39,7 @@ #include #include #include - -static time_t t_last = time(NULL); -static time_t t_current = time(NULL); -static time_t t_tmp = time(NULL); +#include "oble.h" using namespace std; diff --git a/oble.h b/oble.h new file mode 100644 index 0000000..3e900f0 --- /dev/null +++ b/oble.h @@ -0,0 +1,51 @@ +//use the camera to aid the decision to sleep. +//Copyright 2009 Daniel Watson +/* + use a camera to prevent screensaver + Copyright (C) 2009 daniel watson, ozzloy@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/* + This file is part of oble. + + oble is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + oble is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with oble. If not, see . + +*/ + +static time_t t_current = time(NULL); + +// argument for cvFlip(src, dest, FLIP_TYPE) +#define MIRROR 1 + +CvHaarClassifierCascade* load_object_detector(const char* cascade_path); + +void detect_and_draw_objects(IplImage* image, + CvHaarClassifierCascade* cascade, + int do_pyramids); + +void screensave(time_t t_current); + +bool parse_opts(int argc, char **argv);