Skip to content

Commit

Permalink
Merge pull request #4 from zshahaf/master
Browse files Browse the repository at this point in the history
Recorder from zshahaf
  • Loading branch information
dorodnic authored and GitHub Enterprise committed Jul 16, 2017
2 parents a2b325d + 9af160c commit 085b3de
Show file tree
Hide file tree
Showing 346 changed files with 5,819 additions and 17,553 deletions.
9 changes: 8 additions & 1 deletion CMake/realsense.def
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,11 @@ EXPORTS
rs2_get_census
rs2_advanced_mode_preset_to_string
rs2_is_enabled
rs2_toggle_advanced_mode
rs2_toggle_advanced_mode

rs2_create_device_serializer
rs2_delete_device_serializer
rs2_create_record_device
rs2_create_playback_device
rs2_record_device_pause
rs2_record_device_resume
47 changes: 44 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,20 @@ set(REALSENSE_CPP
src/win/win-usb.cpp
src/win/win-hid.cpp
src/win/win-backend.cpp

rs400/rs400_advanced_mode/src/rs2_advanced_mode.cpp
rs400/rs400_advanced_mode/src/presets.cpp
rs400/rs400_advanced_mode/src/advanced_mode.cpp

third-party/easyloggingpp/src/easylogging++.cc

third-party/sqlite/sqlite3.c

src/mock/sql.cpp
src/mock/recorder.cpp

rs400/rs400_advanced_mode/src/presets.cpp
rs400/rs400_advanced_mode/src/advanced_mode.cpp
src/record_device.cpp
src/playback_device.cpp
src/playback_sensor.cpp
)

set(REALSENSE_HPP
Expand Down Expand Up @@ -192,11 +196,48 @@ set(REALSENSE_HPP
src/win/win-hid.h
src/win/win-backend.h
src/api.h
src/core/advanced_mode.h
src/core/serialization.h

src/record_device.h
src/playback_device.h
src/playback_sensor.h
src/serializers/ros_device_serializer.h
src/serializers/ros_reader.h
src/serializers/ros_device_serializer_writer.h

third-party/easyloggingpp/src/easylogging++.h
third-party/sqlite/sqlite3.h
src/mock/sql.h
src/mock/recorder.h

src/ros/data_objects/pose.h
src/ros/data_objects/vendor_data.h
src/ros/data_objects/image.h
src/ros/data_objects/motion_stream_info.h
src/ros/data_objects/property.h
src/ros/data_objects/log.h
src/ros/data_objects/motion_sample.h
src/ros/data_objects/time_sample.h
src/ros/data_objects/compressed_image.h
src/ros/data_objects/occupancy_map.h
src/ros/data_objects/stream_data.h
src/ros/data_objects/image_stream_info.h
src/ros/stream_playback.h
src/ros/file_types.h
src/ros/status.h
src/ros/stream_playback.h
src/ros/ros_writer.h
src/ros/stream_playback.cpp
src/ros/topic.h
)

# Add additional include directories to allow file to include rosbag headers
include(${CMAKE_CURRENT_LIST_DIR}/third-party/realsense-file/3rd_party/config.cmake)
include_directories(
${ROSBAG_HEADER_DIRS}
${BOOST_INCLUDE_PATH}
${LZ4_INCLUDE_PATH}
)

if(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/pybackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace py = pybind11;
using namespace pybind11::literals;

using namespace rsimpl2;
using namespace librealsense;
using namespace pybackend2;

// Prevents expensive copies of pixel buffers into python
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/pybackend_extras.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "pybackend_extras.h"
#include <cinttypes>

using namespace rsimpl2;
using namespace librealsense;

#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "../examples/third_party/stb_image_write.h"
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/pybackend_extras.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../src/types.h"

using namespace rsimpl2;
using namespace librealsense;

namespace pybackend2 {
enum class command
Expand Down
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ add_subdirectory(capture)
#add_subdirectory(headless)
add_subdirectory(multicam)
add_subdirectory(pointcloud)
add_subdirectory(recording)
1 change: 0 additions & 1 deletion examples/capture/rs-capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ using namespace std;
int main(int argc, char * argv[])
{
context ctx;

util::device_hub hub(ctx);

auto finished = false;
Expand Down
36 changes: 36 additions & 0 deletions examples/recording/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# ubuntu 16.04 LTS cmake version 3.5.1
cmake_minimum_required(VERSION 2.8.3)

project(RealsenseExamplesRecording)

# Save the command line compile commands in the build output
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

# recording-sample
add_executable(rs-recording rs-recording.cpp)
target_link_libraries(rs-recording ${DEPENDENCIES})
include_directories(rs-recording ../../third-party/tclap/include)
set_target_properties (rs-recording PROPERTIES
FOLDER Examples
)

install(
TARGETS

rs-recording

RUNTIME DESTINATION
${CMAKE_INSTALL_PREFIX}/bin
)
1 change: 1 addition & 0 deletions examples/recording/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Readme (TODO)
103 changes: 103 additions & 0 deletions examples/recording/rs-recording.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#include <librealsense/rs2.hpp>
#include <iostream>
#include <iomanip>
#include <core/streaming.h> //TODO: remove
#include <sensor.h>
#include <record_device.h>

#include "tclap/CmdLine.h"

using namespace std;
using namespace TCLAP;
using namespace rs2;

int main(int argc, const char** argv) try
{
CmdLine cmd("librealsense cpp-record example", ' ', RS2_API_VERSION_STR);
ValueArg<std::string> file_path("f", "file_path", "File path for recording output", false, "record_example.bag", "string");
cmd.add( file_path );
cmd.parse(argc, argv);

std::cout << "Recording to file: " << file_path.getValue() << std::endl;

context ctx;
auto devices = ctx.query_devices();
if (devices.size() == 0)
{
std::cerr << "No device connected" << std::endl;
return EXIT_FAILURE;
}
//Create a recorder from the device
//recorder device(file_path.getValue(), devices[0]);
playback device(file_path.getValue());
//From this point on we use the record_device and not the (live) device

std::cout << "Device: " << device.get_info(RS2_CAMERA_INFO_NAME) << std::endl;

//Declare profiles we want to play
const std::vector<rs2::stream_profile> profiles_to_play_if_available{
rs2::stream_profile{ RS2_STREAM_DEPTH, 640, 480, 30, RS2_FORMAT_Z16 },
rs2::stream_profile{ RS2_STREAM_INFRARED, 640, 480, 30, RS2_FORMAT_Y8 },
rs2::stream_profile{ RS2_STREAM_FISHEYE, 640, 480, 30, RS2_FORMAT_RAW8 },
rs2::stream_profile{ RS2_STREAM_COLOR, 640, 480, 30, RS2_FORMAT_RGBA8 }
};

std::vector<sensor> m_playing_sensors; //will hold the sensors that are playing
int sensor_id = 0;
//Go over the sensors and open start streaming
for (auto&& sensor : device.query_sensors())
{
sensor_id++;
if (sensor.supports(RS2_CAMERA_INFO_NAME))
{
std::cout << "Sensor #" << sensor_id << ": " << sensor.get_info(RS2_CAMERA_INFO_NAME) << std::endl;
}

std::vector<rs2::stream_profile> profiles_to_play_for_this_sensor;
for (auto profile : sensor.get_stream_modes())
{
if (std::find(std::begin(profiles_to_play_if_available),
std::end(profiles_to_play_if_available), profile) != std::end(profiles_to_play_if_available))
{
profiles_to_play_for_this_sensor.push_back(profile);
}

}
if (profiles_to_play_for_this_sensor.empty())
{
//This sensor does not support any of the requested profiles
continue;
}
sensor.open(profiles_to_play_for_this_sensor);
sensor.start([](rs2::frame f) {
std::cout << rs2_stream_to_string(f.get_stream_type()) << " frame #" << f.get_frame_number() << std::endl;
});
m_playing_sensors.push_back(sensor);
try
{
roi_sensor x(sensor);
}
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
}
}
getchar();
//std::this_thread::sleep_for(std::chrono::seconds(5));

for(auto sensor : m_playing_sensors)
{
sensor.stop();
sensor.close();
}

return 0;
}
catch (const rs2::error & e)
{
cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << endl;
return EXIT_FAILURE;
}
15 changes: 6 additions & 9 deletions include/librealsense/rs2.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef enum rs2_exception_type
RS2_EXCEPTION_TYPE_WRONG_API_CALL_SEQUENCE, /**< Function precondition was violated */
RS2_EXCEPTION_TYPE_NOT_IMPLEMENTED, /**< The method is not implemented at this point */
RS2_EXCEPTION_TYPE_DEVICE_IN_RECOVERY_MODE, /**< Device is in recovery mode and might require firmware update */
RS2_EXCEPTION_TYPE_IO, /**< IO Device failure */
RS2_EXCEPTION_TYPE_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */
} rs2_exception_type;

Expand Down Expand Up @@ -211,11 +212,11 @@ typedef enum rs2_timestamp_domain

typedef enum rs2_extension_type
{
RS2_EXTENSION_TYPE_UNKNOWN,
RS2_EXTENSION_TYPE_DEBUG,
RS2_EXTENSION_TYPE_INFO,
RS2_EXTENSION_TYPE_MOTION,
RS2_EXTENSION_TYPE_OPTIONS,
RS2_EXTENSION_TYPE_UNKNOWN,
RS2_EXTENSION_TYPE_VIDEO,
RS2_EXTENSION_TYPE_ROI,
RS2_EXTENSION_TYPE_DEPTH_SENSOR,
Expand Down Expand Up @@ -287,7 +288,6 @@ typedef struct rs2_frame_callback rs2_frame_callback;
typedef struct rs2_log_callback rs2_log_callback;
typedef struct rs2_syncer rs2_syncer;
typedef struct rs2_device_serializer rs2_device_serializer;
typedef struct rs2_record_device rs2_record_device;
typedef struct rs2_source rs2_source;
typedef struct rs2_processing_block rs2_processing_block;
typedef struct rs2_frame_processor_callback rs2_frame_processor_callback;
Expand Down Expand Up @@ -1076,13 +1076,10 @@ void rs2_delete_device_serializer(rs2_device_serializer * device_serializer);
* \param error
* \return
*/
rs2_record_device* rs2_create_record_device(const rs2_device* device, rs2_device_serializer* serializer, rs2_error** error);
/**
* TODO: document
* \param device
*/
void rs2_delete_record_device(rs2_record_device* device);

rs2_device* rs2_create_record_device(const rs2_device* device, rs2_device_serializer* serializer, rs2_error** error);
void rs2_record_device_pause(const rs2_device* device, rs2_error** error);
void rs2_record_device_resume(const rs2_device* device, rs2_error** error);
rs2_device* rs2_create_playback_device(rs2_device_serializer* serializer, rs2_error** error);

rs2_frame* rs2_allocate_synthetic_video_frame(rs2_source* source, rs2_stream new_stream, rs2_frame* original,
rs2_format new_format, int new_bpp, int new_width, int new_height, int new_stride, rs2_error** error);
Expand Down
Loading

0 comments on commit 085b3de

Please sign in to comment.