57 void printHelp(
const char *prgname)
61 std::cout << prgname <<
" -h | [-o <output-filename>] [<interface-id>:]<device-id>" << std::endl;
62 std::cout << std::endl;
63 std::cout <<
"Gets the first synchronized image set of the Roboception rc_visard, consisting of left, disparity, confidence and error image, creates a point cloud and stores it in ply ascii format." << std::endl;
64 std::cout << std::endl;
65 std::cout <<
"Options:" << std::endl;
66 std::cout <<
"-h Prints help information and exits" << std::endl;
67 std::cout <<
"-o <file> Set name of output file (default is 'rc_visard_<timestamp>.ply')" << std::endl;
68 std::cout << std::endl;
69 std::cout <<
"Parameters:" << std::endl;
70 std::cout <<
"<interface-id> Optional GenICam ID of interface for connecting to the device" << std::endl;
71 std::cout <<
"<device-id> GenICam device ID, serial number or user defined name of device" << std::endl;
76 int main(
int argc,
char *argv[])
90 if (std::string(argv[i]) ==
"-o")
97 std::cout <<
"Unknown parameter: " << argv[i] << std::endl;
98 std::cout << std::endl;
106 if (i >= argc || std::string(argv[i]) ==
"-h")
119 std::shared_ptr<GenApi::CNodeMapRef> nodemap=dev->getRemoteNodeMap();
123 double f=
rcg::getFloat(nodemap,
"FocalLengthFactor", 0, 0,
false);
125 double scale=
rcg::getFloat(nodemap,
"Scan3dCoordinateScale", 0, 0,
true);
144 std::string linesource=
rcg::getEnum(nodemap,
"LineSource",
true);
145 std::string filter=
rcg::getEnum(nodemap,
"AcquisitionAlternateFilter",
true);
147 if (linesource ==
"ExposureAlternateActive" && filter ==
"OnlyLow")
152 catch (
const std::exception &)
166 rcg::setEnum(nodemap,
"PixelFormat",
"YCbCr411_8",
false);
172 std::vector<std::string> component;
174 rcg::getEnum(nodemap,
"ComponentSelector", component,
true);
176 for (
size_t k=0; k<component.size(); k++)
178 rcg::setEnum(nodemap,
"ComponentSelector", component[k].c_str(),
true);
180 bool enable=(component[k] ==
"Intensity" || component[k] ==
"Disparity" ||
181 component[k] ==
"Confidence" || component[k] ==
"Error");
189 rcg::setString(nodemap,
"AcquisitionMultiPartMode",
"SynchronizedComponents");
193 std::vector<std::shared_ptr<rcg::Stream> > stream=dev->getStreams();
195 if (stream.size() > 0)
200 stream[0]->startStreaming();
211 int async=0, maxasync=50;
213 while (run && async < maxasync)
229 for (uint32_t part=0; part<partn; part++)
240 if (component ==
"Intensity")
242 left_list.
add(buffer, part);
245 else if (component ==
"Disparity")
247 disp_list.
add(buffer, part);
250 else if (component ==
"Confidence")
252 conf_list.
add(buffer, part);
255 else if (component ==
"Error")
257 error_list.
add(buffer, part);
264 std::shared_ptr<const rcg::Image>
left=left_list.
find(timestamp, left_tol);
265 std::shared_ptr<const rcg::Image> disp=disp_list.
find(timestamp, disp_tol);
270 std::shared_ptr<const rcg::Image> conf;
271 std::shared_ptr<const rcg::Image> error;
275 conf=conf_list.
find(disp->getTimestampNS());
276 error=error_list.
find(disp->getTimestampNS());
279 if (left && disp && conf && error)
305 std::cerr <<
"Cannot grab images" << std::endl;
312 if (async >= maxasync && run)
314 std::cerr <<
"Cannot grab synchronized left and disparity image" << std::endl;
320 stream[0]->stopStreaming();
325 std::cerr <<
"No streams available" << std::endl;
335 std::cerr <<
"Device '" << argv[1] <<
"' not found!" << std::endl;
339 catch (
const std::exception &ex)
341 std::cerr << ex.what() << std::endl;
346 std::cerr <<
"Exception: " << ex.
what() << std::endl;
351 std::cerr <<
"Unknown exception!" << std::endl;
std::shared_ptr< Device > getDevice(const char *id)
Searches across all transport layers and interfaces for a device.
std::shared_ptr< const Image > find(uint64_t timestamp) const
Returns the image that has the given timestamp.
void storePointCloud(std::string name, double f, double t, double scale, std::shared_ptr< const Image > left, std::shared_ptr< const Image > disp, std::shared_ptr< const Image > conf, std::shared_ptr< const Image > error)
An object of this class manages a limited number of images.
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.
static void clearSystems()
Clears the internal list of systems.
void removeOld(uint64_t timestamp)
Removes all images that have a timestamp that is older or equal than the given timestamp.
The buffer class encapsulates a Genicam buffer that is provided by a stream.
void checkFeature(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const char *name, const char *value, bool igncache)
Checks the value of given feature and throws an exception in case of a mismatch.
LOG4CPP_EXPORT CategoryStream & left(CategoryStream &os)
left manipulator
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.
void add(const std::shared_ptr< const Image > &image)
Adds the given image to the internal list.
std::string getComponetOfPart(const std::shared_ptr< GenApi::CNodeMapRef > &nodemap, const Buffer *buffer, uint32_t ipart)
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.
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.
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.
uint64_t getTimestampNS() const
Returns the acquisition timestamp of the data in this buffer in ns.
bool getImagePresent(std::uint32_t part) const
Returns if a 2D, 3D or confidence image is present in the specified part.
bool getIsIncomplete() const
Signals if the buffer is incomplete due to an error.
GenICam's exception class.
int main(int argc, char *argv[])
virtual const char * what() const
Get error description (overwrite from std:exception)
std::uint32_t getNumberOfParts() const
Returns the number of parts, excluding chunk data.