]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
All debug messages to error output.
authorPetr Kubiznak <kubizpet@fel.cvut.cz>
Wed, 26 May 2010 13:34:33 +0000 (15:34 +0200)
committerPetr Kubiznak <kubizpet@fel.cvut.cz>
Wed, 26 May 2010 13:34:33 +0000 (15:34 +0200)
src/camera/rozkuk/rozkuk.cxx

index d56d6d0443e6dbb44f1bc442d2ec5e6bd035d8b7..4c5ccc4cac9f9bfdb4de30bc5fe59f71af101f8b 100644 (file)
@@ -245,7 +245,7 @@ int modeRealtime(CvCapture* capture) {
 
                frame = cvQueryFrame(capture);                      // Get one frame
                if(!frame) {
-                       fprintf(stdout, "NULL frame\n");
+                       fprintf(stderr, "NULL frame\n");
                        continue;
                }
 
@@ -312,10 +312,11 @@ int modeRecognize(CvCapture* capture) {
 #endif                    /*----------- DEBUG SESSION ONLY -----------*/
                        frame = cvQueryFrame(capture);
                if(!frame) {
-                       fprintf(stdout, "NULL frame\n");
+                       fprintf(stderr, "NULL frame\n");
                        // save error code to orte and publish it
                        orte.camera_result.error |= camera_ERR_NO_FRAME;
                        ORTEPublicationSend(orte.publication_camera_result);
+                       usleep(100*1000);
                        continue;
                } else if(orte.camera_result.error & camera_ERR_NO_FRAME) {
                        orte.camera_result.error &= ~camera_ERR_NO_FRAME;
@@ -336,7 +337,7 @@ int modeRecognize(CvCapture* capture) {
                sideConfig = recognize(floatMat, sideMasks, SIDEMASKSCNT, &sideDist);
                centerConfig = recognize(floatMat, centerMasks, CENTERMASKSCNT, &centerDist);
                //publish results
-               fprintf(stdout, "thr: %d, side: %d (%f), center: %d (%f)\n", threshold, sideConfig, sideDist, centerConfig, centerDist);
+               fprintf(stderr, "thr: %d, side: %d (%f), center: %d (%f)\n", threshold, sideConfig, sideDist, centerConfig, centerDist);
                orte.camera_result.side = sideConfig;
                orte.camera_result.center = centerConfig;
                orte.camera_result.sideDist = sideDist;
@@ -386,7 +387,7 @@ int modeWait(CvCapture *capture) {
 
                }
 #endif                    /*----------- DEBUG SESSION ONLY -----------*/
-               fprintf(stdout, "waiting...\n");
+               fprintf(stderr, "waiting...\n");
                sleep(1);
        }
        return MODE_RECOGNIZE;
@@ -403,12 +404,14 @@ int modeManager(int defaultMode) {
 
        // connect to a camera
        while(!((capture=cvCaptureFromCAM(0)) || (capture=cvCaptureFromCAM(1)))) {
-               fprintf(stdout, "NULL capture (is camera connected?)\n");
+               fprintf(stderr, "NULL capture (is camera connected?)\n");
                orte.camera_result.error |= camera_ERR_NO_VIDEO;
-               sleep(1);
+               ORTEPublicationSend(orte.publication_camera_result);
+               usleep(500*1000);
        }
        orte.camera_result.error &= ~camera_ERR_NO_VIDEO;
-       fprintf(stdout, "rozkuk started, camera connected successfully\n");
+       ORTEPublicationSend(orte.publication_camera_result);
+       fprintf(stderr, "rozkuk started, camera connected successfully\n");
 
 #ifdef ROZKUK_DEBUG       /************ DEBUG SESSION ONLY ************/
        // create gui windows and init font
@@ -502,7 +505,7 @@ int loadMask(const char *filename, CvMat **mask) {
        
        IplImage *img = cvLoadImage(filename, CV_LOAD_IMAGE_GRAYSCALE);
        if(!img) {
-               fprintf(stdout, "Mask %s cannot be loaded.\n", filename);
+               fprintf(stderr, "Mask %s cannot be loaded.\n", filename);
                fprintf(stderr, "Run me from _build/user/camera/rozkuk\n");
                return 0;
        }
@@ -511,7 +514,7 @@ int loadMask(const char *filename, CvMat **mask) {
        if(!(len=clr2float(img, mask, CL_NEUTRAL, 1.0, NULL)))
                fprintf(stderr, "A problem while converting mask to float occured.\n");
        else
-               fprintf(stdout, "Mask %s successfully loaded.\n", filename);
+               fprintf(stderr, "Mask %s successfully loaded.\n", filename);
 
        cvReleaseImage(&img);
        return len;