All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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, 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  if (buffer->getSizeFilled() == 0)
70  {
71  throw GenTLException("Image without data");
72  }
73 
74  pixel.reset(new uint8_t [size]);
75 
76  memcpy(pixel.get(), reinterpret_cast<uint8_t *>(buffer->getBase(part)), size);
77  }
78  else
79  {
80  throw GenTLException("Image::Image(): Now image available.");
81  }
82 }
83 
84 namespace
85 {
86 
91 inline unsigned char clamp8(int v)
92 {
93  const int v2=v<0 ? 0:v;
94  return static_cast<unsigned char>(v2>255 ? 255:v2);
95 }
96 
97 }
98 
99 void convYCbCr411toRGB(uint8_t rgb[3], const uint8_t *row, int i)
100 {
101  const uint32_t j=static_cast<uint32_t>((i>>2)*6);
102  const uint32_t js=static_cast<uint32_t>(i&0x3);
103 
104  int Y=row[j+js];
105  if (js > 1)
106  {
107  Y=row[j+js+1];
108  }
109 
110  const int Cb=static_cast<int>(row[j+2])-128;
111  const int Cr=static_cast<int>(row[j+5])-128;
112 
113  // conversion of YCbCr into RGB with correct rounding
114  const int rc=((90*Cr+16384+32)>>6)-256;
115  const int gc=((-22*Cb-46*Cr+16384+32)>>6)-256;
116  const int bc=((113*Cb+16384+32)>>6)-256;
117 
118  rgb[0]=clamp8(Y+rc);
119  rgb[1]=clamp8(Y+gc);
120  rgb[2]=clamp8(Y+bc);
121 }
122 
123 void convYCbCr411toQuadRGB(uint8_t rgb[12], const uint8_t *row, int i)
124 {
125  i=(i>>2)*6;
126 
127  const int Y[4]={row[i], row[i+1], row[i+3], row[i+4]};
128  const int Cb=static_cast<int>(row[i+2])-128;
129  const int Cr=static_cast<int>(row[i+5])-128;
130 
131  // conversion of YCbCr into RGB with correct rounding
132  const int rc=((90*Cr+16384+32)>>6)-256;
133  const int gc=((-22*Cb-46*Cr+16384+32)>>6)-256;
134  const int bc=((113*Cb+16384+32)>>6)-256;
135 
136  for (int j=0; j<4; j++)
137  {
138  *rgb++=clamp8(Y[j]+rc);
139  *rgb++=clamp8(Y[j]+gc);
140  *rgb++=clamp8(Y[j]+bc);
141  }
142 }
143 
144 void convYCbCr422toRGB(uint8_t rgb[3], const uint8_t *row, int i)
145 {
146  const uint32_t j=static_cast<uint32_t>((i>>1)*4);
147  const uint32_t js=static_cast<uint32_t>(i&0x1)*2;
148 
149  const int Y=row[j+js];
150  const int Cb=static_cast<int>(row[j+1])-128;
151  const int Cr=static_cast<int>(row[j+3])-128;
152 
153  // conversion of YCbCr into RGB with correct rounding
154  const int rc=((90*Cr+16384+32)>>6)-256;
155  const int gc=((-22*Cb-46*Cr+16384+32)>>6)-256;
156  const int bc=((113*Cb+16384+32)>>6)-256;
157 
158  rgb[0]=clamp8(Y+rc);
159  rgb[1]=clamp8(Y+gc);
160  rgb[2]=clamp8(Y+bc);
161 }
162 
163 void convYCbCr422toQuadRGB(uint8_t rgb[12], const uint8_t *row, int i)
164 {
165  i=(i>>2)*8;
166 
167  for (int k=0; k<8; k+=4)
168  {
169  const int Y[2]={row[i+k], row[i+2+k]};
170  const int Cb=static_cast<int>(row[i+1+k])-128;
171  const int Cr=static_cast<int>(row[i+3+k])-128;
172 
173  // conversion of YCbCr into RGB with correct rounding
174  const int rc=((90*Cr+16384+32)>>6)-256;
175  const int gc=((-22*Cb-46*Cr+16384+32)>>6)-256;
176  const int bc=((113*Cb+16384+32)>>6)-256;
177 
178  for (int j=0; j<2; j++)
179  {
180  *rgb++=clamp8(Y[j]+rc);
181  *rgb++=clamp8(Y[j]+gc);
182  *rgb++=clamp8(Y[j]+bc);
183  }
184  }
185 }
186 
187 void getColor(uint8_t rgb[3], const std::shared_ptr<const Image> &img,
188  uint32_t ds, uint32_t i, uint32_t k)
189 {
190  if (ds < 1)
191  ds = 1;
192 
193  i*=ds;
194  k*=ds;
195 
196  if (img->getPixelFormat() == Mono8) // convert from monochrome
197  {
198  size_t lstep=img->getWidth()+img->getXPadding();
199  const uint8_t *p=img->getPixels()+k*lstep+i;
200 
201  uint32_t g=0, n=0;
202 
203  for (uint32_t kk=0; kk<ds; kk++)
204  {
205  for (uint32_t ii=0; ii<ds; ii++)
206  {
207  g+=p[ii];
208  n++;
209  }
210 
211  p+=lstep;
212  }
213 
214  rgb[2]=rgb[1]=rgb[0]=static_cast<uint8_t>(g/n);
215  }
216  else if (img->getPixelFormat() == RGB8) // convert from RGB8
217  {
218  size_t lstep=3*img->getWidth()+img->getXPadding();
219  const uint8_t *p=img->getPixels()+k*lstep+3*i;
220 
221  uint32_t r=0;
222  uint32_t g=0;
223  uint32_t b=0;
224  uint32_t n=0;
225 
226  for (uint32_t kk=0; kk<ds; kk++)
227  {
228  const uint8_t *pp=p;
229  for (uint32_t ii=0; ii<ds; ii++)
230  {
231  r+=*pp++;
232  g+=*pp++;
233  b+=*pp++;
234  n++;
235  }
236 
237  p+=lstep;
238  }
239 
240  rgb[0]=static_cast<uint8_t>(r/n);
241  rgb[1]=static_cast<uint8_t>(g/n);
242  rgb[2]=static_cast<uint8_t>(b/n);
243  }
244  else if (img->getPixelFormat() == YCbCr411_8) // convert from YUV411
245  {
246  size_t lstep=(img->getWidth()>>2)*6+img->getXPadding();
247  const uint8_t *p=img->getPixels()+k*lstep;
248 
249  uint32_t r=0;
250  uint32_t g=0;
251  uint32_t b=0;
252  uint32_t n=0;
253 
254  for (uint32_t kk=0; kk<ds; kk++)
255  {
256  for (uint32_t ii=0; ii<ds; ii++)
257  {
258  uint8_t v[3];
259  convYCbCr411toRGB(v, p, static_cast<int>(i+ii));
260 
261  r+=v[0];
262  g+=v[1];
263  b+=v[2];
264  n++;
265  }
266 
267  p+=lstep;
268  }
269 
270  rgb[0]=static_cast<uint8_t>(r/n);
271  rgb[1]=static_cast<uint8_t>(g/n);
272  rgb[2]=static_cast<uint8_t>(b/n);
273  }
274  else if (img->getPixelFormat() == YCbCr422_8 || img->getPixelFormat() == YUV422_8) // convert from YUV422
275  {
276  size_t lstep=(img->getWidth()>>2)*8+img->getXPadding();
277  const uint8_t *p=img->getPixels()+k*lstep;
278 
279  uint32_t r=0;
280  uint32_t g=0;
281  uint32_t b=0;
282  uint32_t n=0;
283 
284  for (uint32_t kk=0; kk<ds; kk++)
285  {
286  for (uint32_t ii=0; ii<ds; ii++)
287  {
288  uint8_t v[3];
289  convYCbCr422toRGB(v, p, static_cast<int>(i+ii));
290 
291  r+=v[0];
292  g+=v[1];
293  b+=v[2];
294  n++;
295  }
296 
297  p+=lstep;
298  }
299 
300  rgb[0]=static_cast<uint8_t>(r/n);
301  rgb[1]=static_cast<uint8_t>(g/n);
302  rgb[2]=static_cast<uint8_t>(b/n);
303  }
304 }
305 
306 namespace
307 {
308 
309 /*
310  Convert at green pixel in green-red row.
311 */
312 
313 inline void convertGreenGR(uint8_t &r, uint8_t &g, uint8_t &b,
314  const uint8_t *&row0, const uint8_t *&row1, const uint8_t *&row2)
315 {
316  r=static_cast<uint8_t>((static_cast<int>(*row1)+row1[2]+1)>>1);
317  g=row1[1];
318  b=static_cast<uint8_t>((static_cast<int>(row0[1])+row2[1]+1)>>1);
319 
320  row0++; row1++; row2++;
321 }
322 
323 /*
324  Convert at green pixel in green-blue row.
325 */
326 
327 inline void convertGreenGB(uint8_t &r, uint8_t &g, uint8_t &b,
328  const uint8_t *&row0, const uint8_t *&row1, const uint8_t *&row2)
329 {
330  r=static_cast<uint8_t>((static_cast<int>(row0[1])+row2[1]+1)>>1);
331  g=row1[1];
332  b=static_cast<uint8_t>((static_cast<int>(*row1)+row1[2]+1)>>1);
333 
334  row0++; row1++; row2++;
335 }
336 
337 /*
338  Convert at red pixel.
339 */
340 
341 inline void convertRed(uint8_t &r, uint8_t &g, uint8_t &b,
342  const uint8_t *&row0, const uint8_t *&row1, const uint8_t *&row2)
343 {
344  r=row1[1];
345  g=static_cast<uint8_t>((static_cast<int>(row0[1])+row2[1]+*row1+row1[2]+2)>>2);
346  b=static_cast<uint8_t>((static_cast<int>(*row0)+row0[2]+*row2+row2[2]+2)>>2);
347 
348  row0++; row1++; row2++;
349 }
350 
351 /*
352  Convert at blue pixel.
353 */
354 
355 inline void convertBlue(uint8_t &r, uint8_t &g, uint8_t &b,
356  const uint8_t *&row0, const uint8_t *&row1, const uint8_t *&row2)
357 {
358  r=static_cast<uint8_t>((static_cast<int>(*row0)+row0[2]+*row2+row2[2]+2)>>2);
359  g=static_cast<uint8_t>((static_cast<int>(row0[1])+row2[1]+*row1+row1[2]+2)>>2);
360  b=row1[1];
361 
362  row0++; row1++; row2++;
363 }
364 
365 /*
366  Convert RGB to monochrome.
367 */
368 
369 inline uint8_t rgb2Grey(uint8_t r, uint8_t g, uint8_t b)
370 {
371  return static_cast<uint8_t>((9798*static_cast<uint32_t>(r)+
372  19234*static_cast<uint32_t>(g)+
373  3736*static_cast<uint32_t>(b)+16384)>>15);
374 }
375 
376 inline void storeRGBMono(uint8_t *&rgb_out, uint8_t *&mono_out, uint8_t red, uint8_t green,
377  uint8_t blue)
378 {
379  if (rgb_out)
380  {
381  *rgb_out++ = red;
382  *rgb_out++ = green;
383  *rgb_out++ = blue;
384  }
385 
386  if (mono_out)
387  {
388  *mono_out++ = rgb2Grey(red, green, blue);
389  }
390 }
391 
392 /*
393  Convert green-red image row.
394 */
395 
396 void convertBayerGR(uint8_t *rgb_out, uint8_t *mono_out,
397  const uint8_t *row0, const uint8_t *row1, const uint8_t *row2,
398  bool greenfirst, size_t width)
399 {
400  uint8_t red, green, blue;
401 
402  // convert if first pixel is green
403 
404  size_t i=0;
405 
406  if (greenfirst)
407  {
408  convertGreenGR(red, green, blue, row0, row1, row2);
409  storeRGBMono(rgb_out, mono_out, red, green, blue);
410 
411  i++;
412  }
413 
414  while (i+1 < width)
415  {
416  // convert at red pixel
417 
418  convertRed(red, green, blue, row0, row1, row2);
419  storeRGBMono(rgb_out, mono_out, red, green, blue);
420 
421  // convert at green pixel
422 
423  convertGreenGR(red, green, blue, row0, row1, row2);
424  storeRGBMono(rgb_out, mono_out, red, green, blue);
425 
426  i+=2;
427  }
428 
429  // convert at red pixel
430 
431  if (i < width)
432  {
433  convertRed(red, green, blue, row0, row1, row2);
434  storeRGBMono(rgb_out, mono_out, red, green, blue);
435  }
436 }
437 
438 /*
439  Convert green-blue image row.
440 */
441 
442 void convertBayerGB(uint8_t *rgb_out, uint8_t *mono_out,
443  const uint8_t *row0, const uint8_t *row1, const uint8_t *row2,
444  bool greenfirst, size_t width)
445 {
446  uint8_t red, green, blue;
447 
448  // convert if first pixel is green
449 
450  size_t i=0;
451 
452  if (greenfirst)
453  {
454  convertGreenGB(red, green, blue, row0, row1, row2);
455  storeRGBMono(rgb_out, mono_out, red, green, blue);
456 
457  i++;
458  }
459 
460  while (i+1 < width)
461  {
462  // convert at red pixel
463 
464  convertBlue(red, green, blue, row0, row1, row2);
465  storeRGBMono(rgb_out, mono_out, red, green, blue);
466 
467  // convert at green pixel
468 
469  convertGreenGB(red, green, blue, row0, row1, row2);
470  storeRGBMono(rgb_out, mono_out, red, green, blue);
471 
472  i+=2;
473  }
474 
475  // convert at red pixel
476 
477  if (i < width)
478  {
479  convertBlue(red, green, blue, row0, row1, row2);
480  storeRGBMono(rgb_out, mono_out, red, green, blue);
481  }
482 }
483 
484 }
485 
486 bool convertImage(uint8_t *rgb_out, uint8_t *mono_out, const uint8_t *raw, uint64_t pixelformat,
487  size_t width, size_t height, size_t xpadding)
488 {
489  bool ret=true;
490 
491  switch (pixelformat)
492  {
493  case Mono8:
494  case Confidence8:
495  case Error8:
496  {
497  for (size_t k=0; k<height; k++)
498  {
499  if (rgb_out)
500  {
501  for (size_t i=0; i<width; i++)
502  {
503  uint8_t v=raw[i];
504  *rgb_out++ = v;
505  *rgb_out++ = v;
506  *rgb_out++ = v;
507  }
508  }
509 
510  if (mono_out)
511  {
512  std::memcpy(mono_out, raw, width*sizeof(uint8_t));
513  mono_out+=width;
514  }
515 
516  raw+=width+xpadding;
517  }
518  }
519  break;
520 
521  case YCbCr411_8:
522  {
523  size_t pstep=(width>>2)*6+xpadding;
524  for (size_t k=0; k<height; k++)
525  {
526  for (size_t i=0; i<width; i+=4)
527  {
528  if (rgb_out)
529  {
530  uint8_t rgb[12];
531  convYCbCr411toQuadRGB(rgb, raw, static_cast<int>(i));
532 
533  for (int j=0; j<12; j++)
534  {
535  *rgb_out++ = rgb[j];
536  }
537  }
538 
539  if (mono_out)
540  {
541  size_t j=(i>>2)*6;
542  *mono_out++ = raw[j];
543  *mono_out++ = raw[j+1];
544  *mono_out++ = raw[j+3];
545  *mono_out++ = raw[j+4];
546  }
547  }
548 
549  raw+=pstep;
550  }
551  }
552  break;
553 
554  case YCbCr422_8:
555  case YUV422_8:
556  {
557  size_t pstep=(width>>2)*8+xpadding;
558  for (size_t k=0; k<height; k++)
559  {
560  for (size_t i=0; i<width; i+=4)
561  {
562  if (rgb_out)
563  {
564  uint8_t rgb[12];
565  convYCbCr422toQuadRGB(rgb, raw, static_cast<int>(i));
566 
567  for (int j=0; j<12; j++)
568  {
569  *rgb_out++ = rgb[j];
570  }
571  }
572 
573  if (mono_out)
574  {
575  size_t j=(i>>2)*8;
576  *mono_out++ = raw[j];
577  *mono_out++ = raw[j+2];
578  *mono_out++ = raw[j+4];
579  *mono_out++ = raw[j+6];
580  }
581  }
582 
583  raw+=pstep;
584  }
585  }
586  break;
587 
588  case RGB8:
589  {
590  for (size_t k=0; k<height; k++)
591  {
592  if (rgb_out)
593  {
594  std::memcpy(rgb_out, raw, 3*width*sizeof(uint8_t));
595  rgb_out+=3*width;
596  }
597 
598  if (mono_out)
599  {
600  size_t j=0;
601  for (size_t i=0; i<width; i++)
602  {
603  *mono_out++ = rgb2Grey(raw[j], raw[j+1], raw[j+2]);
604  j+=3;
605  }
606  }
607 
608  raw+=3*width+xpadding;
609  }
610  }
611  break;
612 
613  case BayerRG8:
614  case BayerBG8:
615  case BayerGR8:
616  case BayerGB8:
617  {
618  // In every row, every second pixel is green and every other pixel is
619  // either red or blue. This flag specifies if the current row is red or
620  // blue.
621 
622  bool greenfirst=(pixelformat == BayerGR8 || pixelformat == BayerGB8);
623  bool red=(pixelformat == BayerRG8 || pixelformat == BayerGR8);
624 
625  // setup temporary buffer that is 1 pixel larger than the image
626 
627  std::unique_ptr<uint8_t []> buffer(new uint8_t [(width+2)*3]);
628  uint8_t *row[3];
629 
630  row[0]=buffer.get();
631  row[1]=row[0]+width+2;
632  row[2]=row[1]+width+2;
633 
634  // initialize buffer with 2 rows, extended by two pixel to avoid a special
635  // treatment for the image border
636 
637  memcpy(row[1]+1, raw+width+xpadding, width*sizeof(uint8_t));
638  memcpy(row[2]+1, raw, width*sizeof(uint8_t));
639 
640  row[1][0]=row[1][2]; row[1][width+1]=row[1][width-1];
641  row[2][0]=row[2][2]; row[2][width+1]=row[2][width-1];
642 
643  // for all rows
644 
645  for (size_t k=0; k<height; k++)
646  {
647  // store next extended row in buffer
648 
649  if (k+1 < height)
650  {
651  uint8_t *p=row[0];
652  row[0]=row[1];
653  row[1]=row[2];
654  row[2]=p;
655 
656  memcpy(row[2]+1, raw+(k+1)*(width+xpadding), width*sizeof(uint8_t));
657 
658  row[2][0]=row[2][2]; row[2][width+1]=row[2][width-1];
659  }
660 
661  if (red)
662  {
663  convertBayerGR(rgb_out, mono_out, row[0], row[1], row[2], greenfirst, width);
664 
665  if (rgb_out) rgb_out+=3*width;
666  if (mono_out) mono_out+=width;
667  }
668  else
669  {
670  convertBayerGB(rgb_out, mono_out, row[0], row[1], row[2], greenfirst, width);
671 
672  if (rgb_out) rgb_out+=3*width;
673  if (mono_out) mono_out+=width;
674  }
675 
676  greenfirst=!greenfirst;
677  red=!red;
678  }
679  }
680  break;
681 
682  default:
683  ret=false;
684  break;
685  }
686 
687  return ret;
688 }
689 
690 bool isFormatSupported(uint64_t pixelformat, bool only_color)
691 {
692  if (pixelformat == YCbCr411_8 || pixelformat == YCbCr422_8 || pixelformat == YUV422_8 ||
693  pixelformat == RGB8 || pixelformat == BayerRG8 || pixelformat == BayerBG8 ||
694  pixelformat == BayerGR8 || pixelformat == BayerGB8)
695  {
696  return true;
697  }
698 
699  if (!only_color && (pixelformat == Mono8 || pixelformat == Confidence8 ||
700  pixelformat == Error8))
701  {
702  return true;
703  }
704 
705  return false;
706 }
707 
708 }
rcg::Image::timestamp
uint64_t timestamp
Definition: image.h:95
BayerGR8
@ BayerGR8
Definition: PFNC.h:335
rcg::Image::xpadding
size_t xpadding
Definition: image.h:100
rcg::Image::height
size_t height
Definition: image.h:97
rcg::Image::bigendian
bool bigendian
Definition: image.h:104
YUV422_8
@ YUV422_8
Definition: PFNC.h:565
Confidence8
@ Confidence8
Definition: PFNC.h:442
rcg::Buffer::getImagePresent
bool getImagePresent(uint32_t part) const
Returns if a 2D, 3D or confidence image is present in the specified part.
Definition: buffer.cc:472
rcg::Buffer
The buffer class encapsulates a Genicam buffer that is provided by a stream.
Definition: buffer.h:118
rcg::Image::xoffset
size_t xoffset
Definition: image.h:98
YCbCr422_8
@ YCbCr422_8
Definition: PFNC.h:503
YCbCr411_8
@ YCbCr411_8
Definition: PFNC.h:499
rcg::Buffer::getTimestampNS
uint64_t getTimestampNS() const
Returns the acquisition timestamp of the data in this buffer in ns.
Definition: buffer.cc:670
rcg::Buffer::getYPadding
size_t getYPadding() const
Returns vertical padding of the data in the buffer in bytes.
Definition: buffer.cc:457
rcg
Definition: buffer.cc:47
rcg::isFormatSupported
bool isFormatSupported(uint64_t pixelformat, bool only_color)
Returns true if the given pixel format is supported by the convertImage() function.
Definition: image.cc:690
pixel_formats.h
rcg::getColor
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:187
rcg::Image::pixelformat
uint64_t pixelformat
Definition: image.h:103
rcg::Buffer::getHeight
size_t getHeight(uint32_t part) const
Returns the height of the image in pixel.
Definition: buffer.cc:369
rcg::Image::frameid
uint64_t frameid
Definition: image.h:102
rcg::Buffer::getFrameID
uint64_t getFrameID() const
Returns the sequentially incremented number of the frame.
Definition: buffer.cc:467
rcg::Image::pixel
std::unique_ptr< uint8_t[]> pixel
Definition: image.h:93
rcg::Buffer::getSize
size_t getSize(uint32_t part) const
Returns the size of the specified part of the mult-part buffer.
Definition: buffer.cc:258
rcg::convYCbCr411toQuadRGB
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:123
rcg::convYCbCr422toRGB
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:144
BayerRG8
@ BayerRG8
Definition: PFNC.h:344
rcg::Buffer::getXOffset
size_t getXOffset(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
rcg::Buffer::getSizeFilled
size_t getSizeFilled() const
Returns the number of bytes written into the buffer last time it has been filled.
Definition: buffer.cc:325
rcg::Buffer::getYOffset
size_t getYOffset(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
rcg::Image::ypadding
size_t ypadding
Definition: image.h:101
image.h
rcg::Buffer::isBigEndian
bool isBigEndian() const
Returns if the data is given as big or little endian.
Definition: buffer.cc:641
rcg::Buffer::getXPadding
size_t getXPadding(uint32_t part) const
Returns horizontal padding of the data in the buffer in bytes.
Definition: buffer.cc:444
rcg::convertImage
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:486
RGB8
@ RGB8
Definition: PFNC.h:359
rcg::Image::Image
Image(const Buffer *buffer, uint32_t part)
Copies the image information of the buffer.
Definition: image.cc:51
width
Definition: Manipulator.hh:15
Error8
#define Error8
Definition: pixel_formats.h:46
rcg::Buffer::getWidth
size_t getWidth(uint32_t part) const
Returns the width of the image in pixel.
Definition: buffer.cc:344
exception.h
rcg::Image::yoffset
size_t yoffset
Definition: image.h:99
BayerBG8
@ BayerBG8
Definition: PFNC.h:317
rcg::convYCbCr422toQuadRGB
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:163
rcg::convYCbCr411toRGB
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:99
BayerGB8
@ BayerGB8
Definition: PFNC.h:326
rcg::GenTLException
Definition: exception.h:47
rcg::Buffer::getBase
void * getBase(uint32_t part) const
Returns the base address of the specified part of the multi-part buffer.
Definition: buffer.cc:235
rcg::Buffer::getPixelFormat
uint64_t getPixelFormat(uint32_t part) const
Returns the pixel format of the specified part as defined in the PFNC.
Definition: buffer.cc:519
Mono8
@ Mono8
Definition: PFNC.h:306


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Dec 4 2024 03:10:11