16 static const char*
spec[] =
18 "implementation_id",
"CameraImageLoader",
19 "type_name",
"CameraImageLoader",
20 "description",
"camera image loader",
21 "version", HRPSYS_PACKAGE_VERSION,
23 "category",
"example",
24 "activity_type",
"DataFlowComponent",
27 "lang_type",
"compile",
37 m_imageOut(
"image", m_image),
102 std::cout <<
m_profile.instance_name<<
": onActivated(" << ec_id <<
")" << std::endl;
108 std::cout <<
m_profile.instance_name<<
": onDeactivated(" << ec_id <<
")" << std::endl;
115 std::cerr <<
"image filename: " << std::flush;
117 std::cin >> filename;
119 IplImage *
image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_COLOR);
121 std::cerr <<
m_profile.instance_name <<
": failed to load(" 122 << filename <<
")" << std::endl;
126 m_image.data.image.width = image->width;
127 m_image.data.image.height = image->height;
128 m_image.data.image.raw_data.length(image->imageSize);
129 switch(image->nChannels){
131 m_image.data.image.format = Img::CF_RGB;
135 unsigned char *dst =
m_image.data.image.raw_data.get_buffer();
136 for (
int i=0;
i<image->height;
i++){
137 for (
int j=0;
j<image->width;
j++){
138 src = image->imageData + image->widthStep*
i +
j*3;
148 m_image.data.image.format = Img::CF_GRAY;
149 memcpy(
m_image.data.image.raw_data.get_buffer(),
151 m_image.data.image.raw_data.length());
157 cvReleaseImage (&image);
208 RTC::Create<CameraImageLoader>,
209 RTC::Delete<CameraImageLoader>);
ComponentProfile m_profile
png_infop png_charpp int png_charpp profile
void CameraImageLoaderInit(RTC::Manager *manager)
static const char * spec[]
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
virtual ~CameraImageLoader()
Destructor.
coil::Properties & getProperties()
bool addOutPort(const char *name, OutPortBase &outport)
ExecutionContextHandle_t UniqueId
def j(str, encoding="cp932")
CameraImageLoader(RTC::Manager *manager)
Constructor.
OutPort< Img::TimedCameraImage > m_imageOut
virtual RTC::ReturnCode_t onInitialize()
virtual bool write(DataType &value)
Img::TimedCameraImage m_image
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)