gcc $(LDFLAGS) -o $@ $(OBJS)
test: all
- ./oble /usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml
+ ./oble -c /usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml
clean:
rm -rf oble *.o
* 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.
- * possibly this is how kreed's version works. read kreed's code to find out
- * that way the camera isn't running all the time
- * maybe start 10 seconds before going inactive, then run until activity, or 10
- seconds, whichever's first.
-* 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 profile.
-* 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
+++ /dev/null
-#! /usr/bin/env python
-#inhibit then uninhibit gnome-screensaver. this is a kludge for
-#SimulateUserActivity
-#Copyright 2010 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/>.
-
-'''
-
-
-
-import dbus
-import dbus.glib
-import sys
-import time
-
-def inhibit():
- try:
- bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
- devobj = bus.get_object('org.gnome.ScreenSaver', '/org/gnome/ScreenSaver')
- dev = dbus.Interface(devobj, "org.gnome.ScreenSaver")
- cookie = dev.Inhibit('gss-poke', 'SimulateUserActivity kludge')
- print "gnome screensaver inhibited."
- return (dev, cookie)
- except Exception, e:
- print "could not send the dbus Inhibit signal: %s" % e
- return (False, False)
-
-def uninhibit(dev, cookie):
- try:
- dev.UnInhibit(cookie)
- print "gnome screensaver enabled."
- return(True)
- except Exception, e:
- print "could not send the dbus UnInhibit signal: %s" % e
- return (False)
-
-if __name__ == '__main__':
- (dev, cookie) = inhibit()
- time.sleep(0.1)
- uninhibit(dev, cookie)
- sys.exit(0)
#include <stdio.h>
#include <iostream>
#include <time.h>
+#include <unistd.h>
#include "oble.h"
#include "idle_x11.h"
using namespace std;
+static string cascade_filename = "";
+
// argument for cvFlip(src, dest, FLIP_TYPE)
#define MIRROR 1
}
}
+int parse_opts(int argc, char **argv)
+{
+ int index, c;
+ //int opterr=0, optopt=0, optind=0;
+ //char *optarg;
+ // int getopt(int argc, char **argv, const char *options);
+ opterr = 0;
+ const char *options = "c:";
+ while((c = getopt(argc, argv, options)) != -1)
+ switch(c)
+ {
+ case 'c':
+ cascade_filename = string(optarg);
+ printf("option c, argument = %s\n", optarg);
+ case '?':
+ if(optopt == 'c')
+ printf("option -%c requires an argument.\n", optopt);
+ else if(isprint (optopt))
+ printf("unknown option `-%c'.\n", optopt);
+ else
+ printf("unknown option char `\\x%x'.\n", optopt);
+ goto known_args_processed;
+ default:
+ abort();
+ }
+known_args_processed:
+
+ for(index = optind; index < argc; index++)
+ printf("Non-option arg %s\n", argv[index]);
+
+ return 0;
+}
+
// A Simple Camera Capture Framework.
int main(int argc, char** argv)
{
- CvHaarClassifierCascade* cascade = load_object_detector(argv[1]);
+ if(parse_opts(argc, argv)) return 0;
+
+ if(cascade_filename == "") cascade_filename = string(argv[1]);
+ CvHaarClassifierCascade* cascade =
+ load_object_detector(cascade_filename.c_str());
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
if(!capture) {
void screensave(time_t t_current);
-bool parse_opts(int argc, char **argv);
+int parse_opts(int argc, char **argv);