image.cc
Go to the documentation of this file.
1 /*
2  * This file is part of the rc_genicam_api package.
3  *
4  * Copyright (c) 2017 Roboception GmbH
5  * All rights reserved
6  *
7  * Author: Heiko Hirschmueller
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the copyright holder nor the names of its contributors
20  * may be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #include "image.h"
37 
38 #include "exception.h"
39 #include "pixel_formats.h"
40 
41 #include <cstring>
42 
43 #ifdef _WIN32
44 #undef min
45 #undef max
46 #endif
47 
48 namespace rcg
49 {
50 
51 Image::Image(const Buffer *buffer, std::uint32_t part)
52 {
53  if (buffer->getImagePresent(part))
54  {
55  timestamp=buffer->getTimestampNS();
56 
57  width=buffer->getWidth(part);
58  height=buffer->getHeight(part);
59  xoffset=buffer->getXOffset(part);
60  yoffset=buffer->getYOffset(part);
61  xpadding=buffer->getXPadding(part);
62  ypadding=buffer->getYPadding();
63  frameid=buffer->getFrameID();
64  pixelformat=buffer->getPixelFormat(part);
65  bigendian=buffer->isBigEndian();
66 
67  const size_t size=std::min(buffer->getSize(part), buffer->getSizeFilled());
68 
69  pixel.reset(new uint8_t [size]);
70 
71  memcpy(pixel.get(), reinterpret_cast<uint8_t *>(buffer->getBase(part)), size);
72  }
73  else
74  {
75  throw GenTLException("Image::Image(): Now image available.");
76  }
77 }
78 
79 namespace
80 {
81 
86 inline unsigned char clamp8(int v)
87 {
88  const int v2=v<0 ? 0:v;
89  return static_cast<unsigned char>(v2>255 ? 255:v2);
90 }
91 
92 }
93 
94 void convYCbCr411toRGB(uint8_t rgb[3], const uint8_t *row, int i)
95 {
96  const uint32_t j=static_cast<uint32_t>((i>>2)*6);
97  const uint32_t js=static_cast<uint32_t>(i&0x3);
98 
99  int Y=row[j+js];
100  if (js > 1)
101  {
102  Y=row[j+js+1];
103  }
104 
105  const int Cb=static_cast<int>(row[j+2])-128;
106  const int Cr=static_cast<int>(row[j+5])-128;
107 
108  // conversion of YCbCr into RGB with correct rounding
109  const int rc=((90*Cr+16384+32)>>6)-256;
110  const int gc=((-22*Cb-46*Cr+16384+32)>>6)-256;
111  const int bc=((113*Cb+16384+32)>>6)-256;
112 
113  rgb[0]=clamp8(Y+rc);
114  rgb[1]=clamp8(Y+gc);
115  rgb[2]=clamp8(Y+bc);
116 }
117 
118 void convYCbCr411toQuadRGB(uint8_t rgb[12], const uint8_t *row, int i)
119 {
120  i=(i>>2)*6;
121 
122  const int Y[4]={row[i], row[i+1], row[i+3], row[i+4]};
123  const int Cb=static_cast<int>(row[i+2])-128;
124  const int Cr=static_cast<int>(row[i+5])-128;
125 
126  // conversion of YCbCr into RGB with correct rounding
127  const int rc=((90*Cr+16384+32)>>6)-256;
128  const int gc=((-22*Cb-46*Cr+16384+32)>>6)-256;
129  const int bc=((113*Cb+16384+32)>>6)-256;
130 
131  for (int j=0; j<4; j++)
132  {
133  *rgb++=clamp8(Y[j]+rc);
134  *rgb++=clamp8(Y[j]+gc);
135  *rgb++=clamp8(Y[j]+bc);
136  }
137 }
138 
139 void convYCbCr422toRGB(uint8_t rgb[3], const uint8_t *row, int i)
140 {
141  const uint32_t j=static_cast<uint32_t>((i>>1)*4);
142  const uint32_t js=static_cast<uint32_t>(i&0x1)*2;
143 
144  const int Y=row[j+js];
145  const int Cb=static_cast<int>(row[j+1])-128;
146  const int Cr=static_cast<int>(row[j+3])-128;
147 
148  // conversion of YCbCr into RGB with correct rounding
149  const int rc=((90*Cr+16384+32)>>6)-256;
150  const int gc=((-22*Cb-46*Cr+16384+32)>>6)-256;
151  const int bc=((113*Cb+16384+32)>>6)-256;
152 
153  rgb[0]=clamp8(Y+rc);
154  rgb[1]=clamp8(Y+gc);
155  rgb[2]=clamp8(Y+bc);
156 }
157 
158 void convYCbCr422toQuadRGB(uint8_t rgb[12], const uint8_t *row, int i)
159 {
160  i=(i>>2)*8;
161 
162  for (int k=0; k<8; k+=4)
163  {
164  const int Y[2]={row[i+k], row[i+2+k]};
165  const int Cb=static_cast<int>(row[i+1+k])-128;
166  const int Cr=static_cast<int>(row[i+3+k])-128;
167 
168  // conversion of YCbCr into RGB with correct rounding
169  const int rc=((90*Cr+16384+32)>>6)-256;
170  const int gc=((-22*Cb-46*Cr+16384+32)>>6)-256;
171  const int bc=((113*Cb+16384+32)>>6)-256;
172 
173  for (int j=0; j<2; j++)
174  {
175  *rgb++=clamp8(Y[j]+rc);
176  *rgb++=clamp8(Y[j]+gc);
177  *rgb++=clamp8(Y[j]+bc);
178  }
179  }
180 }
181 
182 void getColor(uint8_t rgb[3], const std::shared_ptr<const Image> &img,
183  uint32_t ds, uint32_t i, uint32_t k)
184 {
185  if (ds < 1)
186  ds = 1;
187 
188  i*=ds;
189  k*=ds;
190 
191  if (img->getPixelFormat() == Mono8) // convert from monochrome
192  {
193  size_t lstep=img->getWidth()+img->getXPadding();
194  const uint8_t *p=img->getPixels()+k*lstep+i;
195 
196  uint32_t g=0, n=0;
197 
198  for (uint32_t kk=0; kk<ds; kk++)
199  {
200  for (uint32_t ii=0; ii<ds; ii++)
201  {
202  g+=p[ii];
203  n++;
204  }
205 
206  p+=lstep;
207  }
208 
209  rgb[2]=rgb[1]=rgb[0]=static_cast<uint8_t>(g/n);
210  }
211  else if (img->getPixelFormat() == RGB8) // convert from RGB8
212  {
213  size_t lstep=3*img->getWidth()+img->getXPadding();
214  const uint8_t *p=img->getPixels()+k*lstep+3*i;
215 
216  uint32_t r=0;
217  uint32_t g=0;
218  uint32_t b=0;
219  uint32_t n=0;
220 
221  for (uint32_t kk=0; kk<ds; kk++)
222  {
223  const uint8_t *pp=p;
224  for (uint32_t ii=0; ii<ds; ii++)
225  {
226  r+=*pp++;
227  g+=*pp++;
228  b+=*pp++;
229  n++;
230  }
231 
232  p+=lstep;
233  }
234 
235  rgb[0]=static_cast<uint8_t>(r/n);
236  rgb[1]=static_cast<uint8_t>(g/n);
237  rgb[2]=static_cast<uint8_t>(b/n);
238  }
239  else if (img->getPixelFormat() == YCbCr411_8) // convert from YUV411
240  {
241  size_t lstep=(img->getWidth()>>2)*6+img->getXPadding();
242  const uint8_t *p=img->getPixels()+k*lstep;
243 
244  uint32_t r=0;
245  uint32_t g=0;
246  uint32_t b=0;
247  uint32_t n=0;
248 
249  for (uint32_t kk=0; kk<ds; kk++)
250  {
251  for (uint32_t ii=0; ii<ds; ii++)
252  {
253  uint8_t v[3];
254  convYCbCr411toRGB(v, p, static_cast<int>(i+ii));
255 
256  r+=v[0];
257  g+=v[1];
258  b+=v[2];
259  n++;
260  }
261 
262  p+=lstep;
263  }
264 
265  rgb[0]=static_cast<uint8_t>(r/n);
266  rgb[1]=static_cast<uint8_t>(g/n);
267  rgb[2]=static_cast<uint8_t>(b/n);
268  }
269  else if (img->getPixelFormat() == YCbCr422_8 || img->getPixelFormat() == YUV422_8) // convert from YUV422
270  {
271  size_t lstep=(img->getWidth()>>2)*8+img->getXPadding();
272  const uint8_t *p=img->getPixels()+k*lstep;
273 
274  uint32_t r=0;
275  uint32_t g=0;
276  uint32_t b=0;
277  uint32_t n=0;
278 
279  for (uint32_t kk=0; kk<ds; kk++)
280  {
281  for (uint32_t ii=0; ii<ds; ii++)
282  {
283  uint8_t v[3];
284  convYCbCr422toRGB(v, p, static_cast<int>(i+ii));
285 
286  r+=v[0];
287  g+=v[1];
288  b+=v[2];
289  n++;
290  }
291 
292  p+=lstep;
293  }
294 
295  rgb[0]=static_cast<uint8_t>(r/n);
296  rgb[1]=static_cast<uint8_t>(g/n);
297  rgb[2]=static_cast<uint8_t>(b/n);
298  }
299 }
300 
301 namespace
302 {
303 
304 /*
305  Convert at green pixel in green-red row.
306 */
307 
308 inline void convertGreenGR(uint8_t &r, uint8_t &g, uint8_t &b,
309  const uint8_t *&row0, const uint8_t *&row1, const uint8_t *&row2)
310 {
311  r=static_cast<uint8_t>((static_cast<int>(*row1)+row1[2]+1)>>1);
312  g=row1[1];
313  b=static_cast<uint8_t>((static_cast<int>(row0[1])+row2[1]+1)>>1);
314 
315  row0++; row1++; row2++;
316 }
317 
318 /*
319  Convert at green pixel in green-blue row.
320 */
321 
322 inline void convertGreenGB(uint8_t &r, uint8_t &g, uint8_t &b,
323  const uint8_t *&row0, const uint8_t *&row1, const uint8_t *&row2)
324 {
325  r=static_cast<uint8_t>((static_cast<int>(row0[1])+row2[1]+1)>>1);
326  g=row1[1];
327  b=static_cast<uint8_t>((static_cast<int>(*row1)+row1[2]+1)>>1);
328 
329  row0++; row1++; row2++;
330 }
331 
332 /*
333  Convert at red pixel.
334 */
335 
336 inline void convertRed(uint8_t &r, uint8_t &g, uint8_t &b,
337  const uint8_t *&row0, const uint8_t *&row1, const uint8_t *&row2)
338 {
339  r=row1[1];
340  g=static_cast<uint8_t>((static_cast<int>(row0[1])+row2[1]+*row1+row1[2]+2)>>2);
341  b=static_cast<uint8_t>((static_cast<int>(*row0)+row0[2]+*row2+row2[2]+2)>>2);
342 
343  row0++; row1++; row2++;
344 }
345 
346 /*
347  Convert at blue pixel.
348 */
349 
350 inline void convertBlue(uint8_t &r, uint8_t &g, uint8_t &b,
351  const uint8_t *&row0, const uint8_t *&row1, const uint8_t *&row2)
352 {
353  r=static_cast<uint8_t>((static_cast<int>(*row0)+row0[2]+*row2+row2[2]+2)>>2);
354  g=static_cast<uint8_t>((static_cast<int>(row0[1])+row2[1]+*row1+row1[2]+2)>>2);
355  b=row1[1];
356 
357  row0++; row1++; row2++;
358 }
359 
360 /*
361  Convert RGB to monochrome.
362 */
363 
364 inline uint8_t rgb2Grey(uint8_t r, uint8_t g, uint8_t b)
365 {
366  return static_cast<uint8_t>((9798*static_cast<uint32_t>(r)+
367  19234*static_cast<uint32_t>(g)+
368  3736*static_cast<uint32_t>(b)+16384)>>15);
369 }
370 
371 inline void storeRGBMono(uint8_t *&rgb_out, uint8_t *&mono_out, uint8_t red, uint8_t green,
372  uint8_t blue)
373 {
374  if (rgb_out)
375  {
376  *rgb_out++ = red;
377  *rgb_out++ = green;
378  *rgb_out++ = blue;
379  }
380 
381  if (mono_out)
382  {
383  *mono_out++ = rgb2Grey(red, green, blue);
384  }
385 }
386 
387 /*
388  Convert green-red image row.
389 */
390 
391 void convertBayerGR(uint8_t *rgb_out, uint8_t *mono_out,
392  const uint8_t *row0, const uint8_t *row1, const uint8_t *row2,
393  bool greenfirst, size_t width)
394 {
395  uint8_t red, green, blue;
396 
397  // convert if first pixel is green
398 
399  size_t i=0;
400 
401  if (greenfirst)
402  {
403  convertGreenGR(red, green, blue, row0, row1, row2);
404  storeRGBMono(rgb_out, mono_out, red, green, blue);
405 
406  i++;
407  }
408 
409  while (i+1 < width)
410  {
411  // convert at red pixel
412 
413  convertRed(red, green, blue, row0, row1, row2);
414  storeRGBMono(rgb_out, mono_out, red, green, blue);
415 
416  // convert at green pixel
417 
418  convertGreenGR(red, green, blue, row0, row1, row2);
419  storeRGBMono(rgb_out, mono_out, red, green, blue);
420 
421  i+=2;
422  }
423 
424  // convert at red pixel
425 
426  if (i < width)
427  {
428  convertRed(red, green, blue, row0, row1, row2);
429  storeRGBMono(rgb_out, mono_out, red, green, blue);
430  }
431 }
432 
433 /*
434  Convert green-blue image row.
435 */
436 
437 void convertBayerGB(uint8_t *rgb_out, uint8_t *mono_out,
438  const uint8_t *row0, const uint8_t *row1, const uint8_t *row2,
439  bool greenfirst, size_t width)
440 {
441  uint8_t red, green, blue;
442 
443  // convert if first pixel is green
444 
445  size_t i=0;
446 
447  if (greenfirst)
448  {
449  convertGreenGB(red, green, blue, row0, row1, row2);
450  storeRGBMono(rgb_out, mono_out, red, green, blue);
451 
452  i++;
453  }
454 
455  while (i+1 < width)
456  {
457  // convert at red pixel
458 
459  convertBlue(red, green, blue, row0, row1, row2);
460  storeRGBMono(rgb_out, mono_out, red, green, blue);
461 
462  // convert at green pixel
463 
464  convertGreenGB(red, green, blue, row0, row1, row2);
465  storeRGBMono(rgb_out, mono_out, red, green, blue);
466 
467  i+=2;
468  }
469 
470  // convert at red pixel
471 
472  if (i < width)
473  {
474  convertBlue(red, green, blue, row0, row1, row2);
475  storeRGBMono(rgb_out, mono_out, red, green, blue);
476  }
477 }
478 
479 }
480 
481 bool convertImage(uint8_t *rgb_out, uint8_t *mono_out, const uint8_t *raw, uint64_t pixelformat,
482  size_t width, size_t height, size_t xpadding)
483 {
484  bool ret=true;
485 
486  switch (pixelformat)
487  {
488  case Mono8:
489  case Confidence8:
490  case Error8:
491  {
492  for (size_t k=0; k<height; k++)
493  {
494  if (rgb_out)
495  {
496  for (size_t i=0; i<width; i++)
497  {
498  uint8_t v=raw[i];
499  *rgb_out++ = v;
500  *rgb_out++ = v;
501  *rgb_out++ = v;
502  }
503  }
504 
505  if (mono_out)
506  {
507  std::memcpy(mono_out, raw, width*sizeof(uint8_t));
508  mono_out+=width;
509  }
510 
511  raw+=width+xpadding;
512  }
513  }
514  break;
515 
516  case YCbCr411_8:
517  {
518  size_t pstep=(width>>2)*6+xpadding;
519  for (size_t k=0; k<height; k++)
520  {
521  for (size_t i=0; i<width; i+=4)
522  {
523  if (rgb_out)
524  {
525  uint8_t rgb[12];
526  convYCbCr411toQuadRGB(rgb, raw, static_cast<int>(i));
527 
528  for (int j=0; j<12; j++)
529  {
530  *rgb_out++ = rgb[j];
531  }
532  }
533 
534  if (mono_out)
535  {
536  size_t j=(i>>2)*6;
537  *mono_out++ = raw[j];
538  *mono_out++ = raw[j+1];
539  *mono_out++ = raw[j+3];
540  *mono_out++ = raw[j+4];
541  }
542  }
543 
544  raw+=pstep;
545  }
546  }
547  break;
548 
549  case YCbCr422_8:
550  case YUV422_8:
551  {
552  size_t pstep=(width>>2)*8+xpadding;
553  for (size_t k=0; k<height; k++)
554  {
555  for (size_t i=0; i<width; i+=4)
556  {
557  if (rgb_out)
558  {
559  uint8_t rgb[12];
560  convYCbCr422toQuadRGB(rgb, raw, static_cast<int>(i));
561 
562  for (int j=0; j<12; j++)
563  {
564  *rgb_out++ = rgb[j];
565  }
566  }
567 
568  if (mono_out)
569  {
570  size_t j=(i>>2)*8;
571  *mono_out++ = raw[j];
572  *mono_out++ = raw[j+2];
573  *mono_out++ = raw[j+4];
574  *mono_out++ = raw[j+6];
575  }
576  }
577 
578  raw+=pstep;
579  }
580  }
581  break;
582 
583  case RGB8:
584  {
585  for (size_t k=0; k<height; k++)
586  {
587  if (rgb_out)
588  {
589  std::memcpy(rgb_out, raw, 3*width*sizeof(uint8_t));
590  rgb_out+=3*width;
591  }
592 
593  if (mono_out)
594  {
595  size_t j=0;
596  for (size_t i=0; i<width; i++)
597  {
598  *mono_out++ = rgb2Grey(raw[j], raw[j+1], raw[j+2]);
599  j+=3;
600  }
601  }
602 
603  raw+=3*width+xpadding;
604  }
605  }
606  break;
607 
608  case BayerRG8:
609  case BayerBG8:
610  case BayerGR8:
611  case BayerGB8:
612  {
613  // In every row, every second pixel is green and every other pixel is
614  // either red or blue. This flag specifies if the current row is red or
615  // blue.
616 
617  bool greenfirst=(pixelformat == BayerGR8 || pixelformat == BayerGB8);
618  bool red=(pixelformat == BayerRG8 || pixelformat == BayerGR8);
619 
620  // setup temporary buffer that is 1 pixel larger than the image
621 
622  std::unique_ptr<uint8_t []> buffer(new uint8_t [(width+2)*3]);
623  uint8_t *row[3];
624 
625  row[0]=buffer.get();
626  row[1]=row[0]+width+2;
627  row[2]=row[1]+width+2;
628 
629  // initialize buffer with 2 rows, extended by two pixel to avoid a special
630  // treatment for the image border
631 
632  memcpy(row[1]+1, raw+width+xpadding, width*sizeof(uint8_t));
633  memcpy(row[2]+1, raw, width*sizeof(uint8_t));
634 
635  row[1][0]=row[1][2]; row[1][width+1]=row[1][width-1];
636  row[2][0]=row[2][2]; row[2][width+1]=row[2][width-1];
637 
638  // for all rows
639 
640  for (size_t k=0; k<height; k++)
641  {
642  // store next extended row in buffer
643 
644  if (k+1 < height)
645  {
646  uint8_t *p=row[0];
647  row[0]=row[1];
648  row[1]=row[2];
649  row[2]=p;
650 
651  memcpy(row[2]+1, raw+(k+1)*(width+xpadding), width*sizeof(uint8_t));
652 
653  row[2][0]=row[2][2]; row[2][width+1]=row[2][width-1];
654  }
655 
656  if (red)
657  {
658  convertBayerGR(rgb_out, mono_out, row[0], row[1], row[2], greenfirst, width);
659 
660  if (rgb_out) rgb_out+=3*width;
661  if (mono_out) mono_out+=width;
662  }
663  else
664  {
665  convertBayerGB(rgb_out, mono_out, row[0], row[1], row[2], greenfirst, width);
666 
667  if (rgb_out) rgb_out+=3*width;
668  if (mono_out) mono_out+=width;
669  }
670 
671  greenfirst=!greenfirst;
672  red=!red;
673  }
674  }
675  break;
676 
677  default:
678  ret=false;
679  break;
680  }
681 
682  return ret;
683 }
684 
685 bool isFormatSupported(uint64_t pixelformat, bool only_color)
686 {
687  if (pixelformat == YCbCr411_8 || pixelformat == YCbCr422_8 || pixelformat == YUV422_8 ||
688  pixelformat == RGB8 || pixelformat == BayerRG8 || pixelformat == BayerBG8 ||
689  pixelformat == BayerGR8 || pixelformat == BayerGB8)
690  {
691  return true;
692  }
693 
694  if (!only_color && (pixelformat == Mono8 || pixelformat == Confidence8 ||
695  pixelformat == Error8))
696  {
697  return true;
698  }
699 
700  return false;
701 }
702 
703 }
size_t ypadding
Definition: image.h:101
bool isBigEndian() const
Returns if the data is given as big or little endian.
Definition: buffer.cc:641
Definition: PFNC.h:326
Definition: PFNC.h:306
Definition: PFNC.h:317
size_t getSizeFilled() const
Returns the number of bytes written into the buffer last time it has been filled. ...
Definition: buffer.cc:325
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...
Definition: buffer.cc:394
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.
Definition: image.cc:94
bool bigendian
Definition: image.h:104
size_t getWidth(std::uint32_t part) const
Returns the width of the image in pixel.
Definition: buffer.cc:344
Definition: PFNC.h:344
size_t width
Definition: image.h:96
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...
Definition: image.cc:118
bool getImagePresent(std::uint32_t part) const
Returns if a 2D, 3D or confidence image is present in the specified part.
Definition: buffer.cc:472
The buffer class encapsulates a Genicam buffer that is provided by a stream.
Definition: buffer.h:118
size_t getHeight(std::uint32_t part) const
Returns the height of the image in pixel.
Definition: buffer.cc:369
#define Error8
Definition: pixel_formats.h:46
void convYCbCr422toQuadRGB(uint8_t rgb[12], const uint8_t *row, int i)
Conversion of a group of four pixels from YCbCr422 format (8 bytes for 4 pixels) to RGB...
Definition: image.cc:158
void convYCbCr422toRGB(uint8_t rgb[3], const uint8_t *row, int i)
Conversion of one pixel from YCbCr422 format (4 bytes for 2 pixels) to RGB.
Definition: image.cc:139
Definition: PFNC.h:359
bool convertImage(uint8_t *rgb_out, uint8_t *mono_out, const uint8_t *raw, uint64_t pixelformat, size_t width, size_t height, size_t xpadding)
Converts image to RGB and monochrome format.
Definition: image.cc:481
uint64_t getTimestampNS() const
Returns the acquisition timestamp of the data in this buffer in ns.
Definition: buffer.cc:670
size_t getYPadding() const
Returns vertical padding of the data in the buffer in bytes.
Definition: buffer.cc:457
uint64_t timestamp
Definition: image.h:95
size_t xpadding
Definition: image.h:100
Image(const Buffer *buffer, std::uint32_t part)
Copies the image information of the buffer.
Definition: image.cc:51
size_t getSize(std::uint32_t part) const
Returns the size of the specified part of the mult-part buffer.
Definition: buffer.cc:258
size_t xoffset
Definition: image.h:98
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 ...
Definition: buffer.cc:419
uint64_t getPixelFormat(std::uint32_t part) const
Returns the pixel format of the specified part as defined in the PFNC.
Definition: buffer.cc:519
size_t yoffset
Definition: image.h:99
void * getBase(std::uint32_t part) const
Returns the base address of the specified part of the multi-part buffer.
Definition: buffer.cc:235
Definition: buffer.cc:47
Definition: PFNC.h:565
Definition: PFNC.h:335
size_t height
Definition: image.h:97
bool isFormatSupported(uint64_t pixelformat, bool only_color)
Returns true if the given pixel format is supported by the convertImage() function.
Definition: image.cc:685
std::unique_ptr< uint8_t []> pixel
Definition: image.h:93
uint64_t getFrameID() const
Returns the sequentially incremented number of the frame.
Definition: buffer.cc:467
size_t getXPadding(std::uint32_t part) const
Returns horizontal padding of the data in the buffer in bytes.
Definition: buffer.cc:444
void getColor(uint8_t rgb[3], const std::shared_ptr< const Image > &img, uint32_t ds, uint32_t i, uint32_t k)
Expects an image in Mono8, RGB8, YCbCr411_8, YCbCr422_8 or YUV422_8 format and returns the color as R...
Definition: image.cc:182
uint64_t frameid
Definition: image.h:102
uint64_t pixelformat
Definition: image.h:103


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Sun Jun 18 2023 02:43:55