Go to the documentation of this file.00001
00010 #include "ExtractCameraImage.h"
00011
00012
00013
00014 static const char* extractcameraimage_spec[] =
00015 {
00016 "implementation_id", "ExtractCameraImage",
00017 "type_name", "ExtractCameraImage",
00018 "description", "extractcameraimage component",
00019 "version", HRPSYS_PACKAGE_VERSION,
00020 "vendor", "AIST",
00021 "category", "example",
00022 "activity_type", "DataFlowComponent",
00023 "max_instance", "10",
00024 "language", "C++",
00025 "lang_type", "compile",
00026
00027 "conf.default.index","0",
00028
00029 ""
00030 };
00031
00032
00033 ExtractCameraImage::ExtractCameraImage(RTC::Manager* manager)
00034 : RTC::DataFlowComponentBase(manager),
00035
00036 m_imagesIn("images", m_images),
00037 m_imageOut("image", m_image),
00038
00039 m_index(0),
00040 dummy(0)
00041 {
00042 }
00043
00044 ExtractCameraImage::~ExtractCameraImage()
00045 {
00046 }
00047
00048
00049
00050 RTC::ReturnCode_t ExtractCameraImage::onInitialize()
00051 {
00052 std::cout << m_profile.instance_name << ": onInitialize()" << std::endl;
00053
00054
00055 bindParameter("index", m_index, "0");
00056
00057
00058
00059
00060
00061
00062 addInPort("imagesIn", m_imagesIn);
00063
00064
00065 addOutPort("imageOut", m_imageOut);
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 return RTC::RTC_OK;
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 RTC::ReturnCode_t ExtractCameraImage::onActivated(RTC::UniqueId ec_id)
00102 {
00103 std::cout << m_profile.instance_name<< ": onActivated(" << ec_id << ")" << std::endl;
00104 return RTC::RTC_OK;
00105 }
00106
00107 RTC::ReturnCode_t ExtractCameraImage::onDeactivated(RTC::UniqueId ec_id)
00108 {
00109 std::cout << m_profile.instance_name<< ": onDeactivated(" << ec_id << ")" << std::endl;
00110 return RTC::RTC_OK;
00111 }
00112
00113 RTC::ReturnCode_t ExtractCameraImage::onExecute(RTC::UniqueId ec_id)
00114 {
00115 if (m_imagesIn.isNew()){
00116 m_imagesIn.read();
00117 if (m_images.data.image_seq.length() > m_index){
00118 m_image.tm = m_images.tm;
00119 m_image.data = m_images.data.image_seq[m_index];
00120 m_image.error_code = m_images.error_code;
00121 m_imageOut.write();
00122 }else{
00123 std::cerr << m_profile.instance_name << ": invalid index of image(" << m_index
00124 << "), length of images = " << m_images.data.image_seq.length() << std::endl;
00125 }
00126 }
00127 return RTC::RTC_OK;
00128 }
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 extern "C"
00168 {
00169
00170 void ExtractCameraImageInit(RTC::Manager* manager)
00171 {
00172 RTC::Properties profile(extractcameraimage_spec);
00173 manager->registerFactory(profile,
00174 RTC::Create<ExtractCameraImage>,
00175 RTC::Delete<ExtractCameraImage>);
00176 }
00177
00178 };
00179
00180