[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 // 2l»ÌÛÉgp·éÅå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; // JC[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[WpÌú»
+ // ã¤ã¡ã¼ã¸ç¨ã¡ã¢ãªã®åæå
imageBuff = NULL;
grayImage = NULL;
binaryImage = NULL;
contourImage = NULL;
- // OutPortæÊTCYÌú»
+ // 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[WpÌðú
+ // ã¤ã¡ã¼ã¸ç¨ã¡ã¢ãªã®è§£æ¾
cvReleaseImage(&imageBuff);
cvReleaseImage(&grayImage);
cvReleaseImage(&binaryImage);
@@ -142,18 +152,18 @@
RTC::ReturnCode_t Findcontour::onExecute(RTC::UniqueId ec_id)
{
- // Vµ¢f[^Ì`FbN
+ // æ°ãããã¼ã¿ã®ãã§ãã¯
if(m_image_origIn.isNew()){
- // InPortf[^ÌÇÝÝ
+ // InPortãã¼ã¿ã®èªã¿è¾¼ã¿
m_image_origIn.read();
- // InPortÆOutPortÌæÊTCY¨æÑC[WpmÛ
+ // 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[WTCYªÏX³ê½ê
+ // InPortã®ã¤ã¡ã¼ã¸ãµã¤ãºãå¤æ´ãããå ´å
if(imageBuff != NULL)
{
cvReleaseImage(&imageBuff);
@@ -162,59 +172,59 @@
cvReleaseImage(&contourImage);
}
- // C[WpÌ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[^ðRs[
+ // 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[XP[ÉÏ·
+ // RGBããã°ã¬ã¼ã¹ã±ã¼ã«ã«å¤æ
cvCvtColor( imageBuff, grayImage, CV_RGB2GRAY);
- // O[XP[©ç2lÉÏ··é
+ // ã°ã¬ã¼ã¹ã±ã¼ã«ãã2å¤ã«å¤æãã
cvThreshold( grayImage, binaryImage, m_nThresholdLv, THRESHOLD_MAX_VALUE, CV_THRESH_BINARY );
- // o³ê½ÖsðÛ¶·éÌæ
+ // æ½åºããã輪éãä¿åããé å
CvMemStorage* storage = cvCreateMemStorage( 0 );
- // 2læÌÖsð©Â¯A»ÌðÔ·
+ // 2å¤ç»åä¸ã®è¼ªéãè¦ã¤ãããã®æ°ãè¿ã
find_contour_num = cvFindContours(
- binaryImage, // üÍæ(WrbgVO`lj
- storage, // o³ê½ÖsðÛ¶·éÌæ
- &find_contour, // êÔO¤ÌÖsÖÌ|C^ÖÌ|C^
- sizeof( CvContour ), // V[PXwb_ÌTCY
- CV_RETR_LIST, // o[h
- CV_CHAIN_APPROX_NONE, // èè@
- cvPoint( 0, 0 ) // ItZbg
+ binaryImage, // å
¥åç»å(ï¼ãããã·ã³ã°ã«ãã£ã³ãã«ï¼
+ 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üijÌF
- CONTOUR_MAX_LEVEL, // `æ³êéÖsÌÅåx
- LINE_THICKNESS, // `æ³êéÖsü̾³
- LINE_TYPE, // üÌíÞ
- cvPoint( 0, 0 ) // ItZbg
+ contourImage, // 輪éãæç»ããç»å
+ find_contour, // æåã®è¼ªéã¸ã®ãã¤ã³ã¿
+ red, // å¤å´è¼ªéç·ã®è²
+ green, // å
å´è¼ªéç·ï¼ç©´ï¼ã®è²
+ m_nContourLv, // æç»ããã輪éã®æ大ã¬ãã«
+ m_nLineThickness, // æç»ããã輪éç·ã®å¤ªã
+ m_nLineType, // ç·ã®ç¨®é¡
+ cvPoint( 0, 0 ) // ãªãã»ãã
);
- // æf[^ÌTCYæ¾
+ // ç»åãã¼ã¿ã®ãµã¤ãºåå¾
int len = contourImage->nChannels * contourImage->width * contourImage->height;
m_image_contour.pixels.length(len);
- // Ï]µ½æf[^ðOutPortÉRs[
+ // å¤è»¢ããç»åãã¼ã¿ã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