|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
22 "yarp.carrier.portmonitor.depthimage2",
29 void getHeatMapColor(
float value,
unsigned char& r,
unsigned char& g,
unsigned char& b)
31 const int NUM_COLORS = 5;
32 static float color[NUM_COLORS][3] = { {0,0,1}, {0,1,0}, {1,1,0}, {1,0,0}, {0,0,0} };
36 float fractBetween = 0;
38 if(value <= 0) { idx1 = idx2 = 0; }
39 else if(value >= 1) { idx1 = idx2 = NUM_COLORS-1; }
42 value = value * (NUM_COLORS-1);
45 fractBetween = value - float(idx1);
48 r = ((color[idx2][0] - color[idx1][0])*fractBetween + color[idx1][0])*255;
49 g = ((color[idx2][1] - color[idx1][1])*fractBetween + color[idx1][1])*255;
50 b = ((color[idx2][2] - color[idx1][2])*fractBetween + color[idx1][2])*255;
80 yCError(DEPTHIMAGE2,
"DepthImageConverter: expected type FlexImage but got wrong data type!");
90 "DepthImageConverter: expected %s, got %s, not doing any conversion!",
101 outImg.setPixelSize(3);
105 auto* inPixels =
reinterpret_cast<float *
> (img->
getRawImage());
106 unsigned char *outPixels = outImg.getRawImage();
107 for(
size_t h=0; h<img->
height(); h++)
109 for(
size_t w=0; w<img->
width(); w++)
111 float inVal = inPixels[w + (h * img->
width())];
112 if (inVal != inVal || inVal < min || inVal > max)
114 outPixels[w*3 + (h * (img->
width()*3)) + 0] = 0;
115 outPixels[w*3 + (h * (img->
width()*3)) + 1] = 0;
116 outPixels[w*3 + (h * (img->
width()*3)) + 2] = 0;
120 float dist = inVal / (max - min);
124 outPixels[w*3 + (h * (img->
width()*3 )) + 0] = r;
125 outPixels[w*3 + (h * (img->
width()*3 )) + 1] = g;
126 outPixels[w*3 + (h * (img->
width()*3 )) + 2] = b;
130 th.setPortWriter(&outImg);
void setPixelCode(int imgPixelCode)
bool create(const yarp::os::Property &options) override
This will be called when the dll is properly loaded by the portmonitor carrier.
#define YARP_LOG_COMPONENT(name,...)
Base class for generic things.
size_t width() const
Gets width of image in pixels.
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
bool setparam(const yarp::os::Property ¶ms) override
This will be called when the portmonitor carrier parameters are set via Yarp admin port.
static LogType minimumPrintLevel()
Get current minimum print level.
size_t height() const
Gets height of image in pixels.
void getHeatMapColor(float value, unsigned char &r, unsigned char &g, unsigned char &b)
bool accept(yarp::os::Things &thing) override
This will be called when the data reach the portmonitor object.
#define yCError(component,...)
yarp::os::Things & update(yarp::os::Things &thing) override
After data get accpeted in the accept() callback, an instance of that is given to the update function...
bool getparam(yarp::os::Property ¶ms) override
This will be called when the portmonitor carrier parameters are requested via Yarp admin port.
An interface to the operating system, including Port based communication.
Base class for storing images.
static LogCallback printCallback()
Get current print callback.
void destroy() override
This will be called when the portmonitor object destroyes.
unsigned char * getRawImage() const
Access to the internal image buffer.
A class for storing options and configuration information.