[openrtm-commit:01931] r177 - in trunk/ImageProcessing/opencv/components: Chromakey Chromakey/include/Chromakey Chromakey/src RockPaperScissors/src
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 5月 6日 (金) 18:59:19 JST
Author: miyamoto
Date: 2016-05-06 18:59:19 +0900 (Fri, 06 May 2016)
New Revision: 177
Modified:
trunk/ImageProcessing/opencv/components/Chromakey/RTC.xml
trunk/ImageProcessing/opencv/components/Chromakey/include/Chromakey/Chromakey.h
trunk/ImageProcessing/opencv/components/Chromakey/src/Chromakey.cpp
trunk/ImageProcessing/opencv/components/RockPaperScissors/src/RockPaperScissors.cpp
Log:
[bugfix]bug fix.
Modified: trunk/ImageProcessing/opencv/components/Chromakey/RTC.xml
===================================================================
--- trunk/ImageProcessing/opencv/components/Chromakey/RTC.xml 2016-02-03 04:33:25 UTC (rev 176)
+++ trunk/ImageProcessing/opencv/components/Chromakey/RTC.xml 2016-05-06 09:59:19 UTC (rev 177)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rtc:RtcProfile rtc:version="0.2" rtc:id="RTC:AIST:Category:Chromakey:1.1.0" xmlns:rtcExt="http://www.openrtp.org/namespaces/rtc_ext" xmlns:rtcDoc="http://www.openrtp.org/namespaces/rtc_doc" xmlns:rtc="http://www.openrtp.org/namespaces/rtc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <rtc:BasicInfo xsi:type="rtcExt:basic_info_ext" rtcExt:saveProject="Chromakey" rtc:updateDate="2013-06-07T15:16:36+09:00" rtc:creationDate="2013-06-07T15:16:36+09:00" rtc:version="1.1.0" rtc:vendor="AIST" rtc:maxInstances="1" rtc:executionType="PeriodicExecutionContext" rtc:executionRate="1000.0" rtc:description="Chromakey image component" rtc:category="Category" rtc:componentKind="DataFlowComponent" rtc:activityType="PERIODIC" rtc:componentType="STATIC" rtc:name="Chromakey"/>
+ <rtc:BasicInfo xsi:type="rtcExt:basic_info_ext" rtcExt:saveProject="Chromakey" rtc:updateDate="2016-05-06T18:45:57.371+09:00" rtc:creationDate="2013-06-07T15:16:36+09:00" rtc:version="1.1.0" rtc:vendor="AIST" rtc:maxInstances="1" rtc:executionType="PeriodicExecutionContext" rtc:executionRate="1000.0" rtc:description="Chromakey image component" rtc:category="Category" rtc:componentKind="DataFlowComponent" rtc:activityType="PERIODIC" rtc:componentType="STATIC" rtc:name="Chromakey"/>
<rtc:Actions>
<rtc:OnInitialize xsi:type="rtcDoc:action_status_doc" rtc:implemented="true"/>
<rtc:OnFinalize xsi:type="rtcDoc:action_status_doc" rtc:implemented="false"/>
@@ -40,7 +40,7 @@
</rtc:Constraint>
<rtcExt:Properties rtcExt:value="slider.1" rtcExt:name="__widget__"/>
</rtc:Configuration>
- <rtc:Configuration xsi:type="rtcExt:configuration_ext" rtcExt:variableName="nLowerYellow" rtc:unit="" rtc:defaultValue="0" rtc:type="int" rtc:name="lower_yellow">
+ <rtc:Configuration xsi:type="rtcExt:configuration_ext" rtcExt:variableName="nLowerGreen" rtc:unit="" rtc:defaultValue="0" rtc:type="int" rtc:name="lower_green">
<rtc:Constraint>
<rtc:ConstraintUnitType>
<rtc:propertyIsBetween>
@@ -51,7 +51,7 @@
</rtc:Constraint>
<rtcExt:Properties rtcExt:value="slider.1" rtcExt:name="__widget__"/>
</rtc:Configuration>
- <rtc:Configuration xsi:type="rtcExt:configuration_ext" rtcExt:variableName="nUpperYellow" rtc:unit="" rtc:defaultValue="0" rtc:type="int" rtc:name="upper_yellow">
+ <rtc:Configuration xsi:type="rtcExt:configuration_ext" rtcExt:variableName="nUpperGreen" rtc:unit="" rtc:defaultValue="0" rtc:type="int" rtc:name="upper_green">
<rtc:Constraint>
<rtc:ConstraintUnitType>
<rtc:propertyIsBetween>
Modified: trunk/ImageProcessing/opencv/components/Chromakey/include/Chromakey/Chromakey.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Chromakey/include/Chromakey/Chromakey.h 2016-02-03 04:33:25 UTC (rev 176)
+++ trunk/ImageProcessing/opencv/components/Chromakey/include/Chromakey/Chromakey.h 2016-05-06 09:59:19 UTC (rev 177)
@@ -242,16 +242,16 @@
int m_nUpperBlue;
/*!
*
- * - Name: nLowerYellow
+ * - Name: nLowerGreen
* - DefaultValue: 0
*/
- int m_nLowerYellow;
+ int m_nLowerGreen;
/*!
*
- * - Name: nUpperYellow
+ * - Name: nUpperGreen
* - DefaultValue: 0
*/
- int m_nUpperYellow;
+ int m_nUpperGreen;
/*!
*
* - Name: nLowerRed
Modified: trunk/ImageProcessing/opencv/components/Chromakey/src/Chromakey.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Chromakey/src/Chromakey.cpp 2016-02-03 04:33:25 UTC (rev 176)
+++ trunk/ImageProcessing/opencv/components/Chromakey/src/Chromakey.cpp 2016-05-06 09:59:19 UTC (rev 177)
@@ -27,22 +27,22 @@
// Configuration variables
"conf.default.lower_blue", "0",
"conf.default.upper_blue", "0",
- "conf.default.lower_yellow", "0",
- "conf.default.upper_yellow", "0",
+ "conf.default.lower_green", "0",
+ "conf.default.upper_green", "0",
"conf.default.lower_red", "0",
"conf.default.upper_red", "0",
// Widget
"conf.__widget__.lower_blue", "slider.1",
"conf.__widget__.upper_blue", "slider.1",
- "conf.__widget__.lower_yellow", "slider.1",
- "conf.__widget__.upper_yellow", "slider.1",
+ "conf.__widget__.lower_green", "slider.1",
+ "conf.__widget__.upper_green", "slider.1",
"conf.__widget__.lower_red", "slider.1",
"conf.__widget__.upper_red", "slider.1",
// Constraints
"conf.__constraints__.lower_blue", "0<=x<=255",
"conf.__constraints__.upper_blue", "0<=x<=255",
- "conf.__constraints__.lower_yellow", "0<=x<=255",
- "conf.__constraints__.upper_yellow", "0<=x<=255",
+ "conf.__constraints__.lower_green", "0<=x<=255",
+ "conf.__constraints__.upper_green", "0<=x<=255",
"conf.__constraints__.lower_red", "0<=x<=255",
"conf.__constraints__.upper_red", "0<=x<=255",
""
@@ -96,8 +96,8 @@
// Bind variables and configuration variable
bindParameter("lower_blue", m_nLowerBlue, "0");
bindParameter("upper_blue", m_nUpperBlue, "0");
- bindParameter("lower_yellow", m_nLowerYellow, "0");
- bindParameter("upper_yellow", m_nUpperYellow, "0");
+ bindParameter("lower_green", m_nLowerGreen, "0");
+ bindParameter("upper_green", m_nUpperGreen, "0");
bindParameter("lower_red", m_nLowerRed, "0");
bindParameter("upper_red", m_nUpperRed, "0");
// </rtc-template>
@@ -247,8 +247,8 @@
memcpy(m_image_buff->imageData,(void *)&(m_image_original.pixels[0]),m_image_original.pixels.length());
// Anternative actions
- CvScalar lowerValue = cvScalar( m_nLowerBlue, m_nLowerYellow, m_nLowerRed );
- CvScalar upperValue = cvScalar( m_nUpperBlue + 1, m_nUpperYellow + 1, m_nUpperRed + 1 );
+ CvScalar lowerValue = cvScalar(m_nLowerBlue, m_nLowerGreen, m_nLowerRed);
+ CvScalar upperValue = cvScalar(m_nUpperBlue + 1, m_nUpperGreen + 1, m_nUpperRed + 1);
/* RGB各チャンネルごとに範囲内の値以外の画素をマスクに設定する */
cvInRangeS( m_image_buff, lowerValue, upperValue, m_image_mask );
Modified: trunk/ImageProcessing/opencv/components/RockPaperScissors/src/RockPaperScissors.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/RockPaperScissors/src/RockPaperScissors.cpp 2016-02-03 04:33:25 UTC (rev 176)
+++ trunk/ImageProcessing/opencv/components/RockPaperScissors/src/RockPaperScissors.cpp 2016-05-06 09:59:19 UTC (rev 177)
@@ -1,64 +1,64 @@
-// -*- C++ -*-
-/*!
- * @file RockPaperScissors.cpp
- * @brief RockpaperScissors check compoenet
- * @date $Date$
- *
- * $Id$
- */
-
-#include "RockPaperScissors.h"
+// -*- C++ -*-
+/*!
+ * @file RockPaperScissors.cpp
+ * @brief RockpaperScissors check compoenet
+ * @date $Date$
+ *
+ * $Id$
+ */
+
+#include "RockPaperScissors.h"
#define Label LabelingBS
using namespace std;
CvCapture *capture = NULL;
-
-// Module specification
-// <rtc-template block="module_spec">
-static const char* rockpaperscissors_spec[] =
- {
- "implementation_id", "RockPaperScissors",
- "type_name", "RockPaperScissors",
- "description", "RockpaperScissors check compoenet",
- "version", "1.1.0",
- "vendor", "AIST",
- "category", "Category",
- "activity_type", "PERIODIC",
- "kind", "DataFlowComponent",
- "max_instance", "1",
- "language", "C++",
- "lang_type", "compile",
- // Configuration variables
- "conf.default.rock_max", "1.0",
- "conf.default.rock_min", "0.85",
- "conf.default.scissor_max", "0.85",
- "conf.default.scissor_min", "0.7",
- "conf.default.paper_max", "0.7",
- "conf.default.paper_min", "0.5",
- "conf.default.iterations", "4",
- "conf.default.out_mode", "1",
- // Widget
- "conf.__widget__.rock_max", "text",
- "conf.__widget__.rock_min", "text",
- "conf.__widget__.scissor_max", "text",
- "conf.__widget__.scissor_min", "text",
- "conf.__widget__.paper_max", "text",
- "conf.__widget__.paper_min", "text",
- "conf.__widget__.iterations", "text",
- "conf.__widget__.out_mode", "radio",
- // Constraints
- "conf.__constraints__.rock_max", "0<=x<=1.0",
- "conf.__constraints__.rock_min", "0<=x<=1.0",
- "conf.__constraints__.scissor_max", "0<=x<=1.0",
- "conf.__constraints__.scissor_min", "0<=x<=1.0",
- "conf.__constraints__.paper_max", "0<=x<=1.0",
- "conf.__constraints__.paper_min", "0<=x<=1.0",
- "conf.__constraints__.out_mode", "(0,1)",
- ""
- };
-// </rtc-template>
-
+
+// Module specification
+// <rtc-template block="module_spec">
+static const char* rockpaperscissors_spec[] =
+ {
+ "implementation_id", "RockPaperScissors",
+ "type_name", "RockPaperScissors",
+ "description", "RockpaperScissors check compoenet",
+ "version", "1.1.0",
+ "vendor", "AIST",
+ "category", "Category",
+ "activity_type", "PERIODIC",
+ "kind", "DataFlowComponent",
+ "max_instance", "1",
+ "language", "C++",
+ "lang_type", "compile",
+ // Configuration variables
+ "conf.default.rock_max", "1.0",
+ "conf.default.rock_min", "0.85",
+ "conf.default.scissor_max", "0.85",
+ "conf.default.scissor_min", "0.7",
+ "conf.default.paper_max", "0.7",
+ "conf.default.paper_min", "0.5",
+ "conf.default.iterations", "4",
+ "conf.default.out_mode", "1",
+ // Widget
+ "conf.__widget__.rock_max", "text",
+ "conf.__widget__.rock_min", "text",
+ "conf.__widget__.scissor_max", "text",
+ "conf.__widget__.scissor_min", "text",
+ "conf.__widget__.paper_max", "text",
+ "conf.__widget__.paper_min", "text",
+ "conf.__widget__.iterations", "text",
+ "conf.__widget__.out_mode", "radio",
+ // Constraints
+ "conf.__constraints__.rock_max", "0<=x<=1.0",
+ "conf.__constraints__.rock_min", "0<=x<=1.0",
+ "conf.__constraints__.scissor_max", "0<=x<=1.0",
+ "conf.__constraints__.scissor_min", "0<=x<=1.0",
+ "conf.__constraints__.paper_max", "0<=x<=1.0",
+ "conf.__constraints__.paper_min", "0<=x<=1.0",
+ "conf.__constraints__.out_mode", "(0,1)",
+ ""
+ };
+// </rtc-template>
+
Label *createLabeling(){
return new LabelingBS();
}
@@ -77,89 +77,89 @@
delete label;
}
-/*!
- * @brief constructor
- * @param manager Maneger Object
- */
-RockPaperScissors::RockPaperScissors(RTC::Manager* manager)
- // <rtc-template block="initializer">
- : RTC::DataFlowComponentBase(manager),
- m_img_inputIn("image_input", m_img_input),
- m_img_outputOut("image_output", m_img_output),
- m_resultOut("result", m_result)
-
- // </rtc-template>
-{
-}
-
-/*!
- * @brief destructor
- */
-RockPaperScissors::~RockPaperScissors()
-{
-}
-
-
-
-RTC::ReturnCode_t RockPaperScissors::onInitialize()
-{
- // Registration: InPort/OutPort/Service
- // <rtc-template block="registration">
- // Set InPort buffers
- addInPort("image_input", m_img_inputIn);
-
- // Set OutPort buffer
- addOutPort("image_output", m_img_outputOut);
- addOutPort("result", m_resultOut);
-
- // Set service provider to Ports
-
- // Set service consumers to Ports
-
- // Set CORBA Service Ports
-
- // </rtc-template>
-
- // <rtc-template block="bind_config">
- // Bind variables and configuration variable
- bindParameter("rock_max", m_rock_max, "1.0");
- bindParameter("rock_min", m_rock_min, "0.85");
- bindParameter("scissor_max", m_scissor_max, "0.85");
- bindParameter("scissor_min", m_scissor_min, "0.7");
- bindParameter("paper_max", m_paper_max, "0.7");
- bindParameter("paper_min", m_paper_min, "0.5");
- bindParameter("iterations", m_iterations, "4");
- bindParameter("out_mode", m_out_mode, "1");
- // </rtc-template>
-
- return RTC::RTC_OK;
-}
-
-/*
-RTC::ReturnCode_t RockPaperScissors::onFinalize()
-{
- return RTC::RTC_OK;
-}
-*/
-
-/*
-RTC::ReturnCode_t RockPaperScissors::onStartup(RTC::UniqueId ec_id)
-{
- return RTC::RTC_OK;
-}
-*/
-
-/*
-RTC::ReturnCode_t RockPaperScissors::onShutdown(RTC::UniqueId ec_id)
-{
- return RTC::RTC_OK;
-}
-*/
-
-
-RTC::ReturnCode_t RockPaperScissors::onActivated(RTC::UniqueId ec_id)
-{
+/*!
+ * @brief constructor
+ * @param manager Maneger Object
+ */
+RockPaperScissors::RockPaperScissors(RTC::Manager* manager)
+ // <rtc-template block="initializer">
+ : RTC::DataFlowComponentBase(manager),
+ m_img_inputIn("image_input", m_img_input),
+ m_img_outputOut("image_output", m_img_output),
+ m_resultOut("result", m_result)
+ // </rtc-template>
+{
+}
+
+/*!
+ * @brief destructor
+ */
+RockPaperScissors::~RockPaperScissors()
+{
+}
+
+
+
+RTC::ReturnCode_t RockPaperScissors::onInitialize()
+{
+ // Registration: InPort/OutPort/Service
+ // <rtc-template block="registration">
+ // Set InPort buffers
+ addInPort("image_input", m_img_inputIn);
+
+ // Set OutPort buffer
+ addOutPort("image_output", m_img_outputOut);
+ addOutPort("result", m_resultOut);
+
+ // Set service provider to Ports
+
+ // Set service consumers to Ports
+
+ // Set CORBA Service Ports
+
+ // </rtc-template>
+
+ // <rtc-template block="bind_config">
+ // Bind variables and configuration variable
+ bindParameter("rock_max", m_rock_max, "1.0");
+ bindParameter("rock_min", m_rock_min, "0.85");
+ bindParameter("scissor_max", m_scissor_max, "0.85");
+ bindParameter("scissor_min", m_scissor_min, "0.7");
+ bindParameter("paper_max", m_paper_max, "0.7");
+ bindParameter("paper_min", m_paper_min, "0.5");
+ bindParameter("iterations", m_iterations, "4");
+ bindParameter("out_mode", m_out_mode, "1");
+ // </rtc-template>
+
+ return RTC::RTC_OK;
+}
+
+/*
+RTC::ReturnCode_t RockPaperScissors::onFinalize()
+{
+ return RTC::RTC_OK;
+}
+*/
+
+/*
+RTC::ReturnCode_t RockPaperScissors::onStartup(RTC::UniqueId ec_id)
+{
+ return RTC::RTC_OK;
+}
+*/
+
+/*
+RTC::ReturnCode_t RockPaperScissors::onShutdown(RTC::UniqueId ec_id)
+{
+ return RTC::RTC_OK;
+}
+*/
+
+
+RTC::ReturnCode_t RockPaperScissors::onActivated(RTC::UniqueId ec_id)
+{
+
m_image_buff = NULL;
m_hsv_buff = NULL;
m_convexHull_buff = NULL;
@@ -170,11 +170,11 @@
m_prev_judge = "";
return RTC::RTC_OK;
-}
-
-
-RTC::ReturnCode_t RockPaperScissors::onDeactivated(RTC::UniqueId ec_id)
-{
+}
+
+
+RTC::ReturnCode_t RockPaperScissors::onDeactivated(RTC::UniqueId ec_id)
+{
if(m_image_buff != NULL){
cvReleaseImage(&m_image_buff);
}
@@ -198,10 +198,10 @@
}
return RTC::RTC_OK;
-}
-
-
-RTC::ReturnCode_t RockPaperScissors::onExecute(RTC::UniqueId ec_id)
+}
+
+
+RTC::ReturnCode_t RockPaperScissors::onExecute(RTC::UniqueId ec_id)
{
/* 新データのチェック */
if(m_img_inputIn.isNew()){
@@ -303,43 +303,43 @@
}
return RTC::RTC_OK;
-}
-
-/*
-RTC::ReturnCode_t RockPaperScissors::onAborting(RTC::UniqueId ec_id)
-{
- return RTC::RTC_OK;
-}
-*/
-
-/*
-RTC::ReturnCode_t RockPaperScissors::onError(RTC::UniqueId ec_id)
-{
- return RTC::RTC_OK;
-}
-*/
-
-/*
-RTC::ReturnCode_t RockPaperScissors::onReset(RTC::UniqueId ec_id)
-{
- return RTC::RTC_OK;
-}
-*/
-
-/*
-RTC::ReturnCode_t RockPaperScissors::onStateUpdate(RTC::UniqueId ec_id)
-{
- return RTC::RTC_OK;
-}
-*/
-
-/*
-RTC::ReturnCode_t RockPaperScissors::onRateChanged(RTC::UniqueId ec_id)
-{
- return RTC::RTC_OK;
-}
-*/
-
+}
+
+/*
+RTC::ReturnCode_t RockPaperScissors::onAborting(RTC::UniqueId ec_id)
+{
+ return RTC::RTC_OK;
+}
+*/
+
+/*
+RTC::ReturnCode_t RockPaperScissors::onError(RTC::UniqueId ec_id)
+{
+ return RTC::RTC_OK;
+}
+*/
+
+/*
+RTC::ReturnCode_t RockPaperScissors::onReset(RTC::UniqueId ec_id)
+{
+ return RTC::RTC_OK;
+}
+*/
+
+/*
+RTC::ReturnCode_t RockPaperScissors::onStateUpdate(RTC::UniqueId ec_id)
+{
+ return RTC::RTC_OK;
+}
+*/
+
+/*
+RTC::ReturnCode_t RockPaperScissors::onRateChanged(RTC::UniqueId ec_id)
+{
+ return RTC::RTC_OK;
+}
+*/
+
//
// 肌色を抽出する
//
@@ -529,15 +529,15 @@
ratio=handarea / ( double )hullarea;
if( ratio >= m_rock_min && ratio <= m_rock_max ) {
- judge = "グー";
+ judge = "Rock";
}
else if( ratio >= m_scissor_min && ratio <= m_scissor_max )
{
- judge = "チョキ";
+ judge = "Scissors";
}
else if( ratio >= m_paper_min && ratio <= m_paper_max )
{
- judge = "パー";
+ judge = "Paper";
}
if( m_out_mode == 1 )
@@ -548,7 +548,8 @@
*/
if( judge != err_judge && m_prev_judge != judge && hullarea >= 10000 )
{
- printf( "Ratio = %lf : 判定領域の大きさ = %d\n", ratio, hullarea );
+ //printf( "Ratio = %lf : 判定領域の大きさ = %d\n", ratio, hullarea );
+ printf("Ratio = %lf : Size of hand region = %d\n", ratio, hullarea);
printf( "%s\n", judge.c_str() );
m_prev_judge = judge;
@@ -559,23 +560,24 @@
else
{
/* すべての結果を出力する */
- printf( "Ratio = %lf : 判定領域の大きさ = %d\n", ratio, hullarea );
+ //printf( "Ratio = %lf : 判定領域の大きさ = %d\n", ratio, hullarea );
+ printf("Ratio = %lf : Size of hand region = %d\n", ratio, hullarea);
printf( "%s\n", judge.c_str() );
}
}
-
-
-extern "C"
-{
-
- void RockPaperScissorsInit(RTC::Manager* manager)
- {
- coil::Properties profile(rockpaperscissors_spec);
- manager->registerFactory(profile,
- RTC::Create<RockPaperScissors>,
- RTC::Delete<RockPaperScissors>);
- }
-
-};
-
-
+
+
+extern "C"
+{
+
+ void RockPaperScissorsInit(RTC::Manager* manager)
+ {
+ coil::Properties profile(rockpaperscissors_spec);
+ manager->registerFactory(profile,
+ RTC::Create<RockPaperScissors>,
+ RTC::Delete<RockPaperScissors>);
+ }
+
+};
+
+
More information about the openrtm-commit
mailing list