diff --git a/apps/src/openni_3d_concave_hull.cpp b/apps/src/openni_3d_concave_hull.cpp index 822f7a81d7c..d4c0309704a 100644 --- a/apps/src/openni_3d_concave_hull.cpp +++ b/apps/src/openni_3d_concave_hull.cpp @@ -34,6 +34,7 @@ */ #include +#include #include #include #include @@ -165,19 +166,29 @@ class OpenNI3DConcaveHull { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n\n"; + std::cout << "usage: " << argv[0] << " [-device_id X (default: \"#1\")]\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -186,24 +197,28 @@ usage(char** argv) int main(int argc, char** argv) { - std::string arg; - if (argc > 1) - arg = std::string(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } - pcl::OpenNIGrabber grabber(arg); + std::string device_id = ""; + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; + ///////////////////////////////////////////////////////////////////// + + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { PCL_INFO("PointXYZRGBA mode enabled.\n"); - OpenNI3DConcaveHull v(arg); + OpenNI3DConcaveHull v(device_id); v.run(); } else { PCL_INFO("PointXYZ mode enabled.\n"); - OpenNI3DConcaveHull v(arg); + OpenNI3DConcaveHull v(device_id); v.run(); } return 0; diff --git a/apps/src/openni_3d_convex_hull.cpp b/apps/src/openni_3d_convex_hull.cpp index 841e429a36f..674ea43ead0 100644 --- a/apps/src/openni_3d_convex_hull.cpp +++ b/apps/src/openni_3d_convex_hull.cpp @@ -34,6 +34,7 @@ */ #include +#include #include #include #include @@ -163,19 +164,29 @@ class OpenNI3DConvexHull { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n\n"; + std::cout << "usage: " << argv[0] << " [-device_id X (default: \"#1\")]\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -184,24 +195,28 @@ usage(char** argv) int main(int argc, char** argv) { - std::string arg; - if (argc > 1) - arg = std::string(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } - pcl::OpenNIGrabber grabber(arg); + std::string device_id = ""; + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; + ///////////////////////////////////////////////////////////////////// + + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { PCL_INFO("PointXYZRGBA mode enabled.\n"); - OpenNI3DConvexHull v(arg); + OpenNI3DConvexHull v(device_id); v.run(); } else { PCL_INFO("PointXYZ mode enabled.\n"); - OpenNI3DConvexHull v(arg); + OpenNI3DConvexHull v(device_id); v.run(); } return 0; diff --git a/apps/src/openni_boundary_estimation.cpp b/apps/src/openni_boundary_estimation.cpp index 89467dd0c27..d0e45444d3a 100644 --- a/apps/src/openni_boundary_estimation.cpp +++ b/apps/src/openni_boundary_estimation.cpp @@ -36,6 +36,7 @@ */ #include +#include #include #include #include @@ -180,19 +181,29 @@ class OpenNIIntegralImageNormalEstimation { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n\n"; + std::cout << "usage: " << argv[0] << " [-device_id X (default: \"#1\")]\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -201,18 +212,22 @@ usage(char** argv) int main(int argc, char** argv) { - std::string arg; - if (argc > 1) - arg = std::string(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } - pcl::OpenNIGrabber grabber(arg); + std::string device_id = ""; + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; + ///////////////////////////////////////////////////////////////////// + + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { - OpenNIIntegralImageNormalEstimation v(arg); + OpenNIIntegralImageNormalEstimation v(device_id); v.run(); } else diff --git a/apps/src/openni_color_filter.cpp b/apps/src/openni_color_filter.cpp index e06e45f5121..56203ed36f6 100644 --- a/apps/src/openni_color_filter.cpp +++ b/apps/src/openni_color_filter.cpp @@ -159,21 +159,33 @@ class OpenNIPassthrough { void usage(char** argv) { - std::cout << "usage: " << argv[0] - << " [-rgb [-radius ] ]\n\n" - << std::endl; + std::cout << "usage: " << argv[0] << " [options]\n\n" + << "where options are:\n" + << " -device_id X: specify the device id (default: \"#1\").\n" + << " -rgb R G B: -- (default: 0 0 0)\n" + << " -radius X: -- (default: 442)\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << (int)driver.getBus (deviceIdx) << " @ " << (int)driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -182,22 +194,21 @@ usage(char** argv) int main(int argc, char** argv) { - if (argc < 2) { - usage(argv); - return 1; - } - - std::string arg(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } + std::string device_id = ""; unsigned char red = 0, green = 0, blue = 0; int rr, gg, bb; unsigned char radius = 442; // all colors! + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; if (pcl::console::parse_3x_arguments(argc, argv, "-rgb", rr, gg, bb, true) != -1) { std::cout << "-rgb present" << std::endl; int rad; @@ -213,8 +224,9 @@ main(int argc, char** argv) if (bb >= 0 && bb < 256) blue = (unsigned char)bb; } + ///////////////////////////////////////////////////////////////////// - pcl::OpenNIGrabber grabber(arg); + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { OpenNIPassthrough v(grabber, red, green, blue, radius); diff --git a/apps/src/openni_fast_mesh.cpp b/apps/src/openni_fast_mesh.cpp index 63b1026c310..e3701033940 100644 --- a/apps/src/openni_fast_mesh.cpp +++ b/apps/src/openni_fast_mesh.cpp @@ -34,6 +34,7 @@ */ #include +#include #include #include #include @@ -151,27 +152,29 @@ class OpenNIFastMesh { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n\n"; + std::cout << "usage: " << argv[0] << " [-device_id X (default: \"#1\")]\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { - std::cout << "Device: " << deviceIdx + 1 - << ", vendor: " << driver.getVendorName(deviceIdx) - << ", product: " << driver.getProductName(deviceIdx) - << ", connected: " << driver.getBus(deviceIdx) << " @ " - << driver.getAddress(deviceIdx) << ", serial number: \'" - << driver.getSerialNumber(deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in " - "the list or" - << std::endl - << " bus@address for the device connected to a " - "specific usb-bus / address combination (works only in Linux) or" - << std::endl - << " (only in Linux and for devices " - "which provide serial numbers)" + // clang-format off + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; + // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -180,24 +183,28 @@ usage(char** argv) int main(int argc, char** argv) { - std::string arg; - if (argc > 1) - arg = std::string(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } - pcl::OpenNIGrabber grabber(arg); + std::string device_id = ""; + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; + ///////////////////////////////////////////////////////////////////// + + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { PCL_INFO("PointXYZRGBA mode enabled.\n"); - OpenNIFastMesh v(arg); + OpenNIFastMesh v(device_id); v.run(argc, argv); } else { PCL_INFO("PointXYZ mode enabled.\n"); - OpenNIFastMesh v(arg); + OpenNIFastMesh v(device_id); v.run(argc, argv); } return 0; diff --git a/apps/src/openni_feature_persistence.cpp b/apps/src/openni_feature_persistence.cpp index f61571d91a6..0b397bffd51 100644 --- a/apps/src/openni_feature_persistence.cpp +++ b/apps/src/openni_feature_persistence.cpp @@ -232,12 +232,13 @@ void usage(char** argv) { // clang-format off - std::cout << "usage: " << argv[0] << " \n\n" + std::cout << "usage: " << argv[0] << " [options]\n\n" << "where options are:\n" - << " -octree_leaf_size X = size of the leaf for the octree-based subsampling filter (default: " << default_subsampling_leaf_size << "\n" - << " -normal_search_radius X = size of the neighborhood to consider for calculating the local plane and extracting the normals (default: " << default_normal_search_radius << "\n" - << " -persistence_alpha X = value of alpha for the multiscale feature persistence (default: " << default_alpha << "\n" - << " -scales X1 X2 ... = values for the multiple scales for extracting features (default: "; + << " -device_id X: specify the device id (default: \"#1\").\n" + << " -octree_leaf_size X: size of the leaf for the octree-based subsampling filter (default: " << default_subsampling_leaf_size << "\n" + << " -normal_search_radius X: size of the neighborhood to consider for calculating the local plane and extracting the normals (default: " << default_normal_search_radius << "\n" + << " -persistence_alpha X: value of alpha for the multiscale feature persistence (default: " << default_alpha << "\n" + << " -scales X1 X2 ...: values for the multiple scales for extracting features (default: "; // clang-format on for (const double& i : default_scales_vector) std::cout << i << " "; @@ -247,13 +248,23 @@ usage(char** argv) if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -266,41 +277,43 @@ main(int argc, char** argv) "MultiscaleFeaturePersistence class using the FPFH features\n" << "Use \"-h\" to get more info about the available options.\n"; - std::string arg = ""; - if ((argc > 1) && (argv[1][0] != '-')) - arg = std::string(argv[1]); - - if (pcl::console::find_argument(argc, argv, "-h") == -1) { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } - // Parse arguments + std::string device_id = ""; float subsampling_leaf_size = default_subsampling_leaf_size; - pcl::console::parse_argument(argc, argv, "-octree_leaf_size", subsampling_leaf_size); double normal_search_radius = default_normal_search_radius; + std::vector scales_vector_double = default_scales_vector; + std::vector scales_vector(scales_vector_double.size()); + float alpha = default_alpha; + + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; + pcl::console::parse_argument(argc, argv, "-octree_leaf_size", subsampling_leaf_size); pcl::console::parse_argument( argc, argv, "-normal_search_radius", normal_search_radius); - std::vector scales_vector_double = default_scales_vector; pcl::console::parse_multiple_arguments(argc, argv, "-scales", scales_vector_double); - std::vector scales_vector(scales_vector_double.size()); for (std::size_t i = 0; i < scales_vector_double.size(); ++i) scales_vector[i] = float(scales_vector_double[i]); - - float alpha = default_alpha; pcl::console::parse_argument(argc, argv, "-persistence_alpha", alpha); + ///////////////////////////////////////////////////////////////////// - pcl::OpenNIGrabber grabber(arg); + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { PCL_INFO("PointXYZRGBA mode enabled.\n"); OpenNIFeaturePersistence v( - subsampling_leaf_size, normal_search_radius, scales_vector, alpha, arg); + subsampling_leaf_size, normal_search_radius, scales_vector, alpha, device_id); v.run(); } else { PCL_INFO("PointXYZ mode enabled.\n"); OpenNIFeaturePersistence v( - subsampling_leaf_size, normal_search_radius, scales_vector, alpha, arg); + subsampling_leaf_size, normal_search_radius, scales_vector, alpha, device_id); v.run(); } diff --git a/apps/src/openni_grab_images.cpp b/apps/src/openni_grab_images.cpp index 68503d9df8c..3d1dc8ba9e3 100644 --- a/apps/src/openni_grab_images.cpp +++ b/apps/src/openni_grab_images.cpp @@ -360,13 +360,15 @@ main(int argc, char** argv) std::string device_id(""); pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode; + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { + usage(argv); + return 1; + } + if (argc >= 2) { device_id = argv[1]; - if (device_id == "--help" || device_id == "-h") { - usage(argv); - return 0; - } - else if (device_id == "-l") { + if (device_id == "-l") { if (argc >= 3) { pcl::OpenNIGrabber grabber(argv[2]); auto device = grabber.getDevice(); diff --git a/apps/src/openni_ii_normal_estimation.cpp b/apps/src/openni_ii_normal_estimation.cpp index ea918916989..942447f35b2 100644 --- a/apps/src/openni_ii_normal_estimation.cpp +++ b/apps/src/openni_ii_normal_estimation.cpp @@ -34,6 +34,7 @@ */ #include +#include #include #include #include @@ -190,19 +191,29 @@ class OpenNIIntegralImageNormalEstimation { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " []\n\n"; + std::cout << "usage: " << argv[0] << " [-device_id X (default: \"#1\")]\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -211,16 +222,19 @@ usage(char** argv) int main(int argc, char** argv) { - std::string arg; - if (argc > 1) - arg = std::string(argv[1]); - - openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); - if (arg == "--help" || arg == "-h" || driver.getNumberDevices() == 0) { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } + std::string device_id = ""; + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; + ///////////////////////////////////////////////////////////////////// + // clang-format off std::cout << "Press following keys to switch to the different integral image normal estimation methods:\n"; std::cout << "<1> COVARIANCE_MATRIX method\n"; @@ -230,15 +244,15 @@ main(int argc, char** argv) std::cout << " quit\n\n"; // clang-format on - pcl::OpenNIGrabber grabber(arg); + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { PCL_INFO("PointXYZRGBA mode enabled.\n"); - OpenNIIntegralImageNormalEstimation v(arg); + OpenNIIntegralImageNormalEstimation v(device_id); v.run(); } else { PCL_INFO("PointXYZ mode enabled.\n"); - OpenNIIntegralImageNormalEstimation v(arg); + OpenNIIntegralImageNormalEstimation v(device_id); v.run(); } diff --git a/apps/src/openni_klt.cpp b/apps/src/openni_klt.cpp index 6bab5e4e972..41b5f81c067 100644 --- a/apps/src/openni_klt.cpp +++ b/apps/src/openni_klt.cpp @@ -312,12 +312,14 @@ main(int argc, char** argv) pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode; bool xyz = false; + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { + printHelp(argc, argv); + return 1; + } + if (argc >= 2) { device_id = argv[1]; - if (device_id == "--help" || device_id == "-h") { - printHelp(argc, argv); - return 0; - } if (device_id == "-l") { if (argc >= 3) { pcl::OpenNIGrabber grabber(argv[2]); diff --git a/apps/src/openni_mls_smoothing.cpp b/apps/src/openni_mls_smoothing.cpp index c45514323c5..641c341c745 100644 --- a/apps/src/openni_mls_smoothing.cpp +++ b/apps/src/openni_mls_smoothing.cpp @@ -177,24 +177,35 @@ void usage(char** argv) { // clang-format off - std::cout << "usage: " << argv[0] << " \n\n" + std::cout << "usage: " << argv[0] << " [options]\n\n" << "where options are:\n" - << " -search_radius X = sphere radius to be used for finding the k-nearest neighbors used for fitting (default: " << default_search_radius << ")\n" - << " -sqr_gauss_param X = parameter used for the distance based weighting of neighbors (recommended = search_radius^2) (default: " << default_sqr_gauss_param << ")\n" - << " -polynomial_order X = order of the polynomial to be fit (0 means tangent estimation) (default: " << default_polynomial_order << ")\n"; + << " -device_id X: specify the device id (default: \"#1\").\n" + << " -search_radius X: sphere radius to be used for finding the k-nearest neighbors used for fitting (default: " << default_search_radius << ")\n" + << " -sqr_gauss_param X: parameter used for the distance based weighting of neighbors (recommended = search_radius^2) (default: " << default_sqr_gauss_param << ")\n" + << " -polynomial_order X: order of the polynomial to be fit (0 means tangent estimation) (default: " << default_polynomial_order << ")\n\n"; // clang-format on openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -203,39 +214,44 @@ usage(char** argv) int main(int argc, char** argv) { - if (argc < 2) { - usage(argv); - return 1; - } - - std::string arg(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } - // Command line parsing + std::string device_id = ""; double search_radius = default_search_radius; double sqr_gauss_param = default_sqr_gauss_param; bool sqr_gauss_param_set = true; int polynomial_order = default_polynomial_order; + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; pcl::console::parse_argument(argc, argv, "-search_radius", search_radius); if (pcl::console::parse_argument(argc, argv, "-sqr_gauss_param", sqr_gauss_param) == -1) sqr_gauss_param_set = false; pcl::console::parse_argument(argc, argv, "-polynomial_order", polynomial_order); + ///////////////////////////////////////////////////////////////////// - pcl::OpenNIGrabber grabber(arg); + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { - OpenNISmoothing v( - search_radius, sqr_gauss_param_set, sqr_gauss_param, polynomial_order, arg); + OpenNISmoothing v(search_radius, + sqr_gauss_param_set, + sqr_gauss_param, + polynomial_order, + device_id); v.run(); } else { - OpenNISmoothing v( - search_radius, sqr_gauss_param_set, sqr_gauss_param, polynomial_order, arg); + OpenNISmoothing v(search_radius, + sqr_gauss_param_set, + sqr_gauss_param, + polynomial_order, + device_id); v.run(); } diff --git a/apps/src/openni_mobile_server.cpp b/apps/src/openni_mobile_server.cpp index e4440dcd0f0..bf6778d1ff5 100644 --- a/apps/src/openni_mobile_server.cpp +++ b/apps/src/openni_mobile_server.cpp @@ -221,29 +221,33 @@ class PCLMobileServer { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n" + std::cout << "usage: " << argv[0] << " [options]\n\n" << "where options are:\n" - << " -port p :: set the server port (default: 11111)\n" - << " -leaf x, y, z :: set the voxel grid leaf size (default: 0.01)\n"; + << " -device_id X: specify the device id (default: \"#1\").\n" + << " -port p: set the server port (default: 11111)\n" + << " -leaf x, y, z: set the voxel grid leaf size (default: 0.01)\n"; } int main(int argc, char** argv) { - std::string device_id = ""; - if ((argc > 1) && (argv[1][0] != '-')) - device_id = std::string(argv[1]); - - if (pcl::console::find_argument(argc, argv, "-h") != -1) { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); - return 0; + return 1; } + std::string device_id = ""; int port = 11111; float leaf_x = 0.01f, leaf_y = 0.01f, leaf_z = 0.01f; + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; pcl::console::parse_argument(argc, argv, "-port", port); pcl::console::parse_3x_arguments(argc, argv, "-leaf", leaf_x, leaf_y, leaf_z, false); + ///////////////////////////////////////////////////////////////////// pcl::OpenNIGrabber grabber(device_id); if (!grabber.providesCallback()) { diff --git a/apps/src/openni_organized_edge_detection.cpp b/apps/src/openni_organized_edge_detection.cpp index 1fc6aee478a..0042f36ffcb 100644 --- a/apps/src/openni_organized_edge_detection.cpp +++ b/apps/src/openni_organized_edge_detection.cpp @@ -34,6 +34,7 @@ */ #include +#include #include #include #include @@ -286,19 +287,29 @@ class OpenNIOrganizedEdgeDetection { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n\n"; + std::cout << "usage: " << argv[0] << " [-device_id X (default: \"#1\")]\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -307,15 +318,19 @@ usage(char** argv) int main(int argc, char** argv) { - std::string arg; - if (argc > 1) - arg = std::string(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } + std::string device_id = ""; + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; + ///////////////////////////////////////////////////////////////////// + // clang-format off std::cout << "Press following keys to enable/disable the different edge types:" << std::endl; std::cout << "<1> EDGELABEL_NAN_BOUNDARY edge" << std::endl; @@ -325,7 +340,7 @@ main(int argc, char** argv) //std::cout << "<5> EDGELABEL_RGB_CANNY edge" << std::endl; std::cout << " quit" << std::endl; // clang-format on - pcl::OpenNIGrabber grabber(arg); + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { OpenNIOrganizedEdgeDetection app; app.run(); diff --git a/apps/src/openni_planar_convex_hull.cpp b/apps/src/openni_planar_convex_hull.cpp index fab465bcf93..d42481a2caa 100644 --- a/apps/src/openni_planar_convex_hull.cpp +++ b/apps/src/openni_planar_convex_hull.cpp @@ -150,9 +150,11 @@ class OpenNIPlanarSegmentation { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n\n" - << "where options are:\n -thresh X :: set the planar " - "segmentation threshold (default: 0.5)\n"; + std::cout + << "usage: " << argv[0] << " [options]\n\n" + << "where options are:\n" + << " -device_id X: specify the device id (default: \"#1\").\n" + << " -thresh X: set the planar segmentation threshold (default: 0.5)\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { @@ -165,6 +167,16 @@ usage(char** argv) << " (only in Linux and for devices which provide serial numbers)" << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -173,28 +185,29 @@ usage(char** argv) int main(int argc, char** argv) { - if (argc < 2) { - usage(argv); - return 1; - } - - std::string arg(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } + std::string device_id = ""; double threshold = 0.05; + + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; pcl::console::parse_argument(argc, argv, "-thresh", threshold); + ///////////////////////////////////////////////////////////////////// - pcl::OpenNIGrabber grabber(arg); + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { - OpenNIPlanarSegmentation v(arg, threshold); + OpenNIPlanarSegmentation v(device_id, threshold); v.run(); } else { - OpenNIPlanarSegmentation v(arg, threshold); + OpenNIPlanarSegmentation v(device_id, threshold); v.run(); } diff --git a/apps/src/openni_planar_segmentation.cpp b/apps/src/openni_planar_segmentation.cpp index cb9afd704be..d06d4fde3b0 100644 --- a/apps/src/openni_planar_segmentation.cpp +++ b/apps/src/openni_planar_segmentation.cpp @@ -143,21 +143,33 @@ class OpenNIPlanarSegmentation { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n\n" - << "where options are:\n -thresh X :: set the planar " - "segmentation threshold (default: 0.5)\n"; + std::cout + << "usage: " << argv[0] << " [options]\n\n" + << "where options are:\n" + << " -device_id X: specify the device id (default: \"#1\").\n" + << " -thresh X: set the planar segmentation threshold (default: 0.5)\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -166,28 +178,29 @@ usage(char** argv) int main(int argc, char** argv) { - if (argc < 2) { - usage(argv); - return 1; - } - - std::string arg(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } + std::string device_id = ""; double threshold = 0.05; + + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; pcl::console::parse_argument(argc, argv, "-thresh", threshold); + ///////////////////////////////////////////////////////////////////// - pcl::OpenNIGrabber grabber(arg); + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { - OpenNIPlanarSegmentation v(arg, threshold); + OpenNIPlanarSegmentation v(device_id, threshold); v.run(); } else { - OpenNIPlanarSegmentation v(arg, threshold); + OpenNIPlanarSegmentation v(device_id, threshold); v.run(); } diff --git a/apps/src/openni_tracking.cpp b/apps/src/openni_tracking.cpp index 1ea742c688f..174f889a19c 100644 --- a/apps/src/openni_tracking.cpp +++ b/apps/src/openni_tracking.cpp @@ -646,46 +646,49 @@ class OpenNISegmentTracking { void usage(char** argv) { - // clang-format off - std::cout << "usage: " << argv[0] << " [-C] [-g]\n\n"; - std::cout << " -C: initialize the pointcloud to track without plane segmentation\n"; - std::cout << " -D: visualizing with non-downsampled pointclouds.\n"; - std::cout << " -P: not visualizing particle cloud.\n"; - std::cout << " -fixed: use the fixed number of the particles.\n"; - std::cout << " -d : specify the grid size of downsampling (defaults to 0.01)." << std::endl; - // clang-format on + // clang format off + std::cout + << "usage: " << argv[0] << " [options]\n\n" + << "where options are:\n" + << " -device_id device_id: specify the device id (defaults to \"#1\").\n" + << " -C: initialize the pointcloud to track without plane segmentation.\n" + << " -D: visualizing with non-downsampled pointclouds.\n" + << " -P: not visualizing particle cloud.\n" + << " -fixed: use the fixed number of the particles.\n" + << " -d: specify the grid size of downsampling (defaults to 0.01)."; + // clang format on } int main(int argc, char** argv) { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { + usage(argv); + return 1; + } + + std::string device_id = ""; bool use_convex_hull = true; bool visualize_non_downsample = false; bool visualize_particles = true; bool use_fixed = false; - double downsampling_grid_size = 0.01; - if (pcl::console::find_argument(argc, argv, "-C") > 0) + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; + if (pcl::console::find_argument(argc, argv, "-C") != -1) use_convex_hull = false; - if (pcl::console::find_argument(argc, argv, "-D") > 0) + if (pcl::console::find_argument(argc, argv, "-D") != -1) visualize_non_downsample = true; - if (pcl::console::find_argument(argc, argv, "-P") > 0) + if (pcl::console::find_argument(argc, argv, "-P") != -1) visualize_particles = false; - if (pcl::console::find_argument(argc, argv, "-fixed") > 0) + if (pcl::console::find_argument(argc, argv, "-fixed") != -1) use_fixed = true; pcl::console::parse_argument(argc, argv, "-d", downsampling_grid_size); - if (argc < 2) { - usage(argv); - exit(1); - } - - std::string device_id = std::string(argv[1]); - - if (device_id == "--help" || device_id == "-h") { - usage(argv); - exit(1); - } + ///////////////////////////////////////////////////////////////////// // open kinect OpenNISegmentTracking v(device_id, diff --git a/apps/src/openni_uniform_sampling.cpp b/apps/src/openni_uniform_sampling.cpp index fbce9edc772..6167cdacb3c 100644 --- a/apps/src/openni_uniform_sampling.cpp +++ b/apps/src/openni_uniform_sampling.cpp @@ -147,22 +147,32 @@ class OpenNIUniformSampling { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n\n" + std::cout << "usage: " << argv[0] << " [options]\n\n" << "where options are:\n" - << " -leaf X :: set the UniformSampling leaf " - "size (default: 0.01)\n"; + << " -device_id X: specify the device id (default: \"#1\").\n" + << " -leaf X: set the UniformSampling leaf size (default: 0.01)\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -171,24 +181,24 @@ usage(char** argv) int main(int argc, char** argv) { - if (argc < 2) { - usage(argv); - return 1; - } - - std::string arg(argv[1]); - - if (arg == "--help" || arg == "-h") { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } + std::string device_id = ""; float leaf_res = 0.05f; + + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; pcl::console::parse_argument(argc, argv, "-leaf", leaf_res); PCL_INFO("Using %f as a leaf size for UniformSampling.\n", leaf_res); + ///////////////////////////////////////////////////////////////////// - pcl::OpenNIGrabber grabber(arg); - OpenNIUniformSampling v(arg, leaf_res); + OpenNIUniformSampling v(device_id, leaf_res); v.run(); return 0; diff --git a/apps/src/openni_voxel_grid.cpp b/apps/src/openni_voxel_grid.cpp index 91274e7312e..27749cbe325 100644 --- a/apps/src/openni_voxel_grid.cpp +++ b/apps/src/openni_voxel_grid.cpp @@ -141,26 +141,37 @@ class OpenNIVoxelGrid { void usage(char** argv) { - std::cout << "usage: " << argv[0] << " \n\n" - << "where options are:\n -minmax min-max :: set the " - "ApproximateVoxelGrid min-max cutting values (default: 0-5.0)\n" - << " -field X :: use field/dimension 'X' to filter data on " - "(default: 'z')\n" - - << " -leaf x, y, z :: set the " - "ApproximateVoxelGrid leaf size (default: 0.01)\n"; + std::cout + << "usage: " << argv[0] << " [options]\n\n" + << "where options are:\n" + << " -device_id X: specify the device id (default: \"#1\").\n" + << " -minmax min-max: set the ApproximateVoxelGrid min-max cutting values " + "(default: 0-5.0)\n" + << " -field X: use field/dimension 'X' to filter data on (default: 'z')\n" + << " -leaf x, y, z: set the ApproximateVoxelGrid leaf size (default: " + "0.01)\n\n"; openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance(); if (driver.getNumberDevices() > 0) { for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices(); ++deviceIdx) { // clang-format off - std::cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx) - << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << std::endl; - std::cout << "device_id may be #1, #2, ... for the first second etc device in the list or" << std::endl - << " bus@address for the device connected to a specific usb-bus / address combination (works only in Linux) or" << std::endl - << " (only in Linux and for devices which provide serial numbers)" << std::endl; + std::cout << "Device: " << deviceIdx + 1 + << ", vendor: " << driver.getVendorName (deviceIdx) + << ", product: " << driver.getProductName (deviceIdx) + << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" + << std::endl; // clang-format on } + + std::cout << "\ndevice_id may be:" << std::endl + << " #1, #2, ... for the first second etc device in the list or" + << std::endl + + << " bus@address for the device connected to a specific " + "usb-bus/address combination (works only in Linux) or" + + << " (only in Linux and for devices which provide " + "serial numbers)"; } else std::cout << "No devices connected." << std::endl; @@ -169,34 +180,40 @@ usage(char** argv) int main(int argc, char** argv) { - std::string arg = ""; - if ((argc > 1) && (argv[1][0] != '-')) - arg = std::string(argv[1]); - - if (pcl::console::find_argument(argc, argv, "-h") != -1) { + ///////////////////////////////////////////////////////////////////// + if (pcl::console::find_argument(argc, argv, "-h") != -1 || + pcl::console::find_argument(argc, argv, "--help") != -1) { usage(argv); return 1; } + std::string device_id = ""; float min_v = 0.0f, max_v = 5.0f; + std::string field_name = "z"; + float leaf_x = 0.01f, leaf_y = 0.01f, leaf_z = 0.01f; + + if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && + argc > 1 && argv[1][0] != '-') + device_id = argv[1]; + pcl::console::parse_2x_arguments(argc, argv, "-minmax", min_v, max_v); - std::string field_name("z"); pcl::console::parse_argument(argc, argv, "-field", field_name); PCL_INFO( "Filtering data on %s between %f -> %f.\n", field_name.c_str(), min_v, max_v); - float leaf_x = 0.01f, leaf_y = 0.01f, leaf_z = 0.01f; + pcl::console::parse_3x_arguments(argc, argv, "-leaf", leaf_x, leaf_y, leaf_z); PCL_INFO("Using %f, %f, %f as a leaf size for VoxelGrid.\n", leaf_x, leaf_y, leaf_z); + ///////////////////////////////////////////////////////////////////// - pcl::OpenNIGrabber grabber(arg); + pcl::OpenNIGrabber grabber(device_id); if (grabber.providesCallback()) { OpenNIVoxelGrid v( - arg, field_name, min_v, max_v, leaf_x, leaf_y, leaf_z); + device_id, field_name, min_v, max_v, leaf_x, leaf_y, leaf_z); v.run(); } else { OpenNIVoxelGrid v( - arg, field_name, min_v, max_v, leaf_x, leaf_y, leaf_z); + device_id, field_name, min_v, max_v, leaf_x, leaf_y, leaf_z); v.run(); }