[openrtm-commit:01132] r102 - in branches/newCMakeForVC2010/ImageProcessing/opencv/components/Findcontour: include/Findcontour src

openrtm @ openrtm.org openrtm @ openrtm.org
2013年 10月 11日 (金) 17:40:29 JST


Author: kawauchi
Date: 2013-10-11 17:40:29 +0900 (Fri, 11 Oct 2013)
New Revision: 102

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

Modified: branches/newCMakeForVC2010/ImageProcessing/opencv/components/Findcontour/include/Findcontour/Findcontour.h
===================================================================
--- branches/newCMakeForVC2010/ImageProcessing/opencv/components/Findcontour/include/Findcontour/Findcontour.h	2013-10-10 06:24:45 UTC (rev 101)
+++ branches/newCMakeForVC2010/ImageProcessing/opencv/components/Findcontour/include/Findcontour/Findcontour.h	2013-10-11 08:40:29 UTC (rev 102)
@@ -24,12 +24,8 @@
 #include <cxcore.h>
 #include <highgui.h>
 
-#define THRESHOLD_MAX_VALUE	255	//	2’l‰»‚̍ۂɎg—p‚·‚éÅ‘å’l
+#define THRESHOLD_MAX_VALUE	255	//	2値化の際に使用する最大値
 
-#define CONTOUR_MAX_LEVEL	1	//	•`‰æ‚³‚ê‚é—ÖŠs‚̍ő僌ƒxƒ‹
-#define LINE_THICKNESS	2		//	ü‚Ì‘¾‚³
-#define LINE_TYPE	8			//	ü‚ÌŽí—Þ
-
 // Service implementation headers
 // <rtc-template block="service_impl_h">
 
@@ -234,7 +230,30 @@
 
   // Configuration variable declaration
   // <rtc-template block="config_declare">
+    /*!
+  * 
+  * - Name:  nThresholdLv
+  * - DefaultValue: 100
+  */
   int m_nThresholdLv;
+  /*!
+  * 
+  * - Name:  nContourLv
+  * - DefaultValue: 1
+  */
+  int m_nContourLv;
+  /*!
+  * 
+  * - Name:  nLineThickness
+  * - DefaultValue: 2
+  */
+  int m_nLineThickness;
+  /*!
+  * 
+  * - Name:  nLineType
+  * - DefaultValue: CV_AA
+  */
+  int m_nLineType;
   // </rtc-template>
 
   // DataInPort declaration
@@ -279,13 +298,14 @@
   // <rtc-template block="private_operation">
   
   // </rtc-template>
-  IplImage* imageBuff;				// ƒJƒƒ‰ƒCƒ[ƒW
+  IplImage* imageBuff;				// カメライメージ
   IplImage* grayImage;
   IplImage* binaryImage;
   IplImage* contourImage;
   int find_contour_num;
   CvSeq* find_contour;
   CvScalar red;
+  CvScalar green;
 };
 
 

Modified: branches/newCMakeForVC2010/ImageProcessing/opencv/components/Findcontour/src/Findcontour.cpp
===================================================================
--- branches/newCMakeForVC2010/ImageProcessing/opencv/components/Findcontour/src/Findcontour.cpp	2013-10-10 06:24:45 UTC (rev 101)
+++ branches/newCMakeForVC2010/ImageProcessing/opencv/components/Findcontour/src/Findcontour.cpp	2013-10-11 08:40:29 UTC (rev 102)
@@ -27,9 +27,15 @@
     "language",          "C++",
     "lang_type",         "compile",
     // Configuration variables
-    "conf.default.threshold_level", "10",
+    "conf.default.threshold_level", "100",
+    "conf.default.contour_level", "1",
+    "conf.default.line_thickness", "2",
+    "conf.default.line_type", "CV_AA", 
     // Widget
     "conf.__widget__.threshold_level", "slider.1",
+    "conf.__widget__.contour_level", "text",
+    "conf.__widget__.line_thickness", "text",
+    "conf.__widget__.line_type", "text",
     // Constraints
     "conf.__constraints__.threshold_level", "0<=x<=255",
     ""
@@ -78,7 +84,10 @@
   // </rtc-template>
 
   // <rtc-template block="bind_config">
-  bindParameter("threshold_level", m_nThresholdLv, "10");
+  bindParameter("threshold_level", m_nThresholdLv, "100");
+  bindParameter("contour_level", m_nContourLv, "1");
+  bindParameter("line_thickness", m_nLineThickness, "2");
+  bindParameter("line_type", m_nLineType, "CV_AA");
   // </rtc-template>
   
   return RTC::RTC_OK;
@@ -108,18 +117,19 @@
 
 RTC::ReturnCode_t Findcontour::onActivated(RTC::UniqueId ec_id)
 {
-  //  ƒCƒ[ƒW—pƒƒ‚ƒŠ‚̏‰Šú‰»
+  //  イメージ用メモリの初期化
   imageBuff = NULL;
   grayImage = NULL;
   binaryImage = NULL;
   contourImage = NULL;
 
-  //  OutPort‰æ–ʃTƒCƒY‚̏‰Šú‰»
+  //  OutPort画面サイズの初期化
   m_image_contour.width = 0;
   m_image_contour.height = 0;
 
   find_contour = NULL;
   red = CV_RGB( 255, 0, 0 );
+  green = CV_RGB( 0, 255, 0 );
 
   return RTC::RTC_OK;
 }
@@ -129,7 +139,7 @@
 {
   if(imageBuff != NULL )
   {
-    //  ƒCƒ[ƒW—pƒƒ‚ƒŠ‚̉ð•ú
+    //  イメージ用メモリの解放
 	cvReleaseImage(&imageBuff);
 	cvReleaseImage(&grayImage);
     cvReleaseImage(&binaryImage);
@@ -142,18 +152,18 @@
 
 RTC::ReturnCode_t Findcontour::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_contour.width || m_image_orig.height != m_image_contour.height)
 	  {
 		  m_image_contour.width = m_image_orig.width;
 		  m_image_contour.height = m_image_orig.height;
 
-		  //  InPort‚̃Cƒ[ƒWƒTƒCƒY‚ª•ÏX‚³‚ꂽê‡
+		  //  InPortのイメージサイズが変更された場合
 		  if(imageBuff != NULL)
 		  {
 			  cvReleaseImage(&imageBuff);
@@ -162,59 +172,59 @@
 			  cvReleaseImage(&contourImage);
 		  }
 
-		  //  ƒ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 );
 		  binaryImage = cvCreateImage( cvSize(m_image_orig.width, m_image_orig.height), IPL_DEPTH_8U, 1);
 		  contourImage = 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() );
 	  memcpy( contourImage->imageData, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length() );
 
-	  //  RGB‚©‚çƒOƒŒ[ƒXƒP[ƒ‹‚É•ÏŠ·
+	  //  RGBからグレースケールに変換
 	  cvCvtColor( imageBuff, grayImage, CV_RGB2GRAY);
 
-	  //  ƒOƒŒ[ƒXƒP[ƒ‹‚©‚ç2’l‚É•ÏŠ·‚·‚é
+	  //  グレースケールから2値に変換する
 	  cvThreshold( grayImage, binaryImage, m_nThresholdLv, THRESHOLD_MAX_VALUE, CV_THRESH_BINARY );
 
-	  //  ’Šo‚³‚ꂽ—ÖŠs‚ð•Û‘¶‚·‚é—̈æ 
+	  //  抽出された輪郭を保存する領域 
 	  CvMemStorage* storage = cvCreateMemStorage( 0 );
 	
-	  //  2’l‰æ‘œ’†‚Ì—ÖŠs‚ðŒ©‚Â‚¯A‚»‚̐”‚ð•Ô‚·
+	  //  2値画像中の輪郭を見つけ、その数を返す
 	  find_contour_num = cvFindContours( 
-		binaryImage,			//	“ü—͉摜(‚WƒrƒbƒgƒVƒ“ƒOƒ‹ƒ`ƒƒƒ“ƒlƒ‹j
-		storage,				//	’Šo‚³‚ꂽ—ÖŠs‚ð•Û‘¶‚·‚é—̈æ
-		&find_contour,			//	ˆê”ÔŠO‘¤‚Ì—ÖŠs‚ւ̃|ƒCƒ“ƒ^‚ւ̃|ƒCƒ“ƒ^
-		sizeof( CvContour ),	//	ƒV[ƒPƒ“ƒXƒwƒbƒ_‚̃TƒCƒY
-		CV_RETR_LIST,			//	’Šoƒ‚[ƒh 
-		CV_CHAIN_APPROX_NONE,	//	„’èŽè–@
-		cvPoint( 0, 0 )			//	ƒIƒtƒZƒbƒg
+		binaryImage,			//	入力画像(8ビットシングルチャンネル)
+		storage,				//	抽出された輪郭を保存する領域
+		&find_contour,			//	一番外側の輪郭へのポインタへのポインタ
+		sizeof( CvContour ),	//	シーケンスヘッダのサイズ
+		CV_RETR_LIST,			//	抽出モード 
+		CV_CHAIN_APPROX_NONE,	//	推定手法
+		cvPoint( 0, 0 )			//	オフセット
 	  );
 
 	  cvDrawContours( 
-		contourImage,			//	—ÖŠs‚ð•`‰æ‚·‚é‰æ‘œ
-		find_contour,			//	Å‰‚Ì—ÖŠs‚ւ̃|ƒCƒ“ƒ^
-		red,					//	ŠO‘¤—ÖŠsü‚̐F
-		red,					//	“à‘¤—ÖŠsüiŒŠj‚̐F
-		CONTOUR_MAX_LEVEL,		//	•`‰æ‚³‚ê‚é—ÖŠs‚̍ő僌ƒxƒ‹
-		LINE_THICKNESS,			//	•`‰æ‚³‚ê‚é—ÖŠsü‚Ì‘¾‚³
-		LINE_TYPE,				//	ü‚ÌŽí—Þ
-		cvPoint( 0, 0 )			//	ƒIƒtƒZƒbƒg
+		contourImage,			//	輪郭を描画する画像
+		find_contour,			//	最初の輪郭へのポインタ
+		red,					//	外側輪郭線の色
+		green, 					//	内側輪郭線(穴)の色
+		m_nContourLv,		//	描画される輪郭の最大レベル
+		m_nLineThickness,			//	描画される輪郭線の太さ
+		m_nLineType,				//	線の種類
+		cvPoint( 0, 0 )			//	オフセット
 	  );
 
-	  //  ‰æ‘œƒf[ƒ^‚̃TƒCƒYŽæ“¾
+	  //  画像データのサイズ取得
 	  int len = contourImage->nChannels * contourImage->width * contourImage->height;
 	  m_image_contour.pixels.length(len);
 
-	  //  •Ï“]‚µ‚½‰æ‘œƒf[ƒ^‚ðOutPort‚ɃRƒs[
+	  //  変転した画像データをOutPortにコピー
 	  memcpy((void *)&(m_image_contour.pixels[0]), contourImage->imageData, len);
 
-	  //  •Ï“]‚µ‚½‰æ‘œƒf[ƒ^‚ðOutPort‚©‚ço—Í
+	  //  変転した画像データをOutPortから出力
 	  m_image_contourOut.write();
 
-	  //  ’Šo‚³‚ꂽ—ÖŠs‚ð‰ð•ú
+	  //  抽出された輪郭を解放
 	  cvReleaseMemStorage( &storage );
 
   }



More information about the openrtm-commit mailing list