libvisiontransfer  6.4.0
parameter_example.cpp
1 /*******************************************************************************
2  * Copyright (c) 2019 Nerian Vision GmbH
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *******************************************************************************/
14 
15 #include <visiontransfer/deviceenumeration.h>
16 #include <visiontransfer/imagetransfer.h>
17 #include <visiontransfer/imagepair.h>
18 #include <visiontransfer/scenescanparameters.h>
19 #include <iostream>
20 #include <exception>
21 #include <iomanip>
22 #include <stdio.h>
23 
24 #ifdef _MSC_VER
25  #include <windows.h>
26  // Visual studio does not come with snprintf or sleep
27  #define snprintf _snprintf_s
28  #define sleep(x) Sleep(x*1000)
29 #else
30  #include <unistd.h>
31 #endif
32 
33 using namespace visiontransfer;
34 
35 int main() {
36  try {
37  // Search for SceneScan devices
38  DeviceEnumeration deviceEnum;
39 
40  DeviceEnumeration::DeviceList devices = deviceEnum.discoverDevices();
41  if(devices.size() == 0) {
42  std::cout << "No devices discovered!" << std::endl;
43  return -1;
44  }
45 
46  // Print devices
47  std::cout << "Discovered devices:" << std::endl;
48  for(unsigned int i = 0; i< devices.size(); i++) {
49  std::cout << devices[i].toString() << std::endl;
50  }
51  std::cout << std::endl;
52 
53  // Create an image transfer object that receives data from
54  // the first detected SceneScan
55  SceneScanParameters parameters(devices[0]);
56 
57  // Output the current parameterization
58 
59  const int colW = 35;
60  std::cout << std::boolalpha << std::left;
61  std::cout << "Current Parameters" << std::endl;
62  std::cout << "==================" << std::endl << std::endl;
63  std::cout << std::setw(colW) << "Operation mode: " << parameters.getOperationMode() << std::endl;
64  std::cout << std::setw(colW) << "Disparity offset: " << parameters.getDisparityOffset() << std::endl;
65  std::cout << std::setw(colW) << "Stereo P1: " << parameters.getStereoMatchingP1() << std::endl;
66  std::cout << std::setw(colW) << "Stereo P2: " << parameters.getStereoMatchingP2() << std::endl;
67  std::cout << std::setw(colW) << "Mask border pixels: " << parameters.getMaskBorderPixelsEnabled() << std::endl;
68  std::cout << std::setw(colW) << "Consistency check enabled: " << parameters.getConsistencyCheckEnabled() << std::endl;
69  std::cout << std::setw(colW) << "Consistency check sensitivity: " << parameters.getConsistencyCheckSensitivity() << std::endl;
70  std::cout << std::setw(colW) << "Uniqueness check enabled: " << parameters.getUniquenessCheckEnabled() << std::endl;
71  std::cout << std::setw(colW) << "Uniqueness check sensitivity: " << parameters.getUniquenessCheckSensitivity() << std::endl;
72  std::cout << std::setw(colW) << "Texture filter enabled: " << parameters.getTextureFilterEnabled() << std::endl;
73  std::cout << std::setw(colW) << "Texture filter sensitivity: " << parameters.getTextureFilterSensitivity() << std::endl;
74  std::cout << std::setw(colW) << "Gap interpolation enabled: " << parameters.getGapInterpolationEnabled() << std::endl;
75  std::cout << std::setw(colW) << "Noise reduction enabled: " << parameters.getNoiseReductionEnabled() << std::endl;
76  std::cout << std::setw(colW) << "Speckle filter enabled: " << parameters.getSpeckleFilterEnabled() << std::endl;
77  std::cout << std::setw(colW) << "Auto exposure/gain mode: " << parameters.getAutoMode() << std::endl;
78  std::cout << std::setw(colW) << "Auto target intensity: " << parameters.getAutoTargetIntensity() << std::endl;
79  std::cout << std::setw(colW) << "Auto intensity delta : " << parameters.getAutoIntensityDelta() << std::endl;
80  std::cout << std::setw(colW) << "Auto target frame: " << parameters.getAutoTargetFrame() << std::endl;
81  std::cout << std::setw(colW) << "Auto skipped frames: " << parameters.getAutoSkippedFrames() << std::endl;
82  std::cout << std::setw(colW) << "Maximum auto exposure time: " << parameters.getAutoMaxExposureTime() << " us" << std::endl;
83  std::cout << std::setw(colW) << "Maximum auto gain: " << parameters.getAutoMaxGain() << " dB" << std::endl;
84  std::cout << std::setw(colW) << "Manual exposure time: " << parameters.getManualExposureTime() << " us" << std::endl;
85  std::cout << std::setw(colW) << "Manual gain: " << parameters.getManualGain() << " dB" << std::endl;
86  std::cout << std::setw(colW) << "Auto ROI enabled: " << parameters.getAutoROIEnabled() << std::endl;
87 
88  int x = 0, y = 0, width = 0, height = 0;
89  parameters.getAutoROI(x, y, width, height);
90  std::cout << std::setw(colW) << "Auto ROI: " << "(" << x << ", " << y << ") (" << width << " x " << height << ")" << std::endl;
91 
92  std::cout << std::setw(colW) << "Maximum frame time difference: " << parameters.getMaxFrameTimeDifference() << " ms" << std::endl;
93  std::cout << std::setw(colW) << "Trigger frequency: " << parameters.getTriggerFrequency() << " Hz" << std::endl;
94  std::cout << std::setw(colW) << "Trigger 0 enabled: " << parameters.getTrigger0Enabled() << std::endl;
95  std::cout << std::setw(colW) << "Trigger 1 enabled: " << parameters.getTrigger1Enabled() << std::endl;
96  std::cout << std::setw(colW) << "Trigger 0 pulse width: " << parameters.getTrigger0PulseWidth() << " ms"<< std::endl;
97  std::cout << std::setw(colW) << "Trigger 1 pulse width: " << parameters.getTrigger1PulseWidth() << " ms"<< std::endl;
98  std::cout << std::setw(colW) << "Trigger 1 offset: " << parameters.getTrigger1Offset() << " ms"<< std::endl;
99  std::cout << std::setw(colW) << "Auto re-calibration enabled: " << parameters.getAutoRecalibrationEnabled() << std::endl;
100  std::cout << std::setw(colW) << "Save auto re-calibration: " << parameters.getSaveAutoReclabration() << std::endl;
101 
102 
103  // Change a few selected parameters
104 
105  std::cout << std::endl
106  << "Changing Parameters" << std::endl
107  << "==================" << std::endl << std::endl;
108 
109  std::cout << "Operation mode..." << std:: endl;
110  parameters.setOperationMode(SceneScanParameters::PASS_THROUGH);
111  sleep(1);
112  parameters.setOperationMode(SceneScanParameters::STEREO_MATCHING);
113  sleep(1);
114 
115  std::cout << "Disparity offset..." << std:: endl;
116  parameters.setDisparityOffset(10);
117  sleep(1);
118  parameters.setDisparityOffset(0);
119  sleep(1);
120 
121  std::cout << "Auto exposure target brightness..." << std:: endl;
122  parameters.setAutoTargetIntensity(0.7);
123  sleep(1);
124  parameters.setAutoTargetIntensity(0.33);
125  sleep(1);
126 
127  std::cout << "Trigger frequency..." << std:: endl;
128  parameters.setTriggerFrequency(5);
129  sleep(1);
130  parameters.setTriggerFrequency(30);
131  sleep(1);
132 
133  return 0;
134  } catch(const std::exception& ex) {
135  std::cerr << "Exception occurred: " << ex.what() << std::endl;
136  }
137 
138  return 0;
139 }
140 
DeviceList discoverDevices()
Discovers new devices and returns the list of all devices that have been found.
The device passes through the input images without modification.
Allows a configuration of SceneScan&#39;s parameters through a network connection.
Allows for the discovery of devices in the network.
Nerian Vision Technologies