20 std::vector<std::string>
logs;
22 void log(
const char* msg)
24 std::lock_guard<std::mutex> lock(
mtx);
35 std::cout <<
"There are "<< ctx.
get_device_count() <<
" connected RealSense devices.\n";
41 printf(
"\nUsing device 0, an %s\n", dev->
get_name());
42 printf(
" Serial number: %s\n", dev->
get_serial());
47 printf(
"This device does not support motion tracking!");
53 auto now = std::chrono::system_clock::now().time_since_epoch();
54 auto sys_time = std::chrono::duration_cast<std::chrono::milliseconds>(now).
count();
56 ss <<
"Motion,\t host time " << sys_time
57 <<
"\ttimestamp: " << std::setprecision(8) << entry.timestamp_data.timestamp
58 <<
"\tsource: " << (
rs::event)entry.timestamp_data.source_id
59 <<
"\tframe_num: " << entry.timestamp_data.frame_number
60 <<
"\tx: " << std::setprecision(5) << entry.axes[0] <<
"\ty: " << entry.axes[1] <<
"\tz: " << entry.axes[2];
61 log(ss.str().c_str());
67 auto now = std::chrono::system_clock::now().time_since_epoch();
68 auto sys_time = std::chrono::duration_cast<std::chrono::milliseconds>(now).
count();
70 ss <<
"TimeEvt, host time " << sys_time
71 <<
"\ttimestamp: " << std::setprecision(8) << entry.timestamp
72 <<
"\tsource: " << (
rs::event)entry.source_id
73 <<
"\tframe_num: " << entry.frame_number;
74 log(ss.str().c_str());
76 for (
int ii = 0; ii < 100; ii++)
78 std::cout <<
"\n\nIteration " << ii+1 <<
" started\n\n" << std::endl;
98 auto now = std::chrono::system_clock::now().time_since_epoch();
99 auto sys_time = std::chrono::duration_cast<std::chrono::milliseconds>(now).
count();
100 std::stringstream ss;
101 ss <<
"Frame data, time " << sys_time
102 <<
"\ttimestamp: " << std::setprecision(8) << frame.get_timestamp()
103 <<
"\tsource: " << std::setw(13) << frame.get_stream_type()
104 <<
"\tframe_num: " << frame.get_frame_number();
105 log(ss.str().c_str());
117 printf(
"\nThe application is collecting data for next 10sec...\n");
118 std::this_thread::sleep_for(std::chrono::milliseconds(10000));
123 for (
auto entry :
logs) std::cout << entry << std::endl;
135 printf(
" %s\n", e.what());
140 printf(
"Unhandled excepton occured'n");
void log_to_console(log_severity min_severity)
Provides convenience methods relating to devices.
void timestamp_callback(rs_device *, rs_timestamp_data, void *)
void enable_stream(stream stream, int width, int height, format format, int framerate, output_buffer_format output_buffer_type=output_buffer_format::continous)
Enables specific stream and requests specific properties.
const std::string & get_failed_args() const
std::vector< std::string > logs
const char * get_firmware_version() const
Retrieves version of firmware currently installed on device.
void motion_callback(rs_device *, rs_motion_data, void *)
Motion data from gyroscope and accelerometer from the microcontroller.
Exposes librealsense functionality for C++ compilers.
event
Source device that triggered specific timestamp event from the motion module.
void stop(rs::source source=rs::source::video)
Ends streaming on all streams for this device.
stream
Streams are different types of data provided by RealSense devices.
void frame_callback(rs_device *dev, rs_frame_ref *frame, void *user)
GLuint GLuint GLsizei count
void disable_motion_tracking(void)
Disables events polling.
const char * get_name() const
Retrieves human-readable device model string.
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
void start(rs::source source=rs::source::video)
Begins streaming on all enabled streams for this device.
void enable_motion_tracking(std::function< void(motion_data)> motion_handler, std::function< void(timestamp_data)> timestamp_handler)
Sets callback for motion module event.
const char * get_serial() const
Retrieves unique serial number of device.
void set_frame_callback(rs::stream stream, std::function< void(frame)> frame_handler)
Sets callback for frame arrival event.
bool supports(capabilities capability) const
Determines device capabilities.
device * get_device(int index)
void set_option(option option, double value)
Sets current value of single option.
const std::string & get_failed_function() const
Timestamp data from the motion microcontroller.
int get_device_count() const
void log(const char *msg)