Last active
December 16, 2018 05:55
-
-
Save UnaNancyOwen/4667cd86d7079eacd6da55baafaa3ad4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
DESCRIPTION: | |
query_motion_devices() is returns a list of all devices that have motion sensors. | |
HOWTOUSE: | |
std::vector<rs2::device> motion_devices; | |
query_motion_devices( motion_devices ); | |
if( motion_devices.empty ){ | |
throw std::runtime_error( "could not find devices that have motion sensors." ); | |
return -1; | |
} | |
rs2::config config; | |
const std::string serial_number = devices.front().get_info( rs2_camera_info::RS2_CAMERA_INFO_SERIAL_NUMBER ); | |
config.enable_device( serial_number ); | |
rs2::pipeline pipeline; | |
pipeline.start( config ); | |
*/ | |
#ifndef __QUERY_MOTION_DEVICES__ | |
#define __QUERY_MOTION_DEVICES__ | |
#include <librealsense2/rs.hpp> | |
#include <vector> | |
void query_motion_devices( std::vector<rs2::device>& motion_devices ) | |
{ | |
rs2::context context; | |
const rs2::device_list device_list = context.query_devices( RS2_PRODUCT_LINE_ANY_INTEL ); | |
for( const rs2::device& device : device_list ){ | |
const std::vector<rs2::sensor> sensors = device.query_sensors(); | |
for( const rs2::sensor& sensor : sensors ){ | |
const std::vector<rs2::stream_profile> profiles = sensor.get_stream_profiles(); | |
for( const rs2::stream_profile& profile : profiles ){ | |
if( profile.is<rs2::motion_stream_profile>() ){ | |
motion_devices.push_back( device ); | |
} | |
} | |
} | |
} | |
} | |
#endif // __QUERY_MOTION_DEVICES__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment