gc_stream.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-2019 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 <rc_genicam_api/system.h>
38 #include <rc_genicam_api/device.h>
39 #include <rc_genicam_api/stream.h>
40 #include <rc_genicam_api/buffer.h>
41 #include <rc_genicam_api/image.h>
43 #include <rc_genicam_api/config.h>
45 
47 
48 #include <Base/GCException.h>
49 
50 #include <signal.h>
51 
52 #include <iostream>
53 #include <fstream>
54 #include <iomanip>
55 #include <algorithm>
56 #include <atomic>
57 #include <thread>
58 #include <chrono>
59 
60 #ifdef _WIN32
61 #undef min
62 #undef max
63 #endif
64 
65 namespace
66 {
67 
68 void printHelp()
69 {
70  // show help
71 
72  std::cout << "gc_stream -h | [-c] [-f <fmt>] [-t] [<interface-id>:]<device-id> [n=<n>] [<key>=<value>] ..." << std::endl;
73  std::cout << std::endl;
74  std::cout << "Stores images from the specified device after applying the given optional GenICam parameters." << std::endl;
75  std::cout << std::endl;
76  std::cout << "Options:" << std::endl;
77  std::cout << "-h Prints help information and exits" << std::endl;
78  std::cout << "-c Print ChunkDataControl category for all received buffers" << std::endl;
79  std::cout << "-t Testmode, which does not store images and provides extended statistics" << std::endl;
80  std::cout << "-f pnm|png Format for storing images. Default is pnm" << std::endl;
81  std::cout << std::endl;
82  std::cout << "Parameters:" << std::endl;
83  std::cout << "<interface-id> Optional GenICam ID of interface for connecting to the device" << std::endl;
84  std::cout << "<device-id> GenICam device ID, serial number or user defined name of device" << std::endl;
85  std::cout << "n=<n> Optional number of images to be received (default is 1)" << std::endl;
86  std::cout << "<key>=<value> Optional GenICam parameters to be changed in the given order" << std::endl;
87 #ifdef _WIN32
88  std::cout << std::endl;
89  std::cout << "Streaming can be aborted by hitting the 'Enter' key." << std::endl;
90 #endif
91 }
92 
97 std::string getDigitalIO(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap)
98 {
99  try
100  {
101  std::int64_t line_status=rcg::getInteger(nodemap, "ChunkLineStatusAll", 0, 0, true);
102 
103  std::string out;
104  std::string in;
105 
106  std::vector<std::string> io;
107  rcg::getEnum(nodemap, "LineSelector", io, true);
108 
109  for (int i=static_cast<int>(io.size())-1; i>=0; i--)
110  {
111  rcg::setEnum(nodemap, "LineSelector", io[i].c_str(), true);
112 
113  std::string mode=rcg::getString(nodemap, "LineMode", true);
114 
115  if (mode == "Input") in+=std::to_string((line_status>>i)&0x1);
116  if (mode == "Output") out+=std::to_string((line_status>>i)&0x1);
117  }
118 
119  if (out.size() > 0 || in.size() > 0)
120  {
121  if (out.size() == 0) out.push_back('0');
122  if (in.size() == 0) in.push_back('0');
123 
124  std::ostringstream ret;
125  ret << "_" << out << "_" << in;
126  return ret.str();
127  }
128  }
129  catch (const std::exception &)
130  {
131  // just ignore and return empty string
132  }
133 
134  return std::string();
135 }
136 
141 std::string storeBuffer(rcg::ImgFmt fmt, const std::shared_ptr<GenApi::CNodeMapRef> &nodemap,
142  const std::string &component, const rcg::Buffer *buffer, uint32_t part,
143  size_t yoffset=0, size_t height=0)
144 {
145  // prepare file name
146 
147  std::ostringstream name;
148 
149  uint64_t t_sec = buffer->getTimestampNS()/1000000000;
150  uint64_t t_nsec = buffer->getTimestampNS()%1000000000;
151 
152  name << "image_" << t_sec << "." << std::setfill('0') << std::setw(9) << t_nsec;
153 
154  if (component.size() > 0)
155  {
156  name << '_' << component;
157  }
158 
159  if (buffer->getContainsChunkdata())
160  {
161  name << getDigitalIO(nodemap);
162  }
163 
164  // store image (see e.g. the sv tool of cvkit for show images)
165 
166  std::string full_name;
167  if (!buffer->getIsIncomplete() && buffer->getImagePresent(part))
168  {
169  rcg::Image image(buffer, part);
170  full_name=storeImage(name.str(), fmt, image, yoffset, height);
171  }
172  else if (buffer->getIsIncomplete())
173  {
174  std::cerr << "storeBuffer(): Received incomplete buffer" << std::endl;
175  }
176  else if (!buffer->getImagePresent(part))
177  {
178  std::cerr << "storeBuffer(): Received buffer without image" << std::endl;
179  }
180 
181  return full_name;
182 }
183 
192 std::string storeBufferAsDisparity(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap,
193  const rcg::Buffer *buffer, uint32_t part)
194 {
195  std::string dispname;
196 
197  if (!buffer->getIsIncomplete() && buffer->getImagePresent(part) &&
198  buffer->getPixelFormat(part) == Coord3D_C16 && buffer->getContainsChunkdata())
199  {
200  // get necessary information from ChunkScan3d parameters
201 
202  int inv=-1;
203 
204  rcg::setString(nodemap, "ChunkComponentSelector", "Disparity");
205 
206  if (rcg::getBoolean(nodemap, "ChunkScan3dInvalidDataFlag"))
207  {
208  inv=static_cast<int>(rcg::getFloat(nodemap, "ChunkScan3dInvalidDataValue"));
209  }
210 
211  double scale=rcg::getFloat(nodemap, "ChunkScan3dCoordinateScale");
212  double offset=rcg::getFloat(nodemap, "ChunkScan3dCoordinateOffset");
213 
214  // prepare file name
215 
216  std::ostringstream name;
217 
218  uint64_t t_sec = buffer->getTimestampNS()/1000000000;
219  uint64_t t_nsec = buffer->getTimestampNS()%1000000000;
220 
221  name << "image_" << t_sec << "." << std::setfill('0') << std::setw(9) << t_nsec;
222  name << "_Disparity";
223 
224  // Append out1 and out2 status to file name: _<out1>_<out2>
225 
226  name << getDigitalIO(nodemap);
227 
228  // store image
229 
230  rcg::Image image(buffer, part);
231  dispname=storeImageAsDisparityPFM(name.str(), image, inv, static_cast<float>(scale), static_cast<float>(offset));
232  }
233  else if (buffer->getIsIncomplete())
234  {
235  std::cerr << "storeBuffer(): Received incomplete buffer" << std::endl;
236  }
237  else if (!buffer->getImagePresent(part))
238  {
239  std::cerr << "storeBuffer(): Received buffer without image" << std::endl;
240  }
241 
242  return dispname;
243 }
244 
249 void storeParameter(const std::shared_ptr<GenApi::CNodeMapRef> &nodemap,
250  const std::string &component, const rcg::Buffer *buffer,
251  size_t height=0, bool dispinfo=false)
252 {
253  if (buffer->getContainsChunkdata())
254  {
255  // prepare file name
256 
257  std::ostringstream name;
258 
259  uint64_t t_sec = buffer->getTimestampNS()/1000000000;
260  uint64_t t_nsec = buffer->getTimestampNS()%1000000000;
261 
262  name << "image_" << t_sec << "." << std::setfill('0') << std::setw(9) << t_nsec;
263 
264  if (component.size() > 0)
265  {
266  name << '_' << component;
267  }
268 
269  // Append out1 and out2 status to file name: _<out1>_<out2>
270 
271  name << getDigitalIO(nodemap);
272  name << "_param.txt";
273 
274  // get 3D parameter
275 
276  rcg::setString(nodemap, "ChunkComponentSelector", component.c_str());
277 
278  int width=static_cast<int>(rcg::getInteger(nodemap, "ChunkWidth"));
279  if (height == 0) height=rcg::getInteger(nodemap, "ChunkHeight");
280  double f=rcg::getFloat(nodemap, "ChunkScan3dFocalLength");
281  double t=rcg::getFloat(nodemap, "ChunkScan3dBaseline");
282  double u=rcg::getFloat(nodemap, "ChunkScan3dPrincipalPointU");
283  double v=rcg::getFloat(nodemap, "ChunkScan3dPrincipalPointV");
284  double exp=rcg::getFloat(nodemap, "ChunkExposureTime")/1000000.0;
285  double gain=rcg::getFloat(nodemap, "ChunkGain");
286  int inv=-1;
287  double scale=0, offset=0;
288 
289  if (dispinfo)
290  {
291  if (rcg::getBoolean(nodemap, "ChunkScan3dInvalidDataFlag"))
292  {
293  inv=static_cast<int>(rcg::getFloat(nodemap, "ChunkScan3dInvalidDataValue"));
294  }
295 
296  scale=rcg::getFloat(nodemap, "ChunkScan3dCoordinateScale");
297  offset=rcg::getFloat(nodemap, "ChunkScan3dCoordinateOffset");
298  }
299 
300  // create parameter file
301 
302  if (width > 0 && height > 0 && f > 0 && t > 0)
303  {
304  std::ofstream out(rcg::ensureNewFileName(name.str()));
305 
306  out << "# Created by gc_stream" << std::endl;
307  out << std::fixed << std::setprecision(5);
308  out << "camera.A=[" << f << " 0 " << u << "; 0 " << f << " " << v << "; 0 0 1]" << std::endl;
309  out << "camera.height=" << height << std::endl;
310  out << "camera.width=" << width << std::endl;
311  out << "camera.exposure_time=" << exp << std::endl;
312  out << "camera.gain=" << gain << std::endl;
313  out << "rho=" << f*t << std::endl;
314  out << "t=" << t << std::endl;
315 
316  try
317  {
318  float v=static_cast<float>(rcg::getFloat(nodemap, "ChunkRcNoise", 0, 0, true));
319  out << "camera.noise=" << v << std::endl;
320  }
321  catch (const std::exception &)
322  { }
323 
324  try
325  {
326  float v=static_cast<float>(rcg::getFloat(nodemap, "ChunkRcBrightness", 0, 0, true));
327  out << "camera.brightness=" << v << std::endl;
328  }
329  catch (const std::exception &)
330  { }
331 
332  try
333  {
334  float v=static_cast<float>(rcg::getFloat(nodemap, "ChunkRcOut1Reduction", 0, 0, true));
335  out << "camera.out1_reduction=" << v << std::endl;
336  }
337  catch (const std::exception &)
338  { }
339 
340  for (int i=0; i<4; i++)
341  {
342  try
343  {
344  rcg::setEnum(nodemap, "ChunkLineSelector", ("Out"+std::to_string(i)).c_str(), true);
345  float v=static_cast<float>(rcg::getFloat(nodemap, "ChunkRcLineRatio", 0, 0, true));
346  out << "camera.out" << i << "_ratio=" << v << std::endl;
347  }
348  catch (const std::exception &)
349  { }
350  }
351 
352  if (scale > 0)
353  {
354  out << "disp.inv=" << inv << std::endl;
355  out << "disp.scale=" << scale << std::endl;
356  out << "disp.offset=" << offset << std::endl;
357  }
358 
359  out.close();
360  }
361  }
362 }
363 
364 // simple mechanism to set the boolean flag when the user presses enter in the
365 // terminal
366 
367 std::atomic<bool> user_interrupt(false);
368 
369 void interruptHandler(int)
370 {
371  std::cout << "Stopping ..." << std::endl;
372 
373  user_interrupt=true;
374 }
375 
376 #ifdef _WIN32
377 
378 void checkUserInterrupt()
379 {
380  char a;
381  std::cin.get(a);
382 
383  std::cout << "Stopping ..." << std::endl;
384 
385  user_interrupt=true;
386 }
387 
388 #endif
389 
390 }
391 
392 int main(int argc, char *argv[])
393 {
394  int ret=0;
395 
396  signal(SIGINT, interruptHandler);
397 
398  try
399  {
400  bool print_chunk_data=false;
401  bool store=true;
402  rcg::ImgFmt fmt=rcg::PNM;
403  int i=1;
404 
405  // get parameters
406 
407  while (i < argc && argv[i][0] == '-')
408  {
409  std::string param=argv[i];
410 
411  if (param == "-h")
412  {
413  printHelp();
414  return 0;
415  }
416  else if (param == "-c")
417  {
418  print_chunk_data=true;
419  i++;
420  }
421  else if (param == "-t")
422  {
423  store=false;
424  i++;
425  }
426  else if (param == "-f")
427  {
428  i++;
429 
430  if (i < argc)
431  {
432  std::string imgfmt=argv[i];
433  if (imgfmt == "pnm")
434  {
435  fmt=rcg::PNM;
436  }
437  else if (imgfmt == "png")
438  {
439  fmt=rcg::PNG;
440  }
441  else
442  {
443  throw std::invalid_argument(std::string("Invalid argument of '-f': ")+argv[i]);
444  }
445 
446  i++;
447  }
448  else
449  {
450  throw std::invalid_argument("Argument expected after '-f'!");
451  }
452  }
453  else
454  {
455  throw std::invalid_argument("Unknown parameter: "+param);
456  }
457  }
458 
459  if (i < argc)
460  {
461  // find specific device accross all systems and interfaces and open it
462 
463  std::shared_ptr<rcg::Device> dev=rcg::getDevice(argv[i]);
464 
465  if (dev)
466  {
467  i++;
468  dev->open(rcg::Device::CONTROL);
469  std::shared_ptr<GenApi::CNodeMapRef> nodemap=dev->getRemoteNodeMap();
470 
471  // try to enable chunks by default (can be disabed by the user)
472 
473  rcg::setBoolean(nodemap, "ChunkModeActive", true);
474 
475  // set values as given on the command line
476 
477  int n=1;
478  while (i < argc)
479  {
480  // split argument in key and value
481 
482  std::string key=argv[i++];
483  std::string value;
484 
485  size_t k=key.find('=');
486  if (k != std::string::npos)
487  {
488  value=key.substr(k+1);
489  key=key.substr(0, k);
490  }
491 
492  if (key == "n") // set number of images
493  {
494  n=std::max(1, std::stoi(value));
495  }
496  else // set key=value pair through GenICam
497  {
498  if (value.size() > 0)
499  {
500  rcg::setString(nodemap, key.c_str(), value.c_str(), true);
501  }
502  else
503  {
504  rcg::callCommand(nodemap, key.c_str(), true);
505  }
506  }
507  }
508 
509  // disable component Intensity if component IntensityCombined is enabled
510 
511  if (rcg::setEnum(nodemap, "ComponentSelector", "IntensityCombined", false) &&
512  rcg::getBoolean(nodemap, "ComponentEnable", true, true))
513  {
514  if (rcg::setEnum(nodemap, "ComponentSelector", "Intensity", false) &&
515  rcg::getBoolean(nodemap, "ComponentEnable", true, true))
516  {
517  rcg::setBoolean(nodemap, "ComponentEnable", false, true);
518 
519  std::cout << std::endl;
520  std::cout << "NOTE: Disabling component 'Intensity' as 'IntensityCombined' is enabled."
521  << std::endl;
522  }
523  }
524 
525  // print enabled streams
526 
527  {
528  std::vector<std::string> component;
529 
530  rcg::getEnum(nodemap, "ComponentSelector", component, false);
531 
532  if (component.size() > 0)
533  {
534  std::cout << std::endl;
535  std::cout << "Available components (1 means enabled, 0 means disabled):" << std::endl;
536  std::cout << std::endl;
537 
538  for (size_t k=0; k<component.size(); k++)
539  {
540  rcg::setEnum(nodemap, "ComponentSelector", component[k].c_str(), true);
541 
542  std::cout << component[k] << ": ";
543  std::cout << rcg::getBoolean(nodemap, "ComponentEnable", true, true);
544  std::cout << std::endl;
545  }
546 
547  std::cout << std::endl;
548  }
549  }
550 
551  // open stream and get n images
552 
553  std::vector<std::shared_ptr<rcg::Stream> > stream=dev->getStreams();
554 
555  if (stream.size() > 0)
556  {
557 #ifdef _WIN32
558  // start background thread for checking user input
559  std::thread thread_cui(checkUserInterrupt);
560  thread_cui.detach();
561 #endif
562 
563  // opening first stream
564 
565  stream[0]->open();
566  stream[0]->attachBuffers(true);
567  stream[0]->startStreaming();
568 
569  std::cout << "Package size: " << rcg::getString(nodemap, "GevSCPSPacketSize") << std::endl;
570 
571 #ifdef _WIN32
572  std::cout << "Press 'Enter' to abort grabbing." << std::endl;
573 #endif
574  std::cout << std::endl;
575 
576  int buffers_received=0;
577  int buffers_incomplete=0;
578  auto time_start=std::chrono::steady_clock::now();
579  double latency_ns=0;
580 
581  for (int k=0; k<n && !user_interrupt; k++)
582  {
583  // grab next image with timeout of 3 seconds
584 
585  int retry=5;
586  while (retry > 0 && !user_interrupt)
587  {
588  const rcg::Buffer *buffer=stream[0]->grab(3000);
589 
590  if (buffer != 0)
591  {
592  if (buffers_received == 0)
593  {
594  time_start=std::chrono::steady_clock::now();
595  }
596 
597  buffers_received++;
598 
599  if (!buffer->getIsIncomplete())
600  {
601  // store images in all parts
602 
603  if (store)
604  {
605  uint32_t npart=buffer->getNumberOfParts();
606  for (uint32_t part=0; part<npart; part++)
607  {
608  if (buffer->getImagePresent(part))
609  {
610  std::string name;
611 
612  // get component name
613 
614  std::string component=rcg::getComponetOfPart(nodemap, buffer, part);
615 
616  // try storing disparity as float image with meta information
617 
618  if (component == "Disparity" && fmt == rcg::PNM)
619  {
620  name=storeBufferAsDisparity(nodemap, buffer, part);
621 
622  if (name.size() != 0)
623  {
624  std::cout << "Image '" << name << "' stored" << std::endl;
625  storeParameter(nodemap, component, buffer);
626  }
627  }
628 
629  // otherwise, store as ordinary image
630 
631  if (name.size() == 0)
632  {
633  if (component == "IntensityCombined")
634  {
635  // splitting left and right image of combined format of
636  // Roboceptions rc_visard camera
637 
638  size_t h2=buffer->getHeight(part)/2;
639  name=storeBuffer(fmt, nodemap, "Intensity", buffer, part, 0, h2);
640 
641  if (name.size() > 0)
642  {
643  std::cout << "Image '" << name << "' stored" << std::endl;
644  }
645 
646  name=storeBuffer(fmt, nodemap, "IntensityRight", buffer, part, h2, h2);
647 
648  if (name.size() > 0)
649  {
650  std::cout << "Image '" << name << "' stored" << std::endl;
651  }
652  }
653  else
654  {
655  name=storeBuffer(fmt, nodemap, component, buffer, part);
656 
657  if (name.size() > 0)
658  {
659  std::cout << "Image '" << name << "' stored" << std::endl;
660  }
661  }
662 
663  // store 3D parameters for intensity and disparity
664  // components (nothing is done if chunk parameters are
665  // not available)
666 
667  if (component == "Intensity")
668  {
669  storeParameter(nodemap, component, buffer);
670  }
671  else if (component == "Disparity")
672  {
673  storeParameter(nodemap, component, buffer, 0, true);
674  }
675  else if (component == "IntensityCombined")
676  {
677  size_t h2=buffer->getHeight(part)/2;
678  storeParameter(nodemap, "Intensity", buffer, h2, false);
679  }
680  }
681 
682  // report success
683 
684  if (name.size() > 0)
685  {
686  retry=0;
687  }
688  }
689  }
690  }
691  else
692  {
693  // just print timestamp of received buffer
694 
695  uint64_t t_sec = buffer->getTimestampNS()/1000000000;
696  uint64_t t_nsec = buffer->getTimestampNS()%1000000000;
697 
698  std::cout << "Received buffer with timestamp: " << t_sec << "."
699  << std::setfill('0') << std::setw(9) << t_nsec << std::endl;
700  retry=0;
701 
702  // accumulate mean latency
703 
704  auto current=std::chrono::system_clock::now();
705  latency_ns+=
706  static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(current.time_since_epoch()).count())-
707  static_cast<double>(buffer->getTimestampNS());
708  }
709 
710  // optinally print chunk data
711 
712  if (print_chunk_data)
713  {
714  std::cout << std::endl;
715 
716  if (!rcg::printNodemap(nodemap, "ChunkDataControl", 100, false))
717  {
718  std::cout << "Cannot find node 'ChunkDataControl'" << std::endl;
719  }
720 
721  std::cout << std::endl;
722  }
723  }
724  else
725  {
726  std::cerr << "Incomplete buffer received" << std::endl;
727  buffers_incomplete++;
728  }
729  }
730  else
731  {
732  std::cerr << "Cannot grab images" << std::endl;
733  break;
734  }
735 
736  retry--;
737  }
738  }
739 
740  auto time_stop=std::chrono::steady_clock::now();
741 
742  stream[0]->stopStreaming();
743  stream[0]->close();
744 
745  // report received and incomplete buffers
746 
747  std::cout << std::endl;
748  std::cout << "Received buffers: " << buffers_received << std::endl;
749  std::cout << "Incomplete buffers: " << buffers_incomplete << std::endl;
750 
751  std::cout << "Buffers per second: " << std::setprecision(3)
752  << 1000.0*buffers_received/std::chrono::duration_cast<std::chrono::milliseconds>(time_stop-time_start).count()
753  << std::endl;
754 
755  if (!store)
756  {
757  if (rcg::getBoolean(nodemap, "PtpEnable") || rcg::getBoolean(nodemap, "GevIEEE1588"))
758  {
759  if (buffers_received-buffers_incomplete > 0)
760  {
761  latency_ns/=buffers_received-buffers_incomplete;
762  }
763 
764  std::cout << "Mean latency: " << std::setprecision(5) << latency_ns/1.0e6
765  << " ms" << std::endl;
766  }
767  }
768 
769  // return error code if no images could be received
770 
771  if (buffers_incomplete == buffers_received)
772  {
773  ret=1;
774  }
775  }
776  else
777  {
778  std::cerr << "No streams available" << std::endl;
779  ret=1;
780  }
781 
782  dev->close();
783  }
784  else
785  {
786  std::cerr << "Device '" << argv[i] << "' not found!" << std::endl;
787  ret=1;
788  }
789  }
790  else
791  {
792  printHelp();
793  ret=1;
794  }
795  }
796  catch (const std::exception &ex)
797  {
798  std::cerr << "Exception: " << ex.what() << std::endl;
799  ret=2;
800  }
801  catch (const GENICAM_NAMESPACE::GenericException &ex)
802  {
803  std::cerr << "Exception: " << ex.what() << std::endl;
804  ret=2;
805  }
806  catch (...)
807  {
808  std::cerr << "Unknown exception!" << std::endl;
809  ret=2;
810  }
811 
813 
814  return ret;
815 }
std::string ensureNewFileName(std::string name)
This method checks if the given file name already exists and produces a new file name if this happens...
Definition: image_store.cc:60
bool getBoolean(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception, bool igncache)
Get the value of a boolean feature of the given nodemap.
Definition: config.cc:518
std::shared_ptr< Device > getDevice(const char *id)
Searches across all transport layers and interfaces for a device.
Definition: device.cc:480
The image class encapsulates image information.
Definition: image.h:55
ImgFmt
Definition: image_store.h:46
std::string storeImage(const std::string &name, ImgFmt fmt, const Image &image, size_t yoffset, size_t height)
Stores the given image.
Definition: image_store.cc:567
bool getContainsChunkdata() const
Returns if the buffer contains chunk data.
Definition: buffer.cc:706
int main(int argc, char *argv[])
Definition: gc_stream.cc:392
__int64 int64_t
Definition: config-win32.h:21
int64_t getInteger(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, int64_t *vmin, int64_t *vmax, bool exception, bool igncache)
Get the value of an integer feature of the given nodemap.
Definition: config.cc:563
std::string str()
bool setEnum(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool exception)
Set the value of an enumeration of the given nodemap.
Definition: config.cc:301
static void clearSystems()
Clears the internal list of systems.
Definition: system.cc:282
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
std::string getEnum(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception)
Get the value of an enumeration of the given nodemap.
Definition: config.cc:676
uint64_t getTimestampNS() const
Returns the acquisition timestamp of the data in this buffer in ns.
Definition: buffer.cc:670
std::string getComponetOfPart(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const Buffer *buffer, uint32_t ipart)
Definition: config.cc:936
bool setString(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool exception)
Set the value of a feature of the given nodemap.
Definition: config.cc:365
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
bool setBoolean(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool value, bool exception)
Set the value of a boolean feature of the given nodemap.
Definition: config.cc:106
double getFloat(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, double *vmin, double *vmax, bool exception, bool igncache)
Get the value of a double feature of the given nodemap.
Definition: config.cc:625
bool callCommand(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception)
Calls the given command.
Definition: config.cc:60
bool getIsIncomplete() const
Signals if the buffer is incomplete due to an error.
Definition: buffer.cc:315
GenICam&#39;s exception class.
Definition: GCException.h:63
bool printNodemap(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char root[], int depth, bool show_enum_list)
Printing of nodemap, starting at given root node.
Definition: nodemap_out.cc:293
std::uint32_t getNumberOfParts() const
Returns the number of parts, excluding chunk data.
Definition: buffer.cc:203
std::string getString(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, bool exception, bool igncache)
Get the value of a feature of the given nodemap.
Definition: config.cc:794
std::string storeImageAsDisparityPFM(const std::string &name, const Image &image, int inv, float scale, float offset)
Stores the given image as disparity.
Definition: image_store.cc:591
virtual const char * what() const
Get error description (overwrite from std:exception)


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