12 #include <opencv2/calib3d/calib3d.hpp> 13 #include <opencv2/core/types_c.h> 14 #include <opencv2/imgproc/imgproc.hpp> 20 "implementation_id",
"UndistortImage",
21 "type_name",
"UndistortImage",
22 "description",
"camera image undistortion component",
23 "version", HRPSYS_PACKAGE_VERSION,
25 "category",
"example",
26 "activity_type",
"DataFlowComponent",
29 "lang_type",
"compile",
31 "conf.default.calibFile",
"camera.xml",
40 m_imageIn(
"imageIn", m_image),
41 m_imageOut(
"imageOut", m_image),
56 std::cout <<
m_profile.instance_name <<
": onInitialize()" << std::endl;
109 std::cout <<
m_profile.instance_name<<
": onActivated(" << ec_id <<
")" << std::endl;
111 cv::FileStorage fs(
m_calibFile.c_str(), cv::FileStorage::READ);
113 std::cerr <<
m_profile.instance_name <<
": can't open " 115 return RTC::RTC_ERROR;
117 cv::FileNode param = fs[
"intrinsic"];
119 param = fs[
"distortion"];
127 std::cout <<
m_profile.instance_name<<
": onDeactivated(" << ec_id <<
")" << std::endl;
151 switch (
m_image.data.image.format){
163 std::cerr <<
"unsupported color format(" 164 <<
m_image.data.image.format <<
")" << std::endl;
165 return RTC::RTC_ERROR;
168 switch(
m_image.data.image.format){
173 for (
unsigned int i=0;
i<
m_image.data.image.raw_data.length();
i+=3){
174 dst[
i ] =
m_image.data.image.raw_data[
i+2];
175 dst[
i+1] =
m_image.data.image.raw_data[
i+1];
176 dst[
i+2] =
m_image.data.image.raw_data[
i ];
182 m_image.data.image.raw_data.get_buffer(),
183 m_image.data.image.raw_data.length());
190 cv::Mat src_img = cv::cvarrToMat(
m_cvImage);
192 src_img.copyTo(dst_img);
195 switch(
m_image.data.image.format){
199 unsigned char *src = dst_img.data;
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());
265 RTC::Create<UndistortImage>,
266 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