Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dorodnic authored Nov 28, 2018
1 parent 87fe921 commit a2406a5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/callback/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Overview

This sample demonstrates how to configure the camera for streaming frames using the pipeline's callback API.
This API is recommended when streaming high frequency data such as IMU (Inertial measurement unit) since the callback is invoked immediately once the a frame is ready.
This sample prints a frame counter for each stream, the code demonstrates how it can be done with correctly by synchronizing the callbacks.
This API is recommended when streaming high frequency data such as IMU ([Inertial measurement unit](https://en.wikipedia.org/wiki/Inertial_measurement_unit)) since the callback is invoked immediately once the a frame is ready.
This sample prints a frame counter for each stream, the code demonstrates how it can be done correctly by synchronizing the callbacks.

## Expected Output
![rs-callback](https://user-images.githubusercontent.com/18511514/48921401-37a0c680-eea8-11e8-9ab4-18e566d69a8a.PNG)
Expand All @@ -29,7 +29,7 @@ The mutex object is a synchronization primitive that will be used to protect our
std::mutex mutex;
```

Define the frame callback which will be invoked by the pipeline on the sensors thread once a frame (or frames) is ready.
Define the frame callback which will be invoked by the pipeline on the sensors thread once a frame (or synchronised frameset) is ready.
```cpp
// Define frame callback
// The callback is executed on a sensor thread and can be called simultaneously from multiple sensors.
Expand Down Expand Up @@ -62,15 +62,16 @@ rs2::pipeline pipe;
rs2::pipeline_profile profiles = pipe.start(callback);
```

Collect the stream names from the returned pipeline_profile.
Collect the stream names from the returned `pipeline_profile` object:
```cpp
// Collect the enabled streams names
for (auto p : profiles.get_streams())
stream_names[p.unique_id()] = p.stream_name();
```

Finally, print the frame counters once every second.
In order to protect our counters from being accessed simultaneously, protect the counters using the mutex.
After calling `start`, the main thread will continue to execute work, so even when no other action is required, we need to keep the application alive.
In order to protect our counters from being accessed simultaneously, access the counters using the mutex.
```cpp
std::cout << "RealSense callback sample" << std::endl << std::endl;

Expand Down

0 comments on commit a2406a5

Please sign in to comment.