Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

Commit

Permalink
Tag v0.2.3, corresponds to internal sha bd92ad
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Bolshem committed Aug 11, 2016
1 parent b248811 commit ccdce2c
Show file tree
Hide file tree
Showing 90 changed files with 2,777 additions and 2,468 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ else()
endif()

add_subdirectory(samples)

option(BUILD_TESTS "set run_tests to NO if build tests should be run, set to OFF to skip tests" OFF)
if(BUILD_TESTS)
add_subdirectory(tests)
endif(BUILD_TESTS)
2 changes: 1 addition & 1 deletion samples/playback_sample/playback_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main(int argc, char* argv[])
string playback_file_name(argv[1]);

//create a playback enabled context with a given output file
rs::playback::context context(playback_file_name);
rs::playback::context context(playback_file_name.c_str());

//create a playback enabled device
rs::device* device = context.get_device(0);
Expand Down
50 changes: 31 additions & 19 deletions samples/projection_sample/projection_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ using namespace std;
using namespace rs::core;

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

int main ()
{
Expand Down Expand Up @@ -53,27 +53,27 @@ int main ()
ColorInfo.format = rs::utils::convert_pixel_format(colorFormat);
ColorInfo.pitch = color_pixel_size * colorWidth;

custom_image colorImage (&ColorInfo,
std::shared_ptr<image_interface> colorImage(image_interface::create_instance_from_raw_data(&ColorInfo,
device->get_frame_data(rs::stream::color),
stream_type::color,
image_interface::flag::any,
device->get_frame_timestamp(rs::stream::color),
device->get_frame_number(rs::stream::color),
nullptr, nullptr);
nullptr, nullptr));

image_info DepthInfo;
DepthInfo.width = depthWidth;
DepthInfo.height = depthHeight;
DepthInfo.format = rs::utils::convert_pixel_format(depthFormat);
DepthInfo.pitch = depth_pixel_size * depthWidth;

custom_image depthImage (&DepthInfo,
std::shared_ptr<image_interface> depthImage (image_interface::create_instance_from_raw_data(&DepthInfo,
device->get_frame_data(rs::stream::depth),
stream_type::depth,
image_interface::flag::any,
device->get_frame_timestamp(rs::stream::depth),
device->get_frame_number(rs::stream::depth),
nullptr, nullptr);
nullptr, nullptr));

/**
* MapDepthToColor example.
Expand All @@ -99,7 +99,7 @@ int main ()
get_color_coordinates_from_rectangle_on_color_image(colorImage, colorCoordinates);

vector<pointF32> mappedDepthCoordinates(colorCoordinates.size());
if(projection_->map_color_to_depth(&depthImage, colorCoordinates.size(), colorCoordinates.data(), mappedDepthCoordinates.data()) < status_no_error)
if(projection_->map_color_to_depth(depthImage.get(), colorCoordinates.size(), colorCoordinates.data(), mappedDepthCoordinates.data()) < status_no_error)
{
cerr<<"failed to map the color coordinates to depth" << endl;
return -1;
Expand Down Expand Up @@ -168,9 +168,9 @@ int main ()
* QueryUVMap Example.
* Retrieve the UV map for the specific depth image. The UVMap is a pointF32 array of depth size width*height.
*/
auto depthImageInfo = depthImage.query_info();
auto depthImageInfo = depthImage->query_info();
vector<pointF32> uvmap(depthImageInfo.width * depthImageInfo.height);
if(projection_->query_uvmap(&depthImage, uvmap.data()) < status_no_error)
if(projection_->query_uvmap(depthImage.get(), uvmap.data()) < status_no_error)
{
cerr<<"failed to query UV map" << endl;
return -1;
Expand All @@ -181,9 +181,9 @@ int main ()
* Retrieve the inverse UV map for the specific depth image. The inverse UV map maps color coordinates
* back to the depth coordinates. The inverse UVMap is a pointF32 array of color size width*height.
*/
auto colorImageInfo = colorImage.query_info();
auto colorImageInfo = colorImage->query_info();
vector<pointF32> invUVmap(colorImageInfo.width * colorImageInfo.height);
if(projection_->query_invuvmap(&depthImage, invUVmap.data()) < status_no_error)
if(projection_->query_invuvmap(depthImage.get(), invUVmap.data()) < status_no_error)
{
cerr<<"failed to query invariant UV map" << endl;
return -1;
Expand All @@ -195,7 +195,7 @@ int main ()
* size width*height. The world coordiantes units are in mm.
*/
vector<point3dF32> vertices(depthImageInfo.width * depthImageInfo.height);
if(projection_->query_vertices(&depthImage, vertices.data()) < status_no_error)
if(projection_->query_vertices(depthImage.get(), vertices.data()) < status_no_error)
{
cerr<<"failed to query vertices" << endl;
return -1;
Expand All @@ -206,7 +206,7 @@ int main ()
* Get the color pixel for every depth pixel using the UV map, and output a color image, aligned in space
* and resolution to the depth image.
*/
std::unique_ptr<image_interface> colorImageMappedToDepth = std::unique_ptr<image_interface>(projection_->create_color_image_mapped_to_depth(&depthImage, &colorImage));
std::unique_ptr<image_interface> colorImageMappedToDepth = std::unique_ptr<image_interface>(projection_->create_color_image_mapped_to_depth(depthImage.get(), colorImage.get()));
//use the mapped image...

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

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

void get_depth_coordinates_from_rectangle_on_depth_image(custom_image &depthImage, vector<point3dF32> &depthCoordinates)
void get_depth_coordinates_from_rectangle_on_depth_image(std::shared_ptr<image_interface> depthImage, vector<point3dF32> &depthCoordinates)
{
auto depthImageInfo = depthImage.query_info();
if(!depthImage)
{
cerr<<"cant use null image" << endl;
return;
}

auto depthImageInfo = depthImage->query_info();

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

}

void get_color_coordinates_from_rectangle_on_color_image(custom_image &colorImage, vector<pointF32> &colorCoordinates)
void get_color_coordinates_from_rectangle_on_color_image(std::shared_ptr<image_interface> colorImage, vector<pointF32> &colorCoordinates)
{
auto colorImageInfo = colorImage.query_info();
if(!colorImage)
{
cerr<<"cant use null image" << endl;
return;
}

auto colorImageInfo = colorImage->query_info();

// create a pointF32 array for the color coordinates you would like to project, for example the central rectangle
const int startX = colorImageInfo.width / 4; const int endX = (colorImageInfo.width * 3) / 4;
Expand Down
2 changes: 1 addition & 1 deletion samples/record_sample/record_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main(int argc, char* argv[])
const string output_file(argv[1]);

//create a record enabled context with a given output file
rs::record::context context(output_file);
rs::record::context context(output_file.c_str());

if(context.get_device_count() == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion samples/sync_utility_sample/sync_utility_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void frame_handler(rs::frame new_frame)
std::cout << "Received "<<frame_counter << " frame of type " << (int)info.format << " with timestamp " << new_frame.get_frame_number() << endl;

auto st_type = (info.format == pixel_format::rgb8 ? stream_type::color : stream_type::depth );
auto image = new custom_image(&info,
auto image = image_interface::create_instance_from_raw_data(&info,
new_frame.get_data(),
st_type,
image_interface::flag::any,
Expand Down
25 changes: 13 additions & 12 deletions samples/video_module_sample/video_module_async_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using namespace rs::mock;
int main (int argc, char* argv[])
{
// initialize the device from live device or playback file, based on command line parameters.
std::unique_ptr<context> ctx;
std::unique_ptr<context_interface> ctx;

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

// initialize the module
bool is_complete_sample_set_required = false;
std::unique_ptr<video_module_interface> module(new video_module_mock(is_complete_sample_set_required));
std::unique_ptr<video_module_interface> module(new video_module_mock());

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

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

auto device_name = device->get_name();
Expand Down Expand Up @@ -139,8 +137,8 @@ int main (int argc, char* argv[])
stream_callback_per_stream[stream] = [stream, &module](rs::frame frame)
{
correlated_sample_set sample_set;
smart_ptr<metadata_interface> metadata(new rs::core::metadata());
smart_ptr<image_interface> image(new lrs_image(frame, image_interface::flag::any, metadata));
smart_ptr<metadata_interface> metadata(metadata_interface::create_instance());
smart_ptr<image_interface> image(image_interface::create_instance_from_librealsense_frame(frame, image_interface::flag::any, metadata));
sample_set[stream] = image;

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

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

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

// setting the enabled module configuration
Expand Down
15 changes: 5 additions & 10 deletions samples/video_module_sample/video_module_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ namespace rs
namespace mock
{

video_module_mock::video_module_mock(bool is_complete_sample_set_required):
m_processing_handler(nullptr),
m_projection(nullptr),
m_is_complete_sample_set_required(is_complete_sample_set_required) {}
video_module_mock::video_module_mock():
m_processing_handler(nullptr) {}

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

supported_config.concurrent_samples_count = 1;
supported_config.complete_sample_set_required = m_is_complete_sample_set_required;
supported_config.config_flags = static_cast<supported_module_config::flags>(
supported_module_config::flags::sync_processing_supported |
supported_module_config::flags::async_processing_supported);

video_module_interface::supported_image_stream_config & color_desc = supported_config[stream_type::color];
color_desc.min_size.width = 640;
Expand Down Expand Up @@ -183,11 +183,6 @@ namespace rs
return status_no_error;
}

void video_module_mock::set_projection(rs::core::projection_interface * projection)
{
m_projection = projection;
}

video_module_control_interface * video_module_mock::query_video_module_control()
{
return nullptr;
Expand Down
5 changes: 1 addition & 4 deletions samples/video_module_sample/video_module_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ namespace rs
private:
rs::core::video_module_interface::actual_module_config m_current_module_config;
rs::core::video_module_interface::processing_event_handler * m_processing_handler;
rs::core::projection_interface * m_projection;
bool m_is_complete_sample_set_required;
public:
video_module_mock(bool is_complete_sample_set_required);
video_module_mock();
int32_t query_module_uid();
rs::core::status query_supported_module_config(int32_t idx,
rs::core::video_module_interface::supported_module_config &supported_config);
Expand All @@ -30,7 +28,6 @@ namespace rs
rs::core::status process_sample_set_async(rs::core::correlated_sample_set *sample_set);
rs::core::status register_event_hander(rs::core::video_module_interface::processing_event_handler *handler);
rs::core::status unregister_event_hander(rs::core::video_module_interface::processing_event_handler *handler);
void set_projection(rs::core::projection_interface * projection);
rs::core::video_module_control_interface *query_video_module_control();
};
}
Expand Down
11 changes: 5 additions & 6 deletions samples/video_module_sample/video_module_sync_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace rs::mock;
int main (int argc, char* argv[])
{
// initialize the device from live device or playback file, based on command line parameters.
std::unique_ptr<context> ctx;
std::unique_ptr<context_interface> ctx;
int frames_count = 0;

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

// initialize the module
bool is_complete_sample_set_required = true;
std::unique_ptr<video_module_interface> module(new video_module_mock(is_complete_sample_set_required));
std::unique_ptr<video_module_interface> module(new video_module_mock());

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

// setting the enabled module configuration
Expand All @@ -168,8 +167,8 @@ int main (int argc, char* argv[])
rs::utils::convert_pixel_format(device->get_stream_format(librealsense_stream)),
device->get_stream_width(librealsense_stream)
};
smart_ptr<metadata_interface> metadata(new rs::core::metadata());
smart_ptr<image_interface> image(new custom_image(&info,
smart_ptr<metadata_interface> metadata(metadata_interface::create_instance());
smart_ptr<image_interface> image(image_interface::create_instance_from_raw_data(&info,
device->get_frame_data(librealsense_stream),
stream,
image_interface::flag::any,
Expand Down
5 changes: 1 addition & 4 deletions sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cmake_minimum_required(VERSION 2.8.9)
project(realsense_sdk)
include(ExternalProject)

if(CMAKE_USE_INTEL_COMPILER EQUAL 1)
MESSAGE("--------- Using Intel compiler------------")
Expand Down Expand Up @@ -41,8 +40,7 @@ add_definitions(-Wno-unused-variable)
add_definitions(-Wno-reorder)
add_definitions(-Werror)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")


set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down Expand Up @@ -95,4 +93,3 @@ add_subdirectory(src/utilities)
add_subdirectory(src/core)
add_subdirectory(src/tools)
add_subdirectory(src/cameras)

2 changes: 1 addition & 1 deletion sdk/CMakeVersion
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(SDK_VERSION_MAJOR 0 )
set(SDK_VERSION_MINOR 2 )
set(SDK_VERSION_COMMIT_NUMBER 2 )
set(SDK_VERSION_COMMIT_NUMBER 3 )
set(SDK_VERSION_COMMIT_ID 0 )
Loading

0 comments on commit ccdce2c

Please sign in to comment.