[openrtm-commit:01131] r101 - in branches/newCMakeForVC2010/ImageProcessing/opencv/components/Edge: include/Edge src

openrtm @ openrtm.org openrtm @ openrtm.org
2013年 10月 10日 (木) 15:24:45 JST


Author: kawauchi
Date: 2013-10-10 15:24:45 +0900 (Thu, 10 Oct 2013)
New Revision: 101

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

Modified: branches/newCMakeForVC2010/ImageProcessing/opencv/components/Edge/include/Edge/Edge.h
===================================================================
--- branches/newCMakeForVC2010/ImageProcessing/opencv/components/Edge/include/Edge/Edge.h	2013-10-07 08:00:30 UTC (rev 100)
+++ branches/newCMakeForVC2010/ImageProcessing/opencv/components/Edge/include/Edge/Edge.h	2013-10-10 06:24:45 UTC (rev 101)
@@ -24,14 +24,10 @@
 #include <cxcore.h>
 #include <highgui.h>
 
-#define SOBEL_X_APERTURE_SIZE	3	//	SobelƒIƒyƒŒ[ƒ^‚̃TƒCƒY (ƒŠƒtƒ@ƒŒƒ“ƒXŽQÆ)
-#define SOBEL_Y_APERTURE_SIZE	3	//	SobelƒIƒyƒŒ[ƒ^‚̃TƒCƒY (ƒŠƒtƒ@ƒŒƒ“ƒXŽQÆ)
-#define LAPLACIAN_APERTURE_SIZE	3	//	LaplacianƒIƒyƒŒ[ƒ^‚̃TƒCƒY (ƒŠƒtƒ@ƒŒƒ“ƒXŽQÆ)
+//	cvConvertScaleAbs用定数
+#define SCALE	1					//	ScaleAbsä¿‚æ•°
+#define	SHIFT	0					//	スケーリングした入力配列の要素に加える値
 
-//	cvConvertScaleAbs—p’萔
-#define SCALE	1					//	ScaleAbsŒW”
-#define	SHIFT	0					//	ƒXƒP[ƒŠƒ“ƒO‚µ‚½“ü—Í”z—ñ‚Ì—v‘f‚ɉÁ‚¦‚é’l
-
 // Service implementation headers
 // <rtc-template block="service_impl_h">
 
@@ -236,7 +232,24 @@
 
   // Configuration variable declaration
   // <rtc-template block="config_declare">
-
+  /*!
+   * 
+   * - Name:  sobel_x_size
+   * - DefaultValue: 3
+   */
+  int m_sobel_x_size;
+  /*!
+   * 
+   * - Name:  sobel_y_size
+   * - DefaultValue: 3
+   */
+  int m_sobel_y_size;
+  /*!
+   * 
+   * - Name:  laplacian_size
+   * - DefaultValue: 3
+   */
+  int m_laplacian_size;
   // </rtc-template>
 
   // DataInPort declaration
@@ -289,7 +302,7 @@
   // <rtc-template block="private_operation">
   
   // </rtc-template>
-  IplImage* imageBuff;					// ƒJƒƒ‰ƒCƒ[ƒW
+  IplImage* imageBuff;					// カメライメージ
   IplImage* grayImage;
   IplImage* destinationImage_x;
   IplImage* destinationImage_y;

Modified: branches/newCMakeForVC2010/ImageProcessing/opencv/components/Edge/src/Edge.cpp
===================================================================
--- branches/newCMakeForVC2010/ImageProcessing/opencv/components/Edge/src/Edge.cpp	2013-10-07 08:00:30 UTC (rev 100)
+++ branches/newCMakeForVC2010/ImageProcessing/opencv/components/Edge/src/Edge.cpp	2013-10-10 06:24:45 UTC (rev 101)
@@ -27,6 +27,18 @@
     "max_instance",      "1",
     "language",          "C++",
     "lang_type",         "compile",
+    // Configuration variables
+    "conf.default.sobel_x_size", "3",
+    "conf.default.sobel_y_size", "3",
+    "conf.default.laplacian_size", "3",
+    // Widget
+    "conf.__widget__.sobel_x_size", "radio",
+    "conf.__widget__.sobel_y_size", "radio",
+    "conf.__widget__.laplacian_size", "radio",
+    // Constraints
+    "conf.__constraints__.sobel_x_size", "(1,3,5,7)",
+    "conf.__constraints__.sobel_y_size", "(1,3,5,7)",
+    "conf.__constraints__.laplacian_size", "(1,3,5,7)",
     ""
   };
 // </rtc-template>
@@ -77,6 +89,9 @@
   // </rtc-template>
 
   // <rtc-template block="bind_config">
+  bindParameter("sobel_x_size", m_sobel_x_size, "3");
+  bindParameter("sobel_y_size", m_sobel_y_size, "3");
+  bindParameter("laplacian_size", m_laplacian_size, "3");
   // </rtc-template>
   
   return RTC::RTC_OK;
@@ -106,7 +121,7 @@
 
 RTC::ReturnCode_t Edge::onActivated(RTC::UniqueId ec_id)
 {
-  //  ƒCƒ[ƒW—pƒƒ‚ƒŠ‚̏‰Šú‰»
+  //  イメージ用メモリの初期化
   imageBuff = NULL;
   grayImage = NULL;
   destinationImage_x = NULL;
@@ -115,7 +130,7 @@
   destinationEdge = NULL;
   edgeImage = NULL;
 
-  //  OutPort‰æ–ʃTƒCƒY‚̏‰Šú‰»
+  //  OutPort画面サイズの初期化
   m_image_edge_sobel_x.width = m_image_edge_sobel_y.width = m_image_edge_LAPLACIAN.width = 0;
   m_image_edge_sobel_x.height = m_image_edge_sobel_y.height = m_image_edge_LAPLACIAN.height = 0;
 
@@ -129,7 +144,7 @@
 {
   if(imageBuff != NULL)
   {
-    //  ƒCƒ[ƒW—pƒƒ‚ƒŠ‚̉ð•ú
+    //  イメージ用メモリの解放
     cvReleaseImage(&imageBuff);
     cvReleaseImage(&destinationImage_x);
     cvReleaseImage(&destinationImage_y);
@@ -145,18 +160,18 @@
 
 RTC::ReturnCode_t Edge::onExecute(RTC::UniqueId ec_id)
 {
-	//  V‚µ‚¢ƒf[ƒ^‚̃`ƒFƒbƒN
+	//  新しいデータのチェック
   if(m_image_origIn.isNew()){
-	  //  InPortƒf[ƒ^‚̓ǂݍž‚Ý
+	  //  InPortデータの読み込み
 	  m_image_origIn.read();
 
-	  // InPort‚ÆOutPort‚̉æ–ʃTƒCƒYˆ—‚¨‚æ‚уCƒ[ƒW—pƒƒ‚ƒŠ‚ÌŠm•Û
+	  // InPortとOutPortの画面サイズ処理およびイメージ用メモリの確保
 	  if( m_image_orig.width != m_image_edge_sobel_x.width || m_image_orig.height != m_image_edge_sobel_x.height)
 	  {
 		  m_image_edge_sobel_x.width = m_image_edge_sobel_y.width = m_image_edge_LAPLACIAN.width = m_image_orig.width;
 		  m_image_edge_sobel_x.height = m_image_edge_sobel_y.height = m_image_edge_LAPLACIAN.height = m_image_orig.height;
 
-		  //  InPort‚̃Cƒ[ƒWƒTƒCƒY‚ª•ÏX‚³‚ꂽê‡
+		  //  InPortのイメージサイズが変更された場合
 		  if(imageBuff != NULL)
 		  {
 			  cvReleaseImage(&imageBuff);
@@ -168,7 +183,7 @@
 			  cvReleaseImage(&edgeImage);
 		  }
 
-		  //  ƒCƒ[ƒW—pƒƒ‚ƒŠ‚ÌŠm•Û
+		  //  イメージ用メモリの確保
 		  imageBuff = cvCreateImage( cvSize(m_image_orig.width, m_image_orig.height), IPL_DEPTH_8U, 3 );
 		  grayImage = cvCreateImage( cvSize(m_image_orig.width, m_image_orig.height), IPL_DEPTH_8U, 1 );
 		  destinationImage_x = cvCreateImage( cvSize(m_image_orig.width, m_image_orig.height), IPL_DEPTH_16S, 1 );
@@ -178,36 +193,36 @@
 		  edgeImage = cvCreateImage( cvSize(m_image_orig.width, m_image_orig.height), IPL_DEPTH_8U, 3 );
 	  }
 
-	  //  InPort‚̉æ–ʃf[ƒ^‚ðƒRƒs[
+	  //  InPortの画面データをコピー
 	  memcpy( imageBuff->imageData, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length() );
 
-	  //  RGB‚©‚çƒOƒŒ[ƒXƒP[ƒ‹‚É•ÏŠ·
+	  //  RGBからグレースケールに変換
 	  cvCvtColor( imageBuff, grayImage, CV_RGB2GRAY );
 
 	  //  Sobel_X
-	  //  X•ûŒü‚ÌSobelƒIƒyƒŒ[ƒ^‚ð‚©‚¯‚é
-	  cvSobel( grayImage, destinationImage_x, 1, 0, SOBEL_X_APERTURE_SIZE );
+	  //  X方向のSobelオペレータをかける
+	  cvSobel( grayImage, destinationImage_x, 1, 0, m_sobel_x_size );
 
-	  //  16ƒrƒbƒg‚Ì•„†‚ ‚èƒf[ƒ^‚ð8ƒrƒbƒg‚Ì•„†‚È‚µƒf[ƒ^‚É•ÏŠ·‚·‚é
+	  //  16ビットの符号ありデータを8ビットの符号なしデータに変換する
 	  cvConvertScaleAbs( destinationImage_x, destinationEdge, SCALE, SHIFT );
 
-	  //  ƒOƒŒ[ƒXƒP[ƒ‹‚©‚çRGB‚É•ÏŠ·
+	  //  グレースケールからRGBに変換
 	  cvCvtColor( destinationEdge, edgeImage, CV_GRAY2RGB );
 
-	  //  ‰æ‘œƒf[ƒ^‚̃TƒCƒYŽæ“¾
+	  //  画像データのサイズ取得
 	  len = edgeImage->nChannels * edgeImage->width * edgeImage->height;
 	  m_image_edge_sobel_x.pixels.length(len);
 
-	  //  ”½“]‚µ‚½‰æ‘œƒf[ƒ^‚ðOutPort‚ɃRƒs[
+	  //  反転した画像データをOutPortにコピー
 	  memcpy( (void *)&(m_image_edge_sobel_x.pixels[0]), edgeImage->imageData, len );
 
-	  //  ”½“]‚µ‚½‰æ‘œƒf[ƒ^‚ðOutPort‚©‚ço—Í
+	  //  反転した画像データをOutPortから出力
 	  m_image_edge_sobel_xOut.write();
 
 
 	  //  Sobel_Y
-	  //  Y•ûŒü‚ÌSobelƒIƒyƒŒ[ƒ^‚ð‚©‚¯‚é
-	  cvSobel( grayImage, destinationImage_y, 0, 1, SOBEL_Y_APERTURE_SIZE );
+	  //  Y方向のSobelオペレータをかける
+	  cvSobel( grayImage, destinationImage_y, 0, 1, m_sobel_y_size );
 
 	  cvConvertScaleAbs( destinationImage_y, destinationEdge, SCALE, SHIFT );
 
@@ -221,7 +236,7 @@
 
 
 	  // LAPLACIAN
-	  cvLaplace( grayImage, destinationImage_LAPLACIAN, LAPLACIAN_APERTURE_SIZE );
+	  cvLaplace( grayImage, destinationImage_LAPLACIAN, m_laplacian_size );
 
 	  cvConvertScaleAbs( destinationImage_LAPLACIAN, destinationEdge, SCALE, SHIFT );
 



More information about the openrtm-commit mailing list