yeah! it simulates the user activity! woo! awesome
authorozzloy <ozzloy+github_com@gmail.com>
Thu, 26 Feb 2009 08:18:05 +0000 (00:18 -0800)
committerozzloy <ozzloy+github_com@gmail.com>
Thu, 26 Feb 2009 08:18:05 +0000 (00:18 -0800)
.gitignore [new file with mode: 0644]
Makefile
hello-world.cpp

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..3268211
--- /dev/null
@@ -0,0 +1 @@
+.*.sw?
index 4463e6afeda9931fafe7a76b6c1f72aed60c2eff..fd1361f0d5a9270af520d369adbaf0720b6136a6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,3 +8,8 @@ dbushello: dbushello.c
 
 test: all
        ./hello-world /usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml
+
+clean:
+       rm -rf hello-world tags dbushello
+
+.PHONY: clean
index 2fd2156d209812545257a9ae4d506899f9deb185..045c11442a759cdf7322363af28cb3c58111a520 100644 (file)
@@ -1,28 +1,31 @@
 //use the camera to aid the decision to sleep.
 //Copyright 2009 Daniel Watson
 /*
-    This file is part of oble.
+        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 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.
+        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/>.
+        You should have received a copy of the GNU General Public License
+        along with oble.  If not, see <http://www.gnu.org/licenses/>.
 
- */
+*/
 #include <cv.h>
 #include <highgui.h>
 #include <stdio.h>
+#include <iostream>
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib.h>
 
+using namespace std;
+
 DBusGConnection *connection;
 GError *error;
 DBusGProxy *proxy;
@@ -31,7 +34,7 @@ char **name_list_ptr;
 
 
 // argument for cvFlip(src, dest, FLIP_TYPE)
-#define VERTICAL_FLIP 1
+#define MIRROR 1
 
 CvHaarClassifierCascade* load_object_detector(const char* cascade_path)
 {
@@ -61,29 +64,10 @@ void detect_and_draw_objects(IplImage* image,
        faces = cvHaarDetectObjects(small_image, cascade, storage, 1.2, 2,
                        CV_HAAR_DO_CANNY_PRUNING);
 
-#if 0
-       if ( 0 < faces->total &&
-                       !dbus_g_proxy_call (proxy, "SimulateUserActivity", &error, G_TYPE_INVALID,
-                               G_TYPE_STRV, &name_list, G_TYPE_INVALID))
-       {
-               fprintf(stderr, "bananas");
-
-               /* Just do demonstrate remote exceptions versus regular GError */
-               if (error->domain == DBUS_GERROR &&
-                               error->code == DBUS_GERROR_REMOTE_EXCEPTION)
-                       g_printerr ("Caught remote method exception %s: %s",
-                                       dbus_g_error_get_name (error),
-                                       error->message);
-               else
-                       g_printerr ("Error: %s\n", error->message);
-               g_error_free (error);
-               exit (1);
-       }
-       else
+       if(0 < faces->total)
        {
-               fprintf(stderr, "peaches");
+               dbus_g_proxy_call_no_reply(proxy, "SimulateUserActivity", G_TYPE_INVALID);
        }
-#endif
 
        /* draw all the rectangles */
        for(i = 0; i < faces->total; i++)
@@ -128,7 +112,7 @@ int main(int argc, char** argv)
 
        CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
        if(!capture) {
-               fprintf(stderr, "ERROR: capture is NULL \n");
+               cerr << "ERROR: capture is NULL " << endl;
                getchar();
                return -1;
        }
@@ -138,7 +122,7 @@ int main(int argc, char** argv)
 
        IplImage* frame = cvQueryFrame(capture);
        if(!frame) {
-               fprintf(stderr, "ERROR: frame is null...\n");
+               cerr << "ERROR: frame is null..." << endl;
                getchar();
                return -1;
        }
@@ -149,13 +133,13 @@ int main(int argc, char** argv)
                // Get one frame
                frame = cvQueryFrame(capture);
                if(!frame) {
-                       fprintf(stderr, "ERROR: frame is null...\n");
+                       cerr << "ERROR: frame is null..." << endl;
                        getchar();
                        break;
                }
 
                //flip the image so displayed right/left corresponds to physical right/left
-               cvFlip(frame, mirrored, VERTICAL_FLIP);
+               cvFlip(frame, mirrored, MIRROR);
 
                detect_and_draw_objects(mirrored, cascade, 1);
                cvShowImage("mywindow", mirrored);