cleanup. mostly notes, not code
authorozzloy <ozzloy@zero7.(none)>
Sun, 7 Feb 2010 09:16:07 +0000 (01:16 -0800)
committerozzloy <ozzloy@zero7.(none)>
Sun, 7 Feb 2010 09:16:07 +0000 (01:16 -0800)
separated README into {TODO,README,NOTES}
added oble.h
modified Makefile

.gitignore
Makefile
NOTES [new file with mode: 0644]
README
TODO [new file with mode: 0644]
activate_screensaver.bash [deleted file]
monitor_idle.pl [deleted file]
oble.cpp
oble.h [new file with mode: 0644]

index a32d98a06e83d59d51096698a0219500d563358d..c2d6ae6cda7798c4399bf7efb69fe982d3c79296 100644 (file)
@@ -1,4 +1,3 @@
 .*.sw?
-hello-world
-gnome-screensaver/
+oble
 
index 3f6e743dbd6ef72c4337639d02df530e986f1a58..7391fbda35eb0d6adb7ec3a76561b59eba955f3d 100644 (file)
--- 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 (file)
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 8fe0c862be4035535702f0fdfb0eb6a5a05cd120..7ca1538cb61db35f9847fc57ae5e4054c28b758b 100644 (file)
--- 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 (file)
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 (executable)
index f94b86f..0000000
+++ /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 (executable)
index 25eba62..0000000
+++ /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 (<IN>) {
-    if (m/^\s+boolean true/) {
-        `./hello-world`;
-    } elsif (m/^\s+boolean false/) {
-        print "*** Session is no longer idle ***\n";
-    }
-}
index c710b4ee4aedab91bc30b6d8efd4e694276803d2..ffc61f043191029890c37e4ff88915be3bf1f61f 100644 (file)
--- a/oble.cpp
+++ b/oble.cpp
 #include <stdio.h>
 #include <iostream>
 #include <time.h>
-
-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 (file)
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 <http://www.gnu.org/licenses/>.
+*/
+/*
+        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 <http://www.gnu.org/licenses/>.
+
+*/
+
+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);