62 const size_t size=buffer->
getSize(part);
64 pixel.reset(
new uint8_t [size]);
66 memcpy(
pixel.get(),
reinterpret_cast<uint8_t *
>(buffer->
getBase(part)), size);
81 inline unsigned char clamp8(
int v)
83 const int v2=v<0 ? 0:v;
84 return static_cast<unsigned char>(v2>255 ? 255:v2);
91 const uint32_t j=
static_cast<uint32_t
>((i>>2)*6);
92 const uint32_t js=
static_cast<uint32_t
>(i&0x3);
100 const int Cb=
static_cast<int>(row[j+2])-128;
101 const int Cr=
static_cast<int>(row[j+5])-128;
103 const int rc=(90*Cr+32)>>6;
104 const int gc=(-22*Cb-46*Cr+32)>>6;
105 const int bc=(113*Cb+32)>>6;
116 const int Y[4]={row[i], row[i+1], row[i+3], row[i+4]};
117 const int Cb=
static_cast<int>(row[i+2])-128;
118 const int Cr=
static_cast<int>(row[i+5])-128;
120 const int rc=(90*Cr+32)>>6;
121 const int gc=(-22*Cb-46*Cr+32)>>6;
122 const int bc=(113*Cb+32)>>6;
124 for (
int j=0; j<4; j++)
126 *rgb++=clamp8(Y[j]+rc);
127 *rgb++=clamp8(Y[j]+gc);
128 *rgb++=clamp8(Y[j]+bc);
132 void getColor(uint8_t rgb[3],
const std::shared_ptr<const rcg::Image> &img,
133 uint32_t ds, uint32_t i, uint32_t k)
138 if (img->getPixelFormat() ==
Mono8)
140 size_t lstep=img->getWidth()+img->getXPadding();
141 const uint8_t *p=img->getPixels()+k*lstep+i;
145 for (uint32_t kk=0; kk<ds; kk++)
147 for (uint32_t ii=0; ii<ds; ii++)
156 rgb[2]=rgb[1]=rgb[0]=
static_cast<uint8_t
>(g/n);
160 size_t lstep=(img->getWidth()>>2)*6+img->getXPadding();
161 const uint8_t *p=img->getPixels()+k*lstep;
168 for (uint32_t kk=0; kk<ds; kk++)
170 for (uint32_t ii=0; ii<ds; ii++)
184 rgb[0]=
static_cast<uint8_t
>(r/n);
185 rgb[1]=
static_cast<uint8_t
>(g/n);
186 rgb[2]=
static_cast<uint8_t
>(b/n);
size_t getYPadding() const
Returns vertical padding of the data in the buffer in bytes.
size_t getXPadding(std::uint32_t part) const
Returns horizontal padding of the data in the buffer in bytes.
void convYCbCr411toRGB(uint8_t rgb[3], const uint8_t *row, int i)
Conversion of one pixel from YCbCr411 format (6 bytes for four pixels) to RGB.
size_t getWidth(std::uint32_t part) const
Returns the width of the image in pixel.
void convYCbCr411toQuadRGB(uint8_t rgb[12], const uint8_t *row, int i)
Conversion of a group of four pixels from YCbCr411 format (6 bytes for four pixels) to RGB...
The buffer class encapsulates a Genicam buffer that is provided by a stream.
void * getBase(std::uint32_t part) const
Returns the base address of the specified part of the multi-part buffer.
uint64_t getPixelFormat(std::uint32_t part) const
Returns the pixel format of the specified part as defined in the PFNC.
Image(const Buffer *buffer, std::uint32_t part)
Copies the image information of the buffer.
void getColor(uint8_t rgb[3], const std::shared_ptr< const rcg::Image > &img, uint32_t ds, uint32_t i, uint32_t k)
Expects an image in Mono8 or YCbCr411_8 format and returns the color as RGB value at the given pixel ...
uint64_t getTimestampNS() const
Returns the acquisition timestamp of the data in this buffer in ns.
bool isBigEndian() const
Returns if the data is given as big or little endian.
bool getImagePresent(std::uint32_t part) const
Returns if a 2D, 3D or confidence image is present in the specified part.
uint64_t getFrameID() const
Returns the sequentially incremented number of the frame.
size_t getYOffset(std::uint32_t part) const
Returns the vertical offset of the data in the buffer in lines from the image origin to handle areas ...
std::unique_ptr< uint8_t[]> pixel
size_t getXOffset(std::uint32_t part) const
Returns the horizontal offset of the data in the buffer in pixels from the image origin to handle are...
size_t getHeight(std::uint32_t part) const
Returns the height of the image in pixel.
size_t getSize(std::uint32_t part) const
Returns the size of the specified part of the mult-part buffer.