Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit ccdce2c

Browse files
author
Boris Bolshem
committed
Tag v0.2.3, corresponds to internal sha bd92ad
1 parent b248811 commit ccdce2c

File tree

90 files changed

+2777
-2468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2777
-2468
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ else()
1313
endif()
1414

1515
add_subdirectory(samples)
16+
17+
option(BUILD_TESTS "set run_tests to NO if build tests should be run, set to OFF to skip tests" OFF)
18+
if(BUILD_TESTS)
19+
add_subdirectory(tests)
20+
endif(BUILD_TESTS)

samples/playback_sample/playback_sample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int main(int argc, char* argv[])
2929
string playback_file_name(argv[1]);
3030

3131
//create a playback enabled context with a given output file
32-
rs::playback::context context(playback_file_name);
32+
rs::playback::context context(playback_file_name.c_str());
3333

3434
//create a playback enabled device
3535
rs::device* device = context.get_device(0);

samples/projection_sample/projection_sample.cpp

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ using namespace std;
1212
using namespace rs::core;
1313

1414
//helper functions
15-
void get_depth_coordinates_from_rectangle_on_depth_image(custom_image &depthImage, vector<point3dF32> &depthCoordinates);
16-
void get_color_coordinates_from_rectangle_on_color_image(custom_image &colorImage, vector<pointF32> &colorCoordinates);
15+
void get_depth_coordinates_from_rectangle_on_depth_image(std::shared_ptr<image_interface> depthImage, vector<point3dF32> &depthCoordinates);
16+
void get_color_coordinates_from_rectangle_on_color_image(std::shared_ptr<image_interface> colorImage, vector<pointF32> &colorCoordinates);
1717

1818
int main ()
1919
{
@@ -53,27 +53,27 @@ int main ()
5353
ColorInfo.format = rs::utils::convert_pixel_format(colorFormat);
5454
ColorInfo.pitch = color_pixel_size * colorWidth;
5555

56-
custom_image colorImage (&ColorInfo,
56+
std::shared_ptr<image_interface> colorImage(image_interface::create_instance_from_raw_data(&ColorInfo,
5757
device->get_frame_data(rs::stream::color),
5858
stream_type::color,
5959
image_interface::flag::any,
6060
device->get_frame_timestamp(rs::stream::color),
6161
device->get_frame_number(rs::stream::color),
62-
nullptr, nullptr);
62+
nullptr, nullptr));
6363

6464
image_info DepthInfo;
6565
DepthInfo.width = depthWidth;
6666
DepthInfo.height = depthHeight;
6767
DepthInfo.format = rs::utils::convert_pixel_format(depthFormat);
6868
DepthInfo.pitch = depth_pixel_size * depthWidth;
6969

70-
custom_image depthImage (&DepthInfo,
70+
std::shared_ptr<image_interface> depthImage (image_interface::create_instance_from_raw_data(&DepthInfo,
7171
device->get_frame_data(rs::stream::depth),
7272
stream_type::depth,
7373
image_interface::flag::any,
7474
device->get_frame_timestamp(rs::stream::depth),
7575
device->get_frame_number(rs::stream::depth),
76-
nullptr, nullptr);
76+
nullptr, nullptr));
7777

7878
/**
7979
* MapDepthToColor example.
@@ -99,7 +99,7 @@ int main ()
9999
get_color_coordinates_from_rectangle_on_color_image(colorImage, colorCoordinates);
100100

101101
vector<pointF32> mappedDepthCoordinates(colorCoordinates.size());
102-
if(projection_->map_color_to_depth(&depthImage, colorCoordinates.size(), colorCoordinates.data(), mappedDepthCoordinates.data()) < status_no_error)
102+
if(projection_->map_color_to_depth(depthImage.get(), colorCoordinates.size(), colorCoordinates.data(), mappedDepthCoordinates.data()) < status_no_error)
103103
{
104104
cerr<<"failed to map the color coordinates to depth" << endl;
105105
return -1;
@@ -168,9 +168,9 @@ int main ()
168168
* QueryUVMap Example.
169169
* Retrieve the UV map for the specific depth image. The UVMap is a pointF32 array of depth size width*height.
170170
*/
171-
auto depthImageInfo = depthImage.query_info();
171+
auto depthImageInfo = depthImage->query_info();
172172
vector<pointF32> uvmap(depthImageInfo.width * depthImageInfo.height);
173-
if(projection_->query_uvmap(&depthImage, uvmap.data()) < status_no_error)
173+
if(projection_->query_uvmap(depthImage.get(), uvmap.data()) < status_no_error)
174174
{
175175
cerr<<"failed to query UV map" << endl;
176176
return -1;
@@ -181,9 +181,9 @@ int main ()
181181
* Retrieve the inverse UV map for the specific depth image. The inverse UV map maps color coordinates
182182
* back to the depth coordinates. The inverse UVMap is a pointF32 array of color size width*height.
183183
*/
184-
auto colorImageInfo = colorImage.query_info();
184+
auto colorImageInfo = colorImage->query_info();
185185
vector<pointF32> invUVmap(colorImageInfo.width * colorImageInfo.height);
186-
if(projection_->query_invuvmap(&depthImage, invUVmap.data()) < status_no_error)
186+
if(projection_->query_invuvmap(depthImage.get(), invUVmap.data()) < status_no_error)
187187
{
188188
cerr<<"failed to query invariant UV map" << endl;
189189
return -1;
@@ -195,7 +195,7 @@ int main ()
195195
* size width*height. The world coordiantes units are in mm.
196196
*/
197197
vector<point3dF32> vertices(depthImageInfo.width * depthImageInfo.height);
198-
if(projection_->query_vertices(&depthImage, vertices.data()) < status_no_error)
198+
if(projection_->query_vertices(depthImage.get(), vertices.data()) < status_no_error)
199199
{
200200
cerr<<"failed to query vertices" << endl;
201201
return -1;
@@ -206,7 +206,7 @@ int main ()
206206
* Get the color pixel for every depth pixel using the UV map, and output a color image, aligned in space
207207
* and resolution to the depth image.
208208
*/
209-
std::unique_ptr<image_interface> colorImageMappedToDepth = std::unique_ptr<image_interface>(projection_->create_color_image_mapped_to_depth(&depthImage, &colorImage));
209+
std::unique_ptr<image_interface> colorImageMappedToDepth = std::unique_ptr<image_interface>(projection_->create_color_image_mapped_to_depth(depthImage.get(), colorImage.get()));
210210
//use the mapped image...
211211

212212
//The application must release the instance after use. (e.g. use smart ptr)
@@ -216,7 +216,7 @@ int main ()
216216
* Map every depth pixel to the color image resolution, and output a depth image, aligned in space
217217
* and resolution to the color image. The color image size may be different from original.
218218
*/
219-
std::unique_ptr<image_interface> depthImageMappedToColor = std::unique_ptr<image_interface>(projection_->create_depth_image_mapped_to_color(&depthImage, &colorImage));
219+
std::unique_ptr<image_interface> depthImageMappedToColor = std::unique_ptr<image_interface>(projection_->create_depth_image_mapped_to_color(depthImage.get(), colorImage.get()));
220220
//use the mapped image...
221221

222222
//The application must release the instance after use. (e.g. use smart ptr)
@@ -226,12 +226,18 @@ int main ()
226226
return 0;
227227
}
228228

229-
void get_depth_coordinates_from_rectangle_on_depth_image(custom_image &depthImage, vector<point3dF32> &depthCoordinates)
229+
void get_depth_coordinates_from_rectangle_on_depth_image(std::shared_ptr<image_interface> depthImage, vector<point3dF32> &depthCoordinates)
230230
{
231-
auto depthImageInfo = depthImage.query_info();
231+
if(!depthImage)
232+
{
233+
cerr<<"cant use null image" << endl;
234+
return;
235+
}
236+
237+
auto depthImageInfo = depthImage->query_info();
232238

233239
// get read access to the detph image data
234-
const void * depthImageData = depthImage.query_data();
240+
const void * depthImageData = depthImage->query_data();
235241
if(!depthImageData)
236242
{
237243
cerr<<"failed to get depth image data" << endl;
@@ -254,9 +260,15 @@ void get_depth_coordinates_from_rectangle_on_depth_image(custom_image &depthImag
254260

255261
}
256262

257-
void get_color_coordinates_from_rectangle_on_color_image(custom_image &colorImage, vector<pointF32> &colorCoordinates)
263+
void get_color_coordinates_from_rectangle_on_color_image(std::shared_ptr<image_interface> colorImage, vector<pointF32> &colorCoordinates)
258264
{
259-
auto colorImageInfo = colorImage.query_info();
265+
if(!colorImage)
266+
{
267+
cerr<<"cant use null image" << endl;
268+
return;
269+
}
270+
271+
auto colorImageInfo = colorImage->query_info();
260272

261273
// create a pointF32 array for the color coordinates you would like to project, for example the central rectangle
262274
const int startX = colorImageInfo.width / 4; const int endX = (colorImageInfo.width * 3) / 4;

samples/record_sample/record_sample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int main(int argc, char* argv[])
2222
const string output_file(argv[1]);
2323

2424
//create a record enabled context with a given output file
25-
rs::record::context context(output_file);
25+
rs::record::context context(output_file.c_str());
2626

2727
if(context.get_device_count() == 0)
2828
{

samples/sync_utility_sample/sync_utility_sample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void frame_handler(rs::frame new_frame)
7676
std::cout << "Received "<<frame_counter << " frame of type " << (int)info.format << " with timestamp " << new_frame.get_frame_number() << endl;
7777

7878
auto st_type = (info.format == pixel_format::rgb8 ? stream_type::color : stream_type::depth );
79-
auto image = new custom_image(&info,
79+
auto image = image_interface::create_instance_from_raw_data(&info,
8080
new_frame.get_data(),
8181
st_type,
8282
image_interface::flag::any,

samples/video_module_sample/video_module_async_sample.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using namespace rs::mock;
2020
int main (int argc, char* argv[])
2121
{
2222
// initialize the device from live device or playback file, based on command line parameters.
23-
std::unique_ptr<context> ctx;
23+
std::unique_ptr<context_interface> ctx;
2424

2525
if (argc > 1)
2626
{
@@ -46,8 +46,7 @@ int main (int argc, char* argv[])
4646
rs::device * device = ctx->get_device(0); //device memory managed by the context
4747

4848
// initialize the module
49-
bool is_complete_sample_set_required = false;
50-
std::unique_ptr<video_module_interface> module(new video_module_mock(is_complete_sample_set_required));
49+
std::unique_ptr<video_module_interface> module(new video_module_mock());
5150

5251
// get the first supported module configuration
5352
video_module_interface::supported_module_config supported_config = {};
@@ -57,10 +56,9 @@ int main (int argc, char* argv[])
5756
return -1;
5857
}
5958

60-
if(supported_config.complete_sample_set_required)
59+
if(supported_config.config_flags & video_module_interface::supported_module_config::flags::time_synced_input)
6160
{
62-
cerr<<"error : (complete_sample_set_required == true) is not inmplemented" << endl;
63-
return -1;
61+
cout<<"the sample is not implementing complete sample set syncroniztion"<< endl;
6462
}
6563

6664
auto device_name = device->get_name();
@@ -139,8 +137,8 @@ int main (int argc, char* argv[])
139137
stream_callback_per_stream[stream] = [stream, &module](rs::frame frame)
140138
{
141139
correlated_sample_set sample_set;
142-
smart_ptr<metadata_interface> metadata(new rs::core::metadata());
143-
smart_ptr<image_interface> image(new lrs_image(frame, image_interface::flag::any, metadata));
140+
smart_ptr<metadata_interface> metadata(metadata_interface::create_instance());
141+
smart_ptr<image_interface> image(image_interface::create_instance_from_librealsense_frame(frame, image_interface::flag::any, metadata));
144142
sample_set[stream] = image;
145143

146144
//send asynced sample set to the module
@@ -170,9 +168,12 @@ int main (int argc, char* argv[])
170168
if (!supported_motion_config.is_enabled)
171169
continue;
172170

173-
actual_config[motion].flags = sample_flags::none;
174-
actual_config[motion].frame_rate = 0; // not implemented by librealsense
175-
actual_config[motion].is_enabled = true;
171+
video_module_interface::actual_motion_sensor_config &actual_motion_config = actual_config[motion];
172+
actual_motion_config.flags = sample_flags::none;
173+
actual_motion_config.frame_rate = 0; // not implemented by librealsense
174+
actual_motion_config.intrinsics = convert_motion_intrinsics(device->get_motion_intrinsics());
175+
actual_motion_config.extrinsics = convert_extrinsics(device->get_motion_extrinsics_from(rs::stream::depth));
176+
actual_motion_config.is_enabled = true;
176177
actual_motions.push_back(motion);
177178
}
178179

@@ -219,7 +220,7 @@ int main (int argc, char* argv[])
219220
rs_intrinsics depth_intrin = device->get_stream_intrinsics(rs::stream::depth);
220221
rs_extrinsics extrinsics = device->get_extrinsics(rs::stream::depth, rs::stream::color);
221222
projection.reset(rs::core::projection_interface::create_instance(&color_intrin, &depth_intrin, &extrinsics));
222-
module->set_projection(projection.get());
223+
actual_config.projection = projection.get();
223224
}
224225

225226
// setting the enabled module configuration

samples/video_module_sample/video_module_mock.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ namespace rs
1414
namespace mock
1515
{
1616

17-
video_module_mock::video_module_mock(bool is_complete_sample_set_required):
18-
m_processing_handler(nullptr),
19-
m_projection(nullptr),
20-
m_is_complete_sample_set_required(is_complete_sample_set_required) {}
17+
video_module_mock::video_module_mock():
18+
m_processing_handler(nullptr) {}
2119

2220
int32_t video_module_mock::query_module_uid()
2321
{
@@ -34,7 +32,9 @@ namespace rs
3432
std::memcpy(supported_config.device_name, device_name, std::strlen(device_name));
3533

3634
supported_config.concurrent_samples_count = 1;
37-
supported_config.complete_sample_set_required = m_is_complete_sample_set_required;
35+
supported_config.config_flags = static_cast<supported_module_config::flags>(
36+
supported_module_config::flags::sync_processing_supported |
37+
supported_module_config::flags::async_processing_supported);
3838

3939
video_module_interface::supported_image_stream_config & color_desc = supported_config[stream_type::color];
4040
color_desc.min_size.width = 640;
@@ -183,11 +183,6 @@ namespace rs
183183
return status_no_error;
184184
}
185185

186-
void video_module_mock::set_projection(rs::core::projection_interface * projection)
187-
{
188-
m_projection = projection;
189-
}
190-
191186
video_module_control_interface * video_module_mock::query_video_module_control()
192187
{
193188
return nullptr;

samples/video_module_sample/video_module_mock.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ namespace rs
1717
private:
1818
rs::core::video_module_interface::actual_module_config m_current_module_config;
1919
rs::core::video_module_interface::processing_event_handler * m_processing_handler;
20-
rs::core::projection_interface * m_projection;
21-
bool m_is_complete_sample_set_required;
2220
public:
23-
video_module_mock(bool is_complete_sample_set_required);
21+
video_module_mock();
2422
int32_t query_module_uid();
2523
rs::core::status query_supported_module_config(int32_t idx,
2624
rs::core::video_module_interface::supported_module_config &supported_config);
@@ -30,7 +28,6 @@ namespace rs
3028
rs::core::status process_sample_set_async(rs::core::correlated_sample_set *sample_set);
3129
rs::core::status register_event_hander(rs::core::video_module_interface::processing_event_handler *handler);
3230
rs::core::status unregister_event_hander(rs::core::video_module_interface::processing_event_handler *handler);
33-
void set_projection(rs::core::projection_interface * projection);
3431
rs::core::video_module_control_interface *query_video_module_control();
3532
};
3633
}

samples/video_module_sample/video_module_sync_sample.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace rs::mock;
1818
int main (int argc, char* argv[])
1919
{
2020
// initialize the device from live device or playback file, based on command line parameters.
21-
std::unique_ptr<context> ctx;
21+
std::unique_ptr<context_interface> ctx;
2222
int frames_count = 0;
2323

2424
if (argc > 1)
@@ -54,8 +54,7 @@ int main (int argc, char* argv[])
5454
rs::device * device = ctx->get_device(0); //device memory managed by the context
5555

5656
// initialize the module
57-
bool is_complete_sample_set_required = true;
58-
std::unique_ptr<video_module_interface> module(new video_module_mock(is_complete_sample_set_required));
57+
std::unique_ptr<video_module_interface> module(new video_module_mock());
5958

6059
// get the first supported module configuration
6160
video_module_interface::supported_module_config supported_config = {};
@@ -142,7 +141,7 @@ int main (int argc, char* argv[])
142141
rs_intrinsics depth_intrin = device->get_stream_intrinsics(rs::stream::depth);
143142
rs_extrinsics extrinsics = device->get_extrinsics(rs::stream::depth, rs::stream::color);
144143
projection.reset(rs::core::projection_interface::create_instance(&color_intrin, &depth_intrin, &extrinsics));
145-
module->set_projection(projection.get());
144+
actual_config.projection = projection.get();
146145
}
147146

148147
// setting the enabled module configuration
@@ -168,8 +167,8 @@ int main (int argc, char* argv[])
168167
rs::utils::convert_pixel_format(device->get_stream_format(librealsense_stream)),
169168
device->get_stream_width(librealsense_stream)
170169
};
171-
smart_ptr<metadata_interface> metadata(new rs::core::metadata());
172-
smart_ptr<image_interface> image(new custom_image(&info,
170+
smart_ptr<metadata_interface> metadata(metadata_interface::create_instance());
171+
smart_ptr<image_interface> image(image_interface::create_instance_from_raw_data(&info,
173172
device->get_frame_data(librealsense_stream),
174173
stream,
175174
image_interface::flag::any,

sdk/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
cmake_minimum_required(VERSION 2.8.9)
22
project(realsense_sdk)
3-
include(ExternalProject)
43

54
if(CMAKE_USE_INTEL_COMPILER EQUAL 1)
65
MESSAGE("--------- Using Intel compiler------------")
@@ -41,8 +40,7 @@ add_definitions(-Wno-unused-variable)
4140
add_definitions(-Wno-reorder)
4241
add_definitions(-Werror)
4342

44-
45-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
43+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
4644

4745

4846
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@@ -95,4 +93,3 @@ add_subdirectory(src/utilities)
9593
add_subdirectory(src/core)
9694
add_subdirectory(src/tools)
9795
add_subdirectory(src/cameras)
98-

0 commit comments

Comments
 (0)