[openrtm-commit:01123] r93 - branches/newCMakeForVC2010/ImageProcessing/opencv/components/BackGroundSubtractionSimple/src

openrtm @ openrtm.org openrtm @ openrtm.org
2013年 8月 29日 (木) 17:20:09 JST


Author: kawauchi
Date: 2013-08-29 17:20:09 +0900 (Thu, 29 Aug 2013)
New Revision: 93

Modified:
   branches/newCMakeForVC2010/ImageProcessing/opencv/components/BackGroundSubtractionSimple/src/BackGroundSubtractionSimple.cpp
Log:
Method of mode specification has been changed from key input to config. Configuration Widget has been changed from text to radio. refs #2704

Modified: branches/newCMakeForVC2010/ImageProcessing/opencv/components/BackGroundSubtractionSimple/src/BackGroundSubtractionSimple.cpp
===================================================================
--- branches/newCMakeForVC2010/ImageProcessing/opencv/components/BackGroundSubtractionSimple/src/BackGroundSubtractionSimple.cpp	2013-08-28 05:10:25 UTC (rev 92)
+++ branches/newCMakeForVC2010/ImageProcessing/opencv/components/BackGroundSubtractionSimple/src/BackGroundSubtractionSimple.cpp	2013-08-29 08:20:09 UTC (rev 93)
@@ -25,20 +25,19 @@
     "language",          "C++",
     "lang_type",         "compile",
     // Configuration variables
-    "conf.default.control_mode", "a",
+    "conf.default.control_mode", "b",
     "conf.default.image_height", "240",
     "conf.default.image_width", "320",
     // Widget
-    "conf.__widget__.control_mode", "text",
+    "conf.__widget__.control_mode", "radio",
     "conf.__widget__.image_height", "text",
     "conf.__widget__.image_width", "text",
     // Constraints
+    "conf.__constraints__.control_mode", "(b,m,n)",
     ""
   };
 // </rtc-template>
 
-int key;
-
 //char windowNameCurrent[] = "Current";		//	Œ»Ý‚̉摜‚ð•\Ž¦‚·‚éƒEƒBƒ“ƒhƒE‚Ì–¼‘O
 //char windowNameResult[] = "Result";			//	”wŒi·•ªŒ‹‰Ê‚ð•\Ž¦‚·‚éƒEƒBƒ“ƒhƒE‚Ì–¼‘O
 //char windowNameBackground[] = "Background";	//	”wŒi‰æ‘œ‚ð•\Ž¦‚·‚éƒEƒBƒ“ƒhƒE‚Ì–¼‘O
@@ -57,16 +56,17 @@
 IplImage *resultImage = NULL;
 IplImage *outputImage = NULL;
 
-char *differenceMethod[3] = {
-	"RGB‚̐¬•ª‚²‚Æ‚É•]‰¿",
-	"CIE L*a*b* ‚Å‹——£‚ð•]‰¿",
-	"ƒOƒŒ[ƒXƒP[ƒ‹‚Å•]‰¿"
+//char *differenceMethod[3] = {
+std::string differenceMethod[3] = {
+	"Evaluate each component of RGB",  //RGB‚̐¬•ª‚²‚Æ‚É•]‰¿
+	"Evaluate the distance in CIE L * a * b *",  //CIE L*a*b* ‚Å‹——£‚ð•]‰¿
+	"Evaluated by gray scale"  //ƒOƒŒ[ƒXƒP[ƒ‹‚Å•]‰¿
 };
 
-char *noiseMethod[3] = {
-	"‚È‚µ",
-	"ƒI[ƒvƒjƒ“ƒO",
-	"ƒƒfƒBƒAƒ“ƒtƒBƒ‹ƒ^"
+std::string noiseMethod[3] = {
+	"None",
+	"Opening",
+	"Median filter"
 };
 
 void colorDifference( IplImage *currentImage, IplImage *backgroundImage, IplImage *resultImage ){
@@ -255,7 +255,7 @@
 RTC::ReturnCode_t BackGroundSubtractionSimple::onActivated(RTC::UniqueId ec_id)
 {	
 	captureOn = CAPTURE_ON;				//	”wŒi·•ª‚ðs‚¤‰æ‘œ‚ðXV‚·‚é‚©‚Ç‚¤‚©
-    differenceMode = COLOR_DIFFERENCE;	//	·•ª‚ÌŒvŽZƒ‚[ƒh
+  differenceMode = COLOR_DIFFERENCE;	//	·•ª‚ÌŒvŽZƒ‚[ƒh
 	noiseMode = NOISE_KEEP;				//	ƒmƒCƒY‚ðœ‹Ž‚·‚郂[ƒh
 
 	g_temp_w = 0;
@@ -339,13 +339,6 @@
 		//	Œ»Ý‚̉摜‚Æ‚µ‚Ä‚à1–‡Šm•Û‚·‚é
 		//currentImage = cvCloneImage( originalImage );
 
-		//Key“ü—ÍRead
-		if(m_keyIn.isNew()){
-			m_keyIn.read();
-			//Int‚É•ÏŠ·
-			key = (int)m_key.data;
-		}
-		
 		//InPort‚̉f‘œ‚̎擾
 		memcpy(originalImage->imageData,(void *)&(m_img_orig.pixels[0]),m_img_orig.pixels.length());
 
@@ -414,41 +407,35 @@
 		//cvShowImage( windowNameCurrent, currentImage );
 		//cvShowImage( windowNameResult, resultImage );
 		//cvShowImage( windowNameBackground, backgroundImage );
+				
+		//Key“ü—ÍRead
+		if(m_keyIn.isNew()){
+			m_keyIn.read();
 		
-		//key = cvWaitKey(1);
-		cvWaitKey(1);
-		
-		if(key == 'b'){
-			if(backgroundImage != NULL) {
-				cvReleaseImage(&backgroundImage);
-			}
-			backgroundImage = cvCloneImage(originalImage);
-			//backgroundImage = NULL;
-			printf( "”wŒi‰æ‘œXV\n" );
-		}else if(key == ' '){
-			captureOn = 1 - captureOn;
-			if(captureOn == CAPTURE_ON){
-				printf("‰f‘œŽæ“¾FON\n");
-			}else if(captureOn == CAPTURE_OFF){
-				printf("‰f‘œŽæ“¾FOFF\n");
-			}
-		}else if(key == 'm'){
-			differenceMode = differenceMode + 1;
-			if( differenceMode > GRAY_DIFFERENCE ){
-				differenceMode = COLOR_DIFFERENCE;
-			}
-			printf( "·‚Ì•]‰¿•û–@: %s\n", differenceMethod[differenceMode] );
-		}else if( key == 'n' ){ 
-			//	'n'ƒL[‚ª‰Ÿ‚³‚ꂽ‚çƒmƒCƒYœ‹Ž•û–@‚ð•ÏX‚·‚é
-			noiseMode = noiseMode + 1;
-			if( noiseMode > NOISE_MEDIAN ){
-				noiseMode = NOISE_KEEP;
-			}
-			printf( "ƒmƒCƒYœ‹Ž•û–@: %s\n", noiseMethod[noiseMode] );
-		}
+		  if(m_cont_mode == 'b'){
+			  if(backgroundImage != NULL) {
+				  cvReleaseImage(&backgroundImage);
+			  }
+			  backgroundImage = cvCloneImage(originalImage);
+			  //backgroundImage = NULL;
+			  printf( "Background image update\n" );   //”wŒi‰æ‘œXV
 
-		key = '0';
-
+		  }else if(m_cont_mode == 'm'){
+			  differenceMode = differenceMode + 1;
+			  if( differenceMode > GRAY_DIFFERENCE ){
+				  differenceMode = COLOR_DIFFERENCE;
+			  }
+			  printf( "Evaluation method of difference: %s\n", differenceMethod[differenceMode].c_str() );   //·‚Ì•]‰¿•û–@
+		  }else if( m_cont_mode == 'n' ){ 
+			  //	'n'ƒL[‚ª‰Ÿ‚³‚ꂽ‚çƒmƒCƒYœ‹Ž•û–@‚ð•ÏX‚·‚é
+			  noiseMode = noiseMode + 1;
+			  if( noiseMode > NOISE_MEDIAN ){
+				  noiseMode = NOISE_KEEP;
+			  }
+			  printf( "Noise removal method: %s\n", noiseMethod[noiseMode].c_str() );  //ƒmƒCƒYœ‹Ž•û–@
+		  }
+		}
+		
 		if(originalImage != NULL){
 			cvReleaseImage(&originalImage);
 		}



More information about the openrtm-commit mailing list