From: Petr Kubiznak Date: Wed, 26 May 2010 13:34:33 +0000 (+0200) Subject: All debug messages to error output. X-Git-Tag: start2011~42 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/eurobot/public.git/commitdiff_plain/eed8d843b871ba74f3f0537c9e862417e207c074 All debug messages to error output. --- diff --git a/src/camera/rozkuk/rozkuk.cxx b/src/camera/rozkuk/rozkuk.cxx index d56d6d04..4c5ccc4c 100644 --- a/src/camera/rozkuk/rozkuk.cxx +++ b/src/camera/rozkuk/rozkuk.cxx @@ -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, ¢erDist); //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;