YARP
Yet Another Robot Platform
FakeFrameGrabber.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #include "FakeFrameGrabber.h"
11 
12 #include <yarp/os/LogComponent.h>
13 #include <yarp/os/LogStream.h>
14 #include <yarp/sig/ImageDraw.h>
15 
16 #include <cstdio>
17 #include <random>
18 
19 using namespace yarp::os;
20 using namespace yarp::dev;
21 using namespace yarp::sig;
22 using namespace yarp::sig::draw;
23 
24 namespace {
25 YARP_LOG_COMPONENT(FAKEFRAMEGRABBER, "yarp.device.fakeFrameGrabber")
26 constexpr yarp::conf::vocab32_t VOCAB_LINE = yarp::os::createVocab('l','i','n','e');
27 constexpr yarp::conf::vocab32_t VOCAB_BALL = yarp::os::createVocab('b','a','l','l');
28 constexpr yarp::conf::vocab32_t VOCAB_GRID = yarp::os::createVocab('g','r','i','d');
29 constexpr yarp::conf::vocab32_t VOCAB_RAND = yarp::os::createVocab('r','a','n','d');
30 constexpr yarp::conf::vocab32_t VOCAB_NONE = yarp::os::createVocab('n','o','n','e');
31 constexpr yarp::conf::vocab32_t VOCAB_GRID_MULTISIZE = yarp::os::createVocab('s','i','z','e');
32 constexpr yarp::conf::vocab32_t VOCAB_TIMETEXT = yarp::os::createVocab('t','i','m','e');
33 
34 //the following data are used by [time] test
35 constexpr char num[12][16]
36 {
37  // '0'
38  "***"
39  "* *"
40  "* *"
41  "* *"
42  "***",
43 
44  // '1'
45  " * "
46  " * "
47  " * "
48  " * "
49  " * ",
50 
51  // '2'
52  "***"
53  " *"
54  "***"
55  "* "
56  "***",
57 
58  // '3'
59  "***"
60  " *"
61  "***"
62  " *"
63  "***",
64 
65  // '4'
66  "* *"
67  "* *"
68  "***"
69  " *"
70  " *",
71 
72  // '5'
73  "***"
74  "* "
75  "***"
76  " *"
77  "***",
78 
79  // '6'
80  "***"
81  "* "
82  "***"
83  "* *"
84  "***",
85 
86  // '7'
87  "***"
88  " *"
89  " *"
90  " *"
91  " *",
92 
93  // '8'
94  "***"
95  "* *"
96  "***"
97  "* *"
98  "***",
99 
100  // '9'
101  "***"
102  "* *"
103  "***"
104  " *"
105  "***",
106 
107  // ' '
108  " "
109  " "
110  " "
111  " "
112  " ",
113 
114  // '.'
115  " "
116  " "
117  " "
118  " **"
119  " **",
120 };
121 constexpr size_t num_width = 3;
122 constexpr size_t num_height = 5;
123 
124 }
125 
126 
128  return true;
129 }
130 
132  w = config.check("width",yarp::os::Value(320),
133  "desired width of test image").asInt32();
134  h = config.check("height",yarp::os::Value(240),
135  "desired height of test image").asInt32();
136  horizontalFov=config.check("horizontalFov",Value(1.0),
137  "desired horizontal fov of test image").asFloat64();
138  verticalFov=config.check("verticalFov",Value(2.0),
139  "desired vertical fov of test image").asFloat64();
140  mirror=config.check("mirror",Value(false),
141  "mirroring disabled by default").asBool();
142  intrinsic.put("physFocalLength",config.check("physFocalLength",Value(3.0),"Physical focal length of the fakeFrameGrabber").asFloat64());
143  intrinsic.put("focalLengthX",config.check("focalLengthX",Value(4.0),"Horizontal component of the focal length of the fakeFrameGrabber").asFloat64());
144  intrinsic.put("focalLengthY",config.check("focalLengthY",Value(5.0),"Vertical component of the focal length of the fakeFrameGrabber").asFloat64());
145  intrinsic.put("principalPointX",config.check("principalPointX",Value(6.0),"X coordinate of the principal point of the fakeFrameGrabber").asFloat64());
146  intrinsic.put("principalPointY",config.check("principalPointY",Value(7.0),"Y coordinate of the principal point of the fakeFrameGrabber").asFloat64());
147 
148  Value* retM;
149  retM=Value::makeList("1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0");
150  intrinsic.put("retificationMatrix",config.check("retificationMatrix",*retM,"Matrix that describes the lens' distortion(fake)"));
151  delete retM;
152 
153  intrinsic.put("distortionModel",config.check("distortionModel",Value("FishEye"),"Reference to group of parameters describing the distortion model of the camera").asString());
154  intrinsic.put("k1",config.check("k1",Value(8.0),"Radial distortion coefficient of the lens(fake)").asFloat64());
155  intrinsic.put("k2",config.check("k2",Value(9.0),"Radial distortion coefficient of the lens(fake)").asFloat64());
156  intrinsic.put("k3",config.check("k3",Value(10.0),"Radial distortion coefficient of the lens(fake)").asFloat64());
157  intrinsic.put("t1",config.check("t1",Value(11.0),"Tangential distortion of the lens(fake)").asFloat64());
158  intrinsic.put("t2",config.check("t2",Value(12.0),"Tangential distortion of the lens(fake)").asFloat64());
159  //Only for debug
160  CameraConfig conf1;
161  conf1.height=128;
162  conf1.width=128;
163  conf1.framerate=60.0;
165  configurations.push_back(conf1);
166 
167  CameraConfig conf2;
168  conf2.height=256;
169  conf2.width=256;
170  conf2.framerate=30.0;
172  configurations.push_back(conf2);
173 
174  CameraConfig conf3;
175  conf3.height=512;
176  conf3.width=512;
177  conf3.framerate=15.0;
179  configurations.push_back(conf3);
180 
181  yarp::os::Value *val;
182  if (config.check("freq", val, "rate of test images in Hz")) {
183  freq = val->asFloat64();
184  period = 1/freq;
185  } else if (config.check("period", val,
186  "period of test images in seconds")) {
187  period = val->asFloat64() / 1000.0;
188  if(period<=0) {
189  period =0;
190  freq = -1;
191  }
192  }
193 
194  mode = config.check("mode",
195  yarp::os::Value(VOCAB_LINE, true),
196  "bouncy [ball], scrolly [line], grid [grid], grid multisize [size], random [rand], none [none], time test[time]").asVocab();
197 
198  if (config.check("src")) {
199  if (!yarp::sig::file::read(background,
200  config.check("src",
201  yarp::os::Value("test.ppm"),
202  "background image to use, if any").asString())) {
203  return false;
204  }
205  if (background.width()>0) {
206  if (config.check("width") || config.check("height")) {
207  yCWarning(FAKEFRAMEGRABBER, "width and height option are ignored when passing a background image");
208  }
209  w = background.width();
210  h = background.height();
211  have_bg = true;
212  }
213  }
214 
215  use_bayer = config.check("bayer","should emit bayer test image?");
216  use_mono = config.check("mono","should emit a monochrome image?");
217  use_mono = use_mono||use_bayer;
218 
219  if (freq!=-1) {
220  yCInfo(FAKEFRAMEGRABBER,
221  "Test grabber period %g / freq %g , mode [%s]",
222  period,
223  freq,
224  yarp::os::Vocab::decode(mode).c_str());
225  } else {
226  yCInfo(FAKEFRAMEGRABBER,
227  "Test grabber period %g / freq [inf], mode [%s]",
228  period,
229  yarp::os::Vocab::decode(mode).c_str());
230  }
231 
232  bx = w/2;
233  by = h/2;
234  return true;
235 }
236 
238  double now = yarp::os::Time::now();
239 
240  if (now-prev>1000) {
241  first = now;
242  prev = now;
243  }
244  double dt = period-(now-prev);
245 
246  if (dt>0) {
248  }
249 
250  // this is the controlled instant when we consider the
251  // image as going out
252  prev += period;
253 }
254 
256  return h;
257 }
258 
260  return w;
261 }
262 
264  return h;
265 }
266 
268  return w;
269 }
270 
272  configurations=this->configurations;
273  return true;
274 }
275 
276 bool FakeFrameGrabber::getRgbResolution(int &width, int &height){
277  width=w;
278  height=h;
279  return true;
280 }
281 
282 bool FakeFrameGrabber::setRgbResolution(int width, int height){
283  w=width;
284  h=height;
285  return true;
286 }
287 
288 bool FakeFrameGrabber::getRgbFOV(double &horizontalFov, double &verticalFov){
289  horizontalFov=this->horizontalFov;
290  verticalFov=this->verticalFov;
291  return true;
292 }
293 
294 bool FakeFrameGrabber::setRgbFOV(double horizontalFov, double verticalFov){
295  this->horizontalFov=horizontalFov;
296  this->verticalFov=verticalFov;
297  return true;
298 }
299 
301  intrinsic=this->intrinsic;
302  return true;
303 }
304 
306  mirror=this->mirror;
307  return true;}
308 
310  this->mirror=mirror;
311  return true;
312 }
313 
315  timing();
316  createTestImage(image);
317  return true;
318 }
319 
320 
322  timing();
323  createTestImage(rgb_image);
324  if (use_bayer) {
325  makeSimpleBayer(rgb_image,image);
326  } else {
327  image.copy(rgb_image);
328  }
329  return true;
330 }
331 
332 
334  return stamp;
335 }
336 
337 bool FakeFrameGrabber::hasAudio() { return false; }
338 
339 bool FakeFrameGrabber::hasVideo() { return !use_mono; }
340 
342  return use_mono;
343 }
344 
346 bool FakeFrameGrabber::hasFeature(int feature, bool *hasFeature) { return false; }
347 bool FakeFrameGrabber::setFeature(int feature, double value) { return false; }
348 bool FakeFrameGrabber::getFeature(int feature, double *value) { return false; }
349 bool FakeFrameGrabber::setFeature(int feature, double value1, double value2) { return false; }
350 bool FakeFrameGrabber::getFeature(int feature, double *value1, double *value2) { return false; }
351 bool FakeFrameGrabber::hasOnOff(int feature, bool *HasOnOff) { return false; }
352 bool FakeFrameGrabber::setActive(int feature, bool onoff) { return false; }
353 bool FakeFrameGrabber::getActive(int feature, bool *isActive) { return false; }
354 bool FakeFrameGrabber::hasAuto(int feature, bool *hasAuto) { return false; }
355 bool FakeFrameGrabber::hasManual(int feature, bool *hasManual) { return false; }
356 bool FakeFrameGrabber::hasOnePush(int feature, bool *hasOnePush) { return false; }
357 bool FakeFrameGrabber::setMode(int feature, FeatureMode mode) { return false; }
358 bool FakeFrameGrabber::getMode(int feature, FeatureMode *mode) { return false; }
359 bool FakeFrameGrabber::setOnePush(int feature) { return false; }
360 
361 void FakeFrameGrabber::printTime(unsigned char* pixbuf, size_t pixbuf_w, size_t pixbuf_h, size_t x, size_t y, char* s, size_t size)
362 {
363  for (size_t i = 0; i < size; i++)
364  {
365  const char* num_p = nullptr;
366  switch (s[i]) {
367  case '0': num_p = num[0]; break;
368  case '1': num_p = num[1]; break;
369  case '2': num_p = num[2]; break;
370  case '3': num_p = num[3]; break;
371  case '4': num_p = num[4]; break;
372  case '5': num_p = num[5]; break;
373  case '6': num_p = num[6]; break;
374  case '7': num_p = num[7]; break;
375  case '8': num_p = num[8]; break;
376  case '9': num_p = num[9]; break;
377  case ' ': num_p = num[10]; break;
378  case '.': num_p = num[11]; break;
379  default: num_p = num[10]; break;
380  }
381 
382  for (size_t yi = 0; yi < num_height; yi++)
383  for (size_t xi = 0; xi < num_width; xi++) {
384  size_t ii = yi * num_width + xi;
385  if (num_p[ii] == '*') {
386  for (size_t r = yi * num_height; r < yi*num_height + num_height; r++) {
387  size_t off = i * (num_height + 20);
388  for (size_t c = xi * num_height + off; c < xi*num_height + num_height + off; c++) {
389  if (c >= pixbuf_h || r >= pixbuf_w) {
390  //avoid drawing out of the image memory
391  return;
392  }
393  unsigned char *pixel = pixbuf;
394  size_t offset = c * sizeof(yarp::sig::PixelRgb) + r * (pixbuf_w * sizeof(yarp::sig::PixelRgb));
395  pixel = pixel + offset;
396  pixel[0] = 0;
397  pixel[1] = 0;
398  pixel[2] = 255;
399  }
400  }
401  }
402  }
403  }
404 }
405 
406 void FakeFrameGrabber::createTestImage(yarp::sig::ImageOf<yarp::sig::PixelRgb>&
407  image) {
408  // to test IPreciselyTimed, make timestamps be mysteriously NNN.NNN42
409  double t = Time::now();
410  t -= (((t*1000) - static_cast<int64_t>(t*1000)) / 1000);
411  t += 0.00042;
412  stamp.update(t);
413  image.resize(w,h);
414 
415  switch (mode) {
416  case VOCAB_TIMETEXT:
417  {
418  if (have_bg) {
419  image.copy(background);
420  } else {
421  image.zero();
422  }
423  char txtbuf[50];
424  static const double start_time = t;
425  double time = t - start_time;
426  std::snprintf(txtbuf, 50, "%.3f", time);
427  int len = strlen(txtbuf);
428  if (len < 20)
429  {
430  printTime((unsigned char*)image.getRawImage(), image.width(), image.height(), 0, 0, txtbuf, len);
431  }
432  }
433  break;
434  case VOCAB_BALL:
435  {
436  if (have_bg) {
437  image.copy(background);
438  } else {
439  image.zero();
440  }
441  addCircle(image,PixelRgb{0,255,0},bx,by,15);
442  addCircle(image,PixelRgb{0,255,255},bx,by,8);
443  if (ct%5!=0) {
444  rnd *= 65537;
445  rnd += 17;
446  int delta_x = (rnd % 5) - 2;
447  bx += delta_x;
448  rnd *= 65537;
449  rnd += 17;
450  int delta_y = (rnd % 5) - 2;
451  by += delta_y;
452  } else {
453  int dx = w/2 - bx;
454  int dy = h/2 - by;
455  if (dx>0) { bx++; }
456  if (dx<0) { bx--; }
457  if (dy>0) { by++; }
458  if (dy<0) { by--; }
459  }
460  }
461  break;
462  case VOCAB_GRID:
463  {
464  size_t ww = image.width();
465  size_t hh = image.height();
466  if (ww>1&&hh>1) {
467  for (size_t x=0; x<ww; x++) {
468  for (size_t y=0; y<hh; y++) {
469  double xx = ((double)x)/(ww-1);
470  double yy = ((double)y)/(hh-1);
471  bool act = (y==ct);
472  auto r = static_cast<unsigned char>(0.5 + 255 * xx);
473  auto g = static_cast<unsigned char>(0.5 + 255 * yy);
474  auto b = static_cast<unsigned char>(act * 255);
475  image.pixel(x, y) = PixelRgb{r, g, b};
476  }
477  }
478  }
479  }
480  break;
481  case VOCAB_GRID_MULTISIZE:
482  {
483  static int count = 0;
484  count++;
485  if (count== 100)
486  {
487  yCDebug(FAKEFRAMEGRABBER) << "size 100, 100";
488  image.resize(100,100);
489  }
490  else if (count == 200)
491  {
492  yCDebug(FAKEFRAMEGRABBER) << "size 200, 100";
493  image.resize(200, 100);
494  }
495  else if (count == 300)
496  {
497  yCDebug(FAKEFRAMEGRABBER) << "size 300, 50";
498  image.resize(300, 50);
499  count = 0;
500  }
501 
502  size_t ww = w = image.width();
503  size_t hh = h = image.height();
504  if (ww>1 && hh>1) {
505  for (size_t x = 0; x<ww; x++) {
506  for (size_t y = 0; y<hh; y++) {
507  double xx = ((double)x) / (ww - 1);
508  double yy = ((double)y) / (hh - 1);
509  bool act = (y == ct);
510  auto r = static_cast<unsigned char>(0.5 + 255 * xx);
511  auto g = static_cast<unsigned char>(0.5 + 255 * yy);
512  auto b = static_cast<unsigned char>(act * 255);
513  image.pixel(x, y) = PixelRgb{r, g, b};
514  }
515  }
516  }
517  }
518  break;
519  case VOCAB_LINE:
520  default:
521  {
522  if (have_bg) {
523  image.copy(background);
524  } else {
525  image.zero();
526  }
527  for (size_t i=0; i<image.width(); i++) {
528  image.pixel(i,ct).r = 255;
529  }
530  char ttxt[50];
531  std::snprintf(ttxt, 50, "%021.10f", t);
532  image.pixel(0, 0).r = ttxt[0] - '0';
533  image.pixel(0, 0).g = ttxt[1] - '0';
534  image.pixel(0, 0).b = ttxt[2] - '0';
535 
536  image.pixel(1, 0).r = ttxt[3] - '0';
537  image.pixel(1, 0).g = ttxt[4] - '0';
538  image.pixel(1, 0).b = ttxt[5] - '0';
539 
540  image.pixel(2, 0).r = ttxt[6] - '0';
541  image.pixel(2, 0).g = ttxt[7] - '0';
542  image.pixel(2, 0).b = ttxt[8] - '0';
543 
544  image.pixel(3, 0).r = ttxt[9] - '0';
545  image.pixel(3, 0).g = ttxt[10] - '0';
546  image.pixel(3, 0).b = ttxt[11] - '0';
547 
548  image.pixel(4, 0).r = ttxt[12] - '0';
549  image.pixel(4, 0).g = ttxt[13] - '0';
550  image.pixel(4, 0).b = ttxt[14] - '0';
551 
552  image.pixel(5, 0).r = ttxt[15] - '0';
553  image.pixel(5, 0).g = ttxt[16] - '0';
554  image.pixel(5, 0).b = ttxt[17] - '0';
555 
556  image.pixel(6, 0).r = ttxt[18] - '0';
557  image.pixel(6, 0).g = ttxt[19] - '0';
558  image.pixel(6, 0).b = ttxt[20] - '0';
559  }
560  break;
561  case VOCAB_RAND:
562  {
563  static unsigned char r = 128;
564  static unsigned char g = 128;
565  static unsigned char b = 128;
566 
567  size_t ww = image.width();
568  size_t hh = image.height();
569 
570  if (ww>1&&hh>1) {
571  for (size_t x=0; x<ww; x++) {
572  for (size_t y=0; y<hh; y++) {
573  r += udist(randengine);
574  g += udist(randengine);
575  b += udist(randengine);
576  image.pixel(x,y) = PixelRgb{r,g,b};
577  }
578  }
579  }
580  }
581  break;
582  case VOCAB_NONE:
583  {
584  if (have_bg) {
585  image.copy(background);
586  } else {
587  image.zero();
588  }
589  }
590  break;
591  }
592  ct++;
593  if (ct>=image.height()) {
594  ct = 0;
595  }
596  if (by>=image.height()) {
597  by = image.height()-1;
598  }
599  if (bx>=image.width()) {
600  bx = image.width()-1;
601  }
602 }
603 
604 
605 
606 // From iCub staticgrabber device.
607 // DF2 bayer sequence.
608 // -- in staticgrabber: first row GBGBGB, second row RGRGRG.
609 // -- changed here to: first row GRGRGR, second row BGBGBG.
610 bool FakeFrameGrabber::makeSimpleBayer(
611  ImageOf<PixelRgb>& img,
612  ImageOf<PixelMono>& bayer) {
613 
614  bayer.resize(img.width(), img.height());
615 
616  const size_t w = img.width();
617  const size_t h = img.height();
618 
619  size_t i, j;
620  for (i = 0; i < h; i++) {
621  auto* row = (PixelRgb *)img.getRow(i);
622  auto* rd = (PixelMono *)bayer.getRow(i);
623 
624  for (j = 0; j < w; j++) {
625 
626  if ((i%2) == 0) {
627  switch (j%4) {
628  case 0:
629  case 2:
630  *rd++ = row->g;
631  row++;
632  break;
633 
634  case 1:
635  case 3:
636  *rd++ = row->r;
637  row++;
638  break;
639  }
640  }
641 
642  if ((i%2) == 1) {
643  switch (j%4) {
644  case 1:
645  case 3:
646  *rd++ = row->g;
647  row++;
648  break;
649 
650  case 0:
651  case 2:
652  *rd++ = row->b;
653  row++;
654  break;
655  }
656  }
657  }
658  }
659 
660  return true;
661 }
662 
664 {
665  yCWarning(FAKEFRAMEGRABBER, "'test_grabber' was renamed 'fakeFrameGrabber'. The old name is still supported for compatibility, but it will be deprecated and removed in a future release. Please update your scripts");
666  return FakeFrameGrabber::open(config);
667 }
float t
std::default_random_engine randengine
Definition: Random.cpp:16
int width() const override
Return the width of each frame.
bool getCameraDescription(CameraDescriptor *camera) override
Get a basic description of the camera hw.
bool hasFeature(int feature, bool *hasFeature) override
Check if camera has the requested feature (saturation, brightness ...
bool getMode(int feature, FeatureMode *mode) override
Get the current mode for the feature.
bool setFeature(int feature, double value) override
Set the requested feature to a value (saturation, brightness ...
int getRgbWidth() override
Return the width of each frame.
int getRgbHeight() override
Return the height of each frame.
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
bool setOnePush(int feature) override
Set the requested feature to a value (saturation, brightness ...
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
bool getActive(int feature, bool *isActive) override
Get the current status of the feature, on or off.
bool hasVideo() override
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
bool hasOnePush(int feature, bool *hasOnePush) override
Check if the requested feature has the 'onePush' mode.
int height() const override
Return the height of each frame.
bool setMode(int feature, FeatureMode mode) override
Set the requested mode for the feature.
bool hasManual(int feature, bool *hasManual) override
Check if the requested feature has the 'manual' mode.
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
bool hasAuto(int feature, bool *hasAuto) override
Check if the requested feature has the 'auto' mode.
bool hasOnOff(int feature, bool *HasOnOff) override
Check if the camera has the ability to turn on/off the requested feature.
bool getFeature(int feature, double *value) override
Get the current value for the requested feature.
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
bool setActive(int feature, bool onoff) override
Set the requested feature on or off.
bool open(yarp::os::Searchable &config) override
Configure with a set of options.
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Get an rgb image from the frame grabber, if required demosaicking/color reconstruction is applied.
bool hasAudio() override
bool hasRawVideo() override
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Configure with a set of options.
A class for storing options and configuration information.
Definition: Property.h:37
A base class for nested structures that can be searched.
Definition: Searchable.h:69
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
A single value (typically within a Bottle).
Definition: Value.h:47
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition: Value.cpp:225
static Value * makeList()
Create a list Value.
Definition: Value.cpp:449
T & pixel(size_t x, size_t y)
Definition: Image.h:663
size_t width() const
Gets width of image in pixels.
Definition: Image.h:153
unsigned char * getRawImage() const
Access to the internal image buffer.
Definition: Image.cpp:535
bool copy(const Image &alt)
Copy operator.
Definition: Image.cpp:847
unsigned char * getRow(size_t r)
Get the address of a the first byte of a row in memory.
Definition: Image.h:203
void resize(size_t imgWidth, size_t imgHeight)
Reallocate an image to be of a desired size, throwing away its current contents.
Definition: Image.cpp:467
void zero()
Set all pixels to 0.
Definition: Image.cpp:460
size_t height() const
Gets height of image in pixels.
Definition: Image.h:159
Provides:
Definition: Vector.h:122
#define yCInfo(component,...)
Definition: LogComponent.h:135
#define yCWarning(component,...)
Definition: LogComponent.h:146
#define yCDebug(component,...)
Definition: LogComponent.h:112
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:80
@ VOCAB_PIXEL_BGR
Definition: Image.h:55
@ VOCAB_PIXEL_MONO
Definition: Image.h:48
@ VOCAB_PIXEL_RGB
Definition: Image.h:50
std::int32_t vocab32_t
Definition: numeric.h:52
An interface for the device drivers.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:124
void delay(double seconds)
Wait for a certain number of seconds.
Definition: Time.cpp:114
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
Definition: Vocab.cpp:36
An interface to the operating system, including Port based communication.
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
Very basic drawing functions, in case you don't have anything better available.
Definition: ImageDraw.h:26
void addCircle(ImageOf< T > &dest, const T &pix, int i, int j, int r)
Definition: ImageDraw.h:43
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:656
Signal processing.
Definition: Image.h:25
unsigned char PixelMono
Monochrome pixel type.
Definition: Image.h:436
The main, catch-all namespace for YARP.
Definition: environment.h:18
Struct describing a possible camera configuration.
Definition: IVisualParams.h:33
YarpVocabPixelTypesEnum pixelCoding
Definition: IVisualParams.h:37
Packed RGB pixel type.
Definition: Image.h:453
unsigned char g
Definition: Image.h:455
unsigned char r
Definition: Image.h:454
unsigned char b
Definition: Image.h:456