|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
32 commonImageProcessor::commonImageProcessor(
string cameradata_topic_name,
string camerainfo_topic_name)
34 if (this->topic(cameradata_topic_name)==
false)
36 yCError(RGBD_ROS) <<
"Error opening topic:" << cameradata_topic_name;
38 if (m_subscriber_camera_info.topic(camerainfo_topic_name) ==
false)
40 yCError(RGBD_ROS) <<
"Error opening topic:" << camerainfo_topic_name;
42 m_cameradata_topic_name = cameradata_topic_name;
43 m_camerainfo_topic_name = camerainfo_topic_name;
44 m_contains_rgb_data =
false;
45 m_contains_depth_data =
false;
47 commonImageProcessor::~commonImageProcessor()
50 m_subscriber_camera_info.close();
55 if (m_contains_rgb_data ==
false) {
return false;}
66 data = m_lastRGBImage;
68 m_port_mutex.unlock();
74 if (m_contains_depth_data ==
false) {
return false;}
85 data = m_lastDepthImage;
87 m_port_mutex.unlock();
91 size_t commonImageProcessor::getWidth()
const
93 return m_lastDepthImage.width();
96 size_t commonImageProcessor::getHeight()
const
98 return m_lastDepthImage.height();
108 m_lastRGBImage.setPixelCode(yarp_pixcode);
111 for (
auto it = v.
data.begin(); it != v.
data.end(); it++)
113 m_lastRGBImage.getRawImage()[c++]=*it;
115 m_lastStamp.update();
116 m_contains_rgb_data =
true;
122 uint16_t* p = (uint16_t*)(v.
data.data());
123 uint16_t* siz = (uint16_t*)(v.
data.data()) + (v.
data.size() /
sizeof(uint16_t));
127 float value = float(*p) / 1000.0;
128 ((
float*)(m_lastDepthImage.getRawImage()))[c++] = value;
131 m_lastStamp.update();
132 m_contains_depth_data =
true;
138 for (
auto it = v.
data.begin(); it != v.
data.end(); it++)
140 m_lastDepthImage.getRawImage()[c++] = *it;
142 m_lastStamp.update();
143 m_contains_depth_data =
true;
149 m_port_mutex.unlock();
152 bool commonImageProcessor::getFOV(
double& horizontalFov,
double& verticalFov)
const
155 m_lastCameraInfo = *tmp;
161 yCError(RGBD_ROS) <<
"getIntrinsicParam not yet implemented";
168 m_lastCameraInfo = *tmp;
176 if (m_lastCameraInfo.distortion_model==
"plumb_bob")
187 yCError(RGBD_ROS) <<
"Unsupported distortion model";
203 dest.setQuantum(src.getQuantum());
204 dest.setExternal(src.getRawImage(), src.width(), src.height());
209 const string& frame_id,
211 const unsigned int& seq)
227 const string& frame_id,
229 const unsigned int& seq)
231 dest.
data.resize(src.getRawImageSize());
233 dest.
width = src.width();
234 dest.
height = src.height();
236 memcpy(dest.
data.data(), src.getRawImage(), src.getRawImageSize());
239 dest.
step = src.getRowSize();
double principalPointY
Vertical coordinate of the principal point of the image, as a pixel offset from the top edge.
std::string yarp2RosPixelCode(int code)
std::vector< std::uint8_t > data
#define YARP_LOG_COMPONENT(name,...)
size_t getQuantum() const
The size of a row is constrained to be a multiple of the "quantum".
size_t getRawImageSize() const
Access to the internal buffer size information (this is how much memory has been allocated for the im...
An interface for the device drivers.
size_t getRowSize() const
Size of the underlying image buffer rows.
double focalLengthY
Result of the product of the physical focal length(mm) and the size sy of the individual imager eleme...
size_t width() const
Gets width of image in pixels.
void setExternal(const void *data, size_t imgWidth, size_t imgHeight)
Use this to wrap an external image.
std::uint8_t is_bigendian
void setQuantum(size_t imgQuantum)
double principalPointX
Horizontal coordinate of the principal point of the image, as a pixel offset from the left edge.
Image class with user control of representation details.
void deepCopyImages(const yarp::sig::FlexImage &src, yarp::rosmsg::sensor_msgs::Image &dest, const std::string &frame_id, const yarp::rosmsg::TickTime &timeStamp, const unsigned int &seq)
void setPixelCode(int imgPixelCode)
double focalLengthX
Result of the product of the physical focal length(mm) and the size sx of the individual imager eleme...
yarp::rosmsg::std_msgs::Header header
size_t height() const
Gets height of image in pixels.
void clear()
Remove all associations.
DistortionModel distortionModel
Distortion model of the image.
An abstraction for a time stamp and/or sequence number.
#define yCError(component,...)
An interface to the operating system, including Port based communication.
void toProperty(yarp::os::Property &intrinsic) const
toProperty, convert the struct to a Property.
int getPixelCode() const override
The IntrinsicParams struct to handle the intrinsic parameter of cameras(RGB and RGBD either).
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
void shallowCopyImages(const yarp::sig::FlexImage &src, yarp::sig::FlexImage &dest)
int Ros2YarpPixelCode(const std::string &roscode)
unsigned char * getRawImage() const
Access to the internal image buffer.
A class for storing options and configuration information.
virtual int getPixelCode() const
Gets pixel type identifier.