[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"; // »ÝÌæð\¦·éEBhE̼O
//char windowNameResult[] = "Result"; // wi·ªÊð\¦·éEBhE̼O
//char windowNameBackground[] = "Background"; // wiæð\¦·éEBhE̼O
@@ -57,16 +56,17 @@
IplImage *resultImage = NULL;
IplImage *outputImage = NULL;
-char *differenceMethod[3] = {
- "RGB̬ª²ÆÉ]¿",
- "CIE L*a*b* Å£ð]¿",
- "O[XP[Å]¿"
+//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[XP[Å]¿
};
-char *noiseMethod[3] = {
- "ȵ",
- "I[vjO",
- "fBAtB^"
+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; // wi·ªðs¤æðXV·é©Ç¤©
- differenceMode = COLOR_DIFFERENCE; // ·ªÌvZ[h
+ differenceMode = COLOR_DIFFERENCE; // ·ªÌvZ[h
noiseMode = NOISE_KEEP; // mCYð·é[h
g_temp_w = 0;
@@ -339,13 +339,6 @@
// »ÝÌæƵÄà1mÛ·é
//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( "wiæXV\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[ª³ê½çmCYû@ðÏX·é
- noiseMode = noiseMode + 1;
- if( noiseMode > NOISE_MEDIAN ){
- noiseMode = NOISE_KEEP;
- }
- printf( "mCYû@: %s\n", noiseMethod[noiseMode] );
- }
+ if(m_cont_mode == 'b'){
+ if(backgroundImage != NULL) {
+ cvReleaseImage(&backgroundImage);
+ }
+ backgroundImage = cvCloneImage(originalImage);
+ //backgroundImage = NULL;
+ printf( "Background image update\n" ); //wiæXV
- 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[ª³ê½çmCYû@ðÏX·é
+ noiseMode = noiseMode + 1;
+ if( noiseMode > NOISE_MEDIAN ){
+ noiseMode = NOISE_KEEP;
+ }
+ printf( "Noise removal method: %s\n", noiseMethod[noiseMode].c_str() ); //mCYû@
+ }
+ }
+
if(originalImage != NULL){
cvReleaseImage(&originalImage);
}
More information about the openrtm-commit
mailing list