-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from zshahaf/master
Recorder from zshahaf
- Loading branch information
Showing
346 changed files
with
5,819 additions
and
17,553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Readme (TODO) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.