10 #include <opencv2/highgui/highgui_c.h> 11 #include <opencv2/imgproc/imgproc_c.h> 16 static const char*
spec[] =
18 "implementation_id",
"RotateImage",
19 "type_name",
"RotateImage",
20 "description",
"rotate image component",
21 "version", HRPSYS_PACKAGE_VERSION,
23 "category",
"example",
24 "activity_type",
"DataFlowComponent",
27 "lang_type",
"compile",
29 "conf.default.angle",
"0.0",
38 m_originalIn(
"original", m_original),
39 m_rotatedOut(
"rotated", m_rotated),
41 m_angle(1.0), m_src(NULL), m_dst(NULL),
57 std::cout <<
m_profile.instance_name <<
": onInitialize()" << std::endl;
110 std::cout <<
m_profile.instance_name<<
": onActivated(" << ec_id <<
")" << std::endl;
116 std::cout <<
m_profile.instance_name<<
": onDeactivated(" << ec_id <<
")" << std::endl;
128 int nchannels = idat.format == Img::CF_GRAY ? 1 : 3;
131 ||
m_src->height != idat.height)){
132 cvReleaseImage(&
m_src);
133 cvReleaseImage(&
m_dst);
137 m_src = cvCreateImage(cvSize(idat.width, idat.height),
138 IPL_DEPTH_8U, nchannels);
139 m_dst = cvCreateImage(cvSize(idat.width, idat.height),
140 IPL_DEPTH_8U, nchannels);
142 m_rotated.data.image.height = idat.height;
143 m_rotated.data.image.format = idat.format;
144 m_rotated.data.image.raw_data.length(idat.width*idat.height*nchannels);
147 memcpy(
m_src->imageData, idat.raw_data.get_buffer(),
148 idat.raw_data.length());
150 CvMat *rotationMat = cvCreateMat(2,3, CV_32FC1);
151 cv2DRotationMatrix(cvPoint2D32f(idat.width/2, idat.height/2),
154 cvReleaseMat(&rotationMat);
156 memcpy(
m_rotated.data.image.raw_data.get_buffer(),
208 RTC::Create<RotateImage>,
209 RTC::Delete<RotateImage>);
ComponentProfile m_profile
png_infop png_charpp int png_charpp profile
RotateImage(RTC::Manager *manager)
Constructor.
InPort< Img::TimedCameraImage > m_originalIn
virtual RTC::ReturnCode_t onInitialize()
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
Img::TimedCameraImage m_original
bool addOutPort(const char *name, OutPortBase &outport)
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
static const char * spec[]
ExecutionContextHandle_t UniqueId
bool bindParameter(const char *param_name, VarType &var, const char *def_val, bool(*trans)(VarType &, const char *)=coil::stringTo)
virtual ~RotateImage()
Destructor.
OutPort< Img::TimedCameraImage > m_rotatedOut
Img::TimedCameraImage m_rotated
void RotateImageInit(RTC::Manager *manager)
virtual bool write(DataType &value)
bool addInPort(const char *name, InPortBase &inport)
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)