10 #ifndef CV_VERSION_EPOCH 11 #define CV_VERSION_EPOCH CV_VERSION_MAJOR 13 #if CV_VERSION_EPOCH > 3 14 #include <opencv2/imgcodecs/imgcodecs.hpp> 16 #include <opencv2/highgui/highgui.hpp> 22 static const char*
spec[] =
24 "implementation_id",
"CameraImageLoader",
25 "type_name",
"CameraImageLoader",
26 "description",
"camera image loader",
27 "version", HRPSYS_PACKAGE_VERSION,
29 "category",
"example",
30 "activity_type",
"DataFlowComponent",
33 "lang_type",
"compile",
43 m_imageOut(
"image", m_image),
108 std::cout <<
m_profile.instance_name<<
": onActivated(" << ec_id <<
")" << std::endl;
114 std::cout <<
m_profile.instance_name<<
": onDeactivated(" << ec_id <<
")" << std::endl;
121 std::cerr <<
"image filename: " << std::flush;
123 std::cin >> filename;
125 cv::Mat
image = cv::imread(filename.c_str(), cv::IMREAD_COLOR);
127 std::cerr <<
m_profile.instance_name <<
": failed to load(" 128 << filename <<
")" << std::endl;
132 m_image.data.image.width = image.size().width;
133 m_image.data.image.height = image.size().height;
134 m_image.data.image.raw_data.length(image.size().area());
135 switch(image.channels()){
137 m_image.data.image.format = Img::CF_RGB;
141 unsigned char *dst =
m_image.data.image.raw_data.get_buffer();
142 for (
int i=0;
i<image.size().height;
i++){
143 for (
int j=0; j<image.size().width; j++){
144 src = image.data + image.step *
i + j * 3;
154 m_image.data.image.format = Img::CF_GRAY;
155 memcpy(
m_image.data.image.raw_data.get_buffer(),
157 m_image.data.image.raw_data.length());
212 RTC::Create<CameraImageLoader>,
213 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
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)