]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
camera/color-finder: system on/off
authorMonika Svedirohova <svedimon@fel.cvut.cz>
Sat, 29 Sep 2012 14:54:13 +0000 (16:54 +0200)
committerMonika Svedirohova <svedimon@fel.cvut.cz>
Sat, 29 Sep 2012 14:54:13 +0000 (16:54 +0200)
src/camera/color-finder/main/revue.cpp

index a30403af04c4b353dac3d53f803d16bd592a54c8..8a834cf660121f0b3722a04363793931abfc6165 100644 (file)
@@ -4,6 +4,7 @@
 #include <CRobot.h>
 #include <CTimer.h>
 #include <CRecognition.h>
+#include <signal.h>
 
 int i = 0;
 int numSaved = 0;
@@ -21,7 +22,7 @@ bool move = false;
 Uint8 lastKeys[10000];
 int keyNumber = 1000;
 Uint8 *keys = NULL;
-bool picture = true;
+
 
 void processKeys()
 {
@@ -42,6 +43,10 @@ void processKeys()
        if (keys[SDLK_RETURN])image->saveBmp();
        memcpy(lastKeys,keys,keyNumber);
 }
+static void sig_handler(int sig)
+{
+        stop = true;
+}
 
 void controlExposition(CRawImage *img, CCamera *camera) {
        
@@ -81,8 +86,11 @@ int main(int argc,char* argv[])
                fprintf(stderr,"usage: %s cameraDevice \ne.g. %s /dev/video0\n",argv[0],argv[0]);
                return 0;
        }
- while(picture){
 
+  // Signal handler registration
+    signal(SIGINT, sig_handler);
+    signal(SIGTERM, sig_handler);
+    
        const char* cameraDevice = argv[1];
        //const char* robotDevice = argv[2];
 
@@ -142,9 +150,9 @@ int main(int argc,char* argv[])
                if (i > 100) {
                        controlExposition(image,camera);        
                }
-            
+        
        } 
- }
        delete recognition;
        //delete robot;
        delete image;