16 "implementation_id",
"UndistortImage",
17 "type_name",
"UndistortImage",
18 "description",
"camera image undistortion component",
19 "version", HRPSYS_PACKAGE_VERSION,
21 "category",
"example",
22 "activity_type",
"DataFlowComponent",
25 "lang_type",
"compile",
27 "conf.default.calibFile",
"camera.xml",
36 m_imageIn(
"imageIn", m_image),
37 m_imageOut(
"imageOut", m_image),
54 std::cout <<
m_profile.instance_name <<
": onInitialize()" << std::endl;
107 std::cout <<
m_profile.instance_name<<
": onActivated(" << ec_id <<
")" << std::endl;
110 = cvOpenFileStorage (
m_calibFile.c_str(), 0, CV_STORAGE_READ);
112 std::cerr <<
m_profile.instance_name <<
": can't open " 114 return RTC::RTC_ERROR;
116 CvFileNode *param = cvGetFileNodeByName (fs, NULL,
"intrinsic");
118 param = cvGetFileNodeByName (fs, NULL,
"distortion");
120 cvReleaseFileStorage (&fs);
127 std::cout <<
m_profile.instance_name<<
": onDeactivated(" << ec_id <<
")" << std::endl;
153 switch (
m_image.data.image.format){
165 std::cerr <<
"unsupported color format(" 166 <<
m_image.data.image.format <<
")" << std::endl;
167 return RTC::RTC_ERROR;
170 switch(
m_image.data.image.format){
175 for (
unsigned int i=0;
i<
m_image.data.image.raw_data.length();
i+=3){
176 dst[
i ] =
m_image.data.image.raw_data[
i+2];
177 dst[
i+1] =
m_image.data.image.raw_data[
i+1];
178 dst[
i+2] =
m_image.data.image.raw_data[
i ];
184 m_image.data.image.raw_data.get_buffer(),
185 m_image.data.image.raw_data.length());
192 IplImage *dst_img = cvCloneImage (
m_cvImage);
195 switch(
m_image.data.image.format){
199 char *src = dst_img->imageData;
200 for (
unsigned int i=0;
i<
m_image.data.image.raw_data.length();
i+=3){
201 m_image.data.image.raw_data[
i+2] = src[
i ];
202 m_image.data.image.raw_data[
i+1] = src[
i+1];
203 m_image.data.image.raw_data[
i ] = src[
i+2];
208 memcpy(
m_image.data.image.raw_data.get_buffer(),
210 m_image.data.image.raw_data.length());
216 cvReleaseImage (&dst_img);
267 RTC::Create<UndistortImage>,
268 RTC::Delete<UndistortImage>);
ComponentProfile m_profile
png_infop png_charpp int png_charpp profile
InPort< Img::TimedCameraImage > m_imageIn
static const char * cameraimageviewercomponent_spec[]
coil::Properties & getProperties()
Img::TimedCameraImage m_image
bool addOutPort(const char *name, OutPortBase &outport)
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
ExecutionContextHandle_t UniqueId
virtual ~UndistortImage()
Destructor.
bool bindParameter(const char *param_name, VarType &var, const char *def_val, bool(*trans)(VarType &, const char *)=coil::stringTo)
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
void UndistortImageInit(RTC::Manager *manager)
virtual bool write(DataType &value)
UndistortImage(RTC::Manager *manager)
Constructor.
virtual RTC::ReturnCode_t onInitialize()
bool addInPort(const char *name, InPortBase &inport)
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
OutPort< Img::TimedCameraImage > m_imageOut