[openrtm-commit:01130] r100 - in branches/newCMakeForVC2010/ImageProcessing/opencv/components/Dilationerosion: include/DilationErosion src

openrtm @ openrtm.org openrtm @ openrtm.org
2013年 10月 7日 (月) 17:00:30 JST


Author: kawauchi
Date: 2013-10-07 17:00:30 +0900 (Mon, 07 Oct 2013)
New Revision: 100

Modified:
   branches/newCMakeForVC2010/ImageProcessing/opencv/components/Dilationerosion/include/DilationErosion/DilationErosion.h
   branches/newCMakeForVC2010/ImageProcessing/opencv/components/Dilationerosion/src/DilationErosion.cpp
Log:
Dilationerosion component: Threshold has changed to the configuration and converted to the UTF-8 character code. refs #2704

Modified: branches/newCMakeForVC2010/ImageProcessing/opencv/components/Dilationerosion/include/DilationErosion/DilationErosion.h
===================================================================
--- branches/newCMakeForVC2010/ImageProcessing/opencv/components/Dilationerosion/include/DilationErosion/DilationErosion.h	2013-09-26 08:22:12 UTC (rev 99)
+++ branches/newCMakeForVC2010/ImageProcessing/opencv/components/Dilationerosion/include/DilationErosion/DilationErosion.h	2013-10-07 08:00:30 UTC (rev 100)
@@ -10,8 +10,7 @@
 #ifndef DILATIONEROSION_H
 #define DILATIONEROSION_H
 
-#define THRESHOLD	128			//	2’l‰»‚̍ۂÌ臒l
-#define THRESHOLD_MAX_VALUE	255	//	2’l‰»‚̍ۂɎg—p‚·‚éÅ‘å’l
+#define THRESHOLD_MAX_VALUE	255	//	2値化の際に使用する最大値
 
 #include <rtm/Manager.h>
 #include <rtm/DataFlowComponentBase.h>
@@ -22,7 +21,7 @@
 #include <rtm/idl/ExtendedDataTypesSkel.h>
 #include <rtm/idl/InterfaceDataTypesSkel.h>
 
-// OpenCVHeadƒtƒ@ƒCƒ‹‚ÌIncluding
+// OpenCVHeadファイルのIncluding
 #include <cv.h>
 #include <cxcore.h>
 #include <highgui.h>
@@ -234,27 +233,21 @@
   /*!
    * 
    * - Name:  count_dilation
-   * - DefaultValue: 1
+   * - DefaultValue: 3
    */
   int m_count_dilation;
   /*!
    * 
    * - Name:  count_erosion
-   * - DefaultValue: 1
+   * - DefaultValue: 3
    */
   int m_count_erosion;
   /*!
    * 
-   * - Name:  img_height
-   * - DefaultValue: 240
+   * - Name:  nThreshold
+   * - DefaultValue: 128
    */
-  int m_img_height;
-  /*!
-   * 
-   * - Name:  img_width
-   * - DefaultValue: 320
-   */
-  int m_img_width;
+  int m_nThreshold;
 
   // </rtc-template>
 

Modified: branches/newCMakeForVC2010/ImageProcessing/opencv/components/Dilationerosion/src/DilationErosion.cpp
===================================================================
--- branches/newCMakeForVC2010/ImageProcessing/opencv/components/Dilationerosion/src/DilationErosion.cpp	2013-09-26 08:22:12 UTC (rev 99)
+++ branches/newCMakeForVC2010/ImageProcessing/opencv/components/Dilationerosion/src/DilationErosion.cpp	2013-10-07 08:00:30 UTC (rev 100)
@@ -25,16 +25,15 @@
     "language",          "C++",
     "lang_type",         "compile",
     // Configuration variables
-    "conf.default.dilation_count", "1",
-    "conf.default.erosion_count", "1",
-    "conf.default.image_height", "240",
-    "conf.default.image_width", "320",
+    "conf.default.dilation_count", "3",
+    "conf.default.erosion_count", "3",
+    "conf.default.threshold", "128",
     // Widget
     "conf.__widget__.dilation_count", "text",
     "conf.__widget__.erosion_count", "text",
-    "conf.__widget__.image_height", "text",
-    "conf.__widget__.image_width", "text",
+    "conf.__widget__.threshold", "slider.1",
     // Constraints
+    "conf.__constraints__.threshold", "0<=x<=255",
     ""
   };
 // </rtc-template>
@@ -86,10 +85,9 @@
 
   // <rtc-template block="bind_config">
   // Bind variables and configuration variable
-  bindParameter("dilation_count", m_count_dilation, "1");
-  bindParameter("erosion_count", m_count_erosion, "1");
-  bindParameter("image_height", m_img_height, "240");
-  bindParameter("image_width", m_img_width, "320");
+  bindParameter("dilation_count", m_count_dilation, "3");
+  bindParameter("erosion_count", m_count_erosion, "3");
+  bindParameter("threshold", m_nThreshold, "128");
   // </rtc-template>
   
   return RTC::RTC_OK;
@@ -119,7 +117,7 @@
 
 RTC::ReturnCode_t DilationErosion::onActivated(RTC::UniqueId ec_id)
 {
-  //ƒCƒ[ƒW—pƒƒ‚ƒŠ‚ÌŠm•Û
+  //イメージ用メモリの確保
 	
 	m_image_buff = NULL;
 	m_gray_buff = NULL;
@@ -140,7 +138,7 @@
 
 RTC::ReturnCode_t DilationErosion::onDeactivated(RTC::UniqueId ec_id)
 {
-	//ƒƒ‚ƒŠ‰ð•ú
+	//メモリ解放
 	if(m_image_buff != NULL){
 		cvReleaseImage(&m_image_buff);
 	}
@@ -185,10 +183,10 @@
 RTC::ReturnCode_t DilationErosion::onExecute(RTC::UniqueId ec_id)
 {
 
-  //VƒCƒ[ƒW‚̃`ƒFƒbƒN
+  //新イメージのチェック
 	if(m_img_origIn.isNew()){
 
-		//ƒf[ƒ^‚̓ǂݍž‚Ý
+		//データの読み込み
 		m_img_origIn.read();
 
 		m_image_buff = cvCreateImage(cvSize(m_img_orig.width, m_img_orig.height), IPL_DEPTH_8U, 3);
@@ -204,46 +202,46 @@
 		m_ero_merge_img = cvCreateImage(cvSize(m_img_orig.width, m_img_orig.height), IPL_DEPTH_8U, 3);
 		m_noise_merge_img = cvCreateImage(cvSize(m_img_orig.width, m_img_orig.height), IPL_DEPTH_8U, 3);
 
-		// InPort‚̉f‘œƒf[ƒ^
+		// InPortの映像データ
 		memcpy(m_image_buff->imageData,(void *)&(m_img_orig.pixels[0]), m_img_orig.pixels.length());
 
-		//	BGR‚©‚çƒOƒŒ[ƒXƒP[ƒ‹‚É•ÏŠ·‚·‚é
+		//	BGRからグレースケールに変換する
 		cvCvtColor( m_image_buff, m_gray_buff, CV_BGR2GRAY );
 
-		//	ƒOƒŒ[ƒXƒP[ƒ‹‚©‚ç2’l‚É•ÏŠ·‚·‚é
-		cvThreshold( m_gray_buff, m_binary_buff, THRESHOLD, THRESHOLD_MAX_VALUE, CV_THRESH_BINARY );
+		//	グレースケールから2値に変換する
+		cvThreshold( m_gray_buff, m_binary_buff, m_nThreshold, THRESHOLD_MAX_VALUE, CV_THRESH_BINARY );
 
-		//Dilation/Erosion‚ðs‚Á‚ămƒCƒY‚ðÁ‚·
+		//Dilation/Erosionを行ってノイズを消す
 		cvDilate(m_binary_buff, m_dilation_buff, NULL, m_count_dilation);
 		cvErode(m_dilation_buff, m_erosion_buff, NULL, m_count_erosion);
 
-		//Dilation‚̂ݍs‚¤
+		//Dilationのみ行う
 		cvDilate(m_binary_buff, m_dilation_image, NULL, m_count_dilation);
 
-		//Erosion‚̂ݍs‚¤
+		//Erosionのみ行う
 		cvErode(m_binary_buff, m_erosion_image, NULL, m_count_erosion);
 		
-		// ‰æ‘œƒf[ƒ^‚̃TƒCƒYŽæ“¾
+		// 画像データのサイズ取得
 		double len = (m_output_image_buff->nChannels * m_output_image_buff->width * m_output_image_buff->height);
 		m_img_out.pixels.length(len);
 		m_img_dilation.pixels.length(len);
 		m_img_erosion.pixels.length(len);
 
-		//DilationImage‚ðƒ}[ƒW‚·‚é
+		//DilationImageをマージする
 		cvMerge(m_dilation_image, m_dilation_image, m_dilation_image, NULL, m_dila_merge_img);
 		
-		//ErosionImage‚ðƒ}[ƒW‚·‚é
+		//ErosionImageをマージする
 		cvMerge(m_erosion_image, m_erosion_image, m_erosion_image, NULL, m_ero_merge_img);
 
-		//ƒmƒCƒY‚ðÁ‚µ‚½Image‚ðƒ}[ƒW‚·‚é
+		//ノイズを消したImageをマージする
 		cvMerge(m_erosion_buff, m_erosion_buff, m_erosion_buff, NULL, m_noise_merge_img);
 		
-		// ŠY“–‚̃Cƒ[ƒW‚ðMemCopy‚·‚é
+		// 該当のイメージをMemCopyする
 		memcpy((void *)&(m_img_out.pixels[0]), m_noise_merge_img->imageData, len);
 		memcpy((void *)&(m_img_dilation.pixels[0]), m_dila_merge_img->imageData, len);
 		memcpy((void *)&(m_img_erosion.pixels[0]), m_ero_merge_img->imageData, len);
 		
-		// ”½“]‚µ‚½‰æ‘œƒf[ƒ^‚ðOutPort‚©‚ço—Í‚·‚éB
+		// 反転した画像データをOutPortから出力する。
 		m_img_out.width = m_image_buff->width;
 		m_img_out.height = m_image_buff->height;
 



More information about the openrtm-commit mailing list