38 #ifndef WIN32_LEAN_AND_MEAN
39 #define WIN32_LEAN_AND_MEAN 1
52 #include <MultiSense/MultiSenseChannel.hh>
62 volatile bool done =
false;
64 void usage(
const char *name)
66 std::cerr <<
"USAGE: " << name <<
" [<options>]" << std::endl;
67 std::cerr <<
"Where <options> are:" << std::endl;
68 std::cerr <<
"\t-a <current_address> : CURRENT IPV4 address (default=10.66.171.21)" << std::endl;
69 std::cerr <<
"\t-m <mtu> : MTU to use to communicate with the camera (default=1500)" << std::endl;
70 std::cerr <<
"\t-r <max-range> : Current max range from the camera for points to be included (default=50m)" << std::endl;
71 std::cerr <<
"\t-c : Flag to colorize the point clouds with the aux image" << std::endl;
92 int main(
int argc,
char** argv)
100 std::string ip_address =
"10.66.171.21";
102 double max_range = 50.0;
106 while(-1 != (c =
getopt(argc, argv,
"a:m:r:c")))
110 case 'a': ip_address = std::string(
optarg);
break;
111 case 'm': mtu =
static_cast<uint16_t
>(atoi(
optarg));
break;
112 case 'r': max_range = std::stod(
optarg);
break;
113 case 'c': color =
true;
break;
114 default:
usage(*argv);
break;
121 std::cerr <<
"Failed to create channel" << std::endl;;
128 auto config = channel->get_config();
129 config.frames_per_second = 10.0;
130 if (
const auto status = channel->set_config(config); status != lms::Status::OK)
132 std::cerr <<
"Cannot set config" << std::endl;
140 const auto info = channel->get_info();
141 const auto color_stream = (color && info.device.has_aux_camera()) ?
142 lms::DataSource::AUX_RECTIFIED_RAW :
143 lms::DataSource::LEFT_RECTIFIED_RAW;
148 if (
const auto status = channel->start_streams({color_stream,
149 lms::DataSource::LEFT_DISPARITY_RAW}); status != lms::Status::OK)
151 std::cerr <<
"Cannot start streams: " <<
lms::to_string(status) << std::endl;
157 if (
const auto image_frame = channel->get_next_image_frame(); image_frame)
159 if (color_stream == lms::DataSource::LEFT_RECTIFIED_RAW)
161 if (
const auto point_cloud = lms::create_color_pointcloud<uint8_t>(image_frame.value(),
164 lms::DataSource::LEFT_DISPARITY_RAW); point_cloud)
166 std::cout <<
"Saving pointcloud for frame id: " << image_frame->frame_id << std::endl;
172 using ColorT = std::array<uint8_t, 3>;
173 if (
const auto bgr =
create_bgr_image(image_frame.value(), color_stream); bgr)
175 const auto &disparity = image_frame->get_image(lms::DataSource::LEFT_DISPARITY_RAW);
176 if (
const auto point_cloud = lms::create_color_pointcloud<ColorT>(disparity,
179 image_frame->calibration); point_cloud)
181 std::cout <<
"Saving aux colorized pointcloud for frame id: " << image_frame->frame_id << std::endl;
189 channel->stop_streams({lms::DataSource::ALL});