Error when combining two Real sense program together
Hello,
I am working with the Tracking Camera T265 and i am facing problem when try to combine two programs together (rs-save to disk with rs-trajectory) it shows the error:
RealSense error calling rs2_pipeline_start_with_config(pipe:0x20756f0, config:0x20668e0):
if anyone can help it would be greatful.
Thank you
-
A member of the Intel RealSense team on the GitHub site gave the advice below to a user with the same error:
"The specific error appear when the application tries to configure stream with unsupported resolution / fps / format modes ... run rs-enumerate-devices -o to list all the supported configurations, and then reconfigure the Librealsense code accordingly".
-
Thanks for the reply MartyG i already visited the issue before but i could not understand that how to solve this error.Can you elaborate it more that how can i solve this error .it would be greatful if you can help.
Thanks
-
I need to merge rs-trajectory and rs-save to disk program also need to have multiple pipeline single device .
I have camera/device connected and camera is on in video mode....now i want to have image of that video which i can do using rs-save-to-disk code...also i need to find trajectory of the same video which i can find using rs-trajectory code.
Now i want to merge this two code...problem i am facing is rs-trajectory uses cfg when we start pipeline....but rs-save-to-disk does not use cfg when we start pipeline....how can i do this??.....What I found is that I cannot use two pipelines for same camera/device I guess, please help me
Thanks in advance....!!!!!!!!
-
The ideal situation for simplicity is to have a single pipeline. It is possible to have multiple threads, but if you are only using one device (the T265) instead of multiple devices then it is likely sufficient to just have a single pipeline.
Cfg (configuration) statements can be used to set up a specific configuration of certain data stream types and their resolution, format and frames per second (FPS) instead of using the default configuration for the camera (which will happen if a cfg configuration is not defined) in the header of the script, just before the pipe start instruction..
It is therefore probably not going to matter that there are not cfg instructions for the save-to-disk part of your merged script, as it will be saving data from streams that were set up by the cfg instructions from the rs-trajectory part of the code.
Merging two scripts exceeds my coding knowledge unfortunately as I am not a programming psecialist, so you are likely to get expert advice on this subject from the GitHub versions of your questions.
-
Hiii...MartyG
Thanks for your reply...!I have posted same on github too.
Here is the resultant code , merged using rs-trajectory and rs-save-to-disk. I am using single pipeline called pipe and in case of rs-save-to-disk I do not need to start() with cfg...but in case of rs-trajectory in need to start(cfg) with cfg.
When I run this code, rs-trajectory code is working fine , but rs-save-to-disk code is not working.So can you please tell what's wrong in this code or how should I use it in correct way.
Below is code starting from main function ---
// In this example, we show how to track the camera's motion using a T265 device
int main(int argc, char * argv[]) try
{
// Declare depth colorizer for pretty visualization of depth data
rs2::colorizer color_map;
// Declare RealSense pipeline, encapsulating the actual device and sensors
// rs2::pipeline pipe_for_save_to_disk;
// Start streaming with default recommended configuration
// pipe_for_save_to_disk.start();
int imgCount = 0;
// Initialize window for rendering
window app(1280, 720, "RealSense Trajectory Example");
// Construct an object to manage view state
glfw_state app_state(0.0, 0.0);
// Register callbacks to allow manipulation of the view state
register_glfw_callbacks(app, app_state);
// Create objects for rendering the camera, the trajectory and the split screen
camera_renderer cam_renderer;
tracker tracker;
split_screen_renderer screen_renderer(app.width(), app.height(), tracker, cam_renderer);
// Declare RealSense pipeline, encapsulating the actual device and sensors
rs2::pipeline pipe;
// Create a configuration for configuring the pipeline with a non default profile
rs2::config cfg;
// Add pose stream
cfg.enable_stream(RS2_STREAM_POSE, RS2_FORMAT_6DOF);
// Start pipeline with chosen configuration
pipe.start(cfg);
std::ofstream myfile("/home/shivani/Desktop/librealsense-development/build/examples/trajectory/matrix1.txt");
// Main loop
while (app)
{
//HERE RS-SAVE-TO-DISK STARTS ...!!!!!!!
// Capture 30 frames to give autoexposure, etc. a chance to settle
for (auto i = 0; i < 30; ++i) pipe.wait_for_frames();
// Wait for the next set of frames from the camera. Now that autoexposure, etc.
// has settled, we will write these to disk
for (auto&& frame : pipe.wait_for_frames())
{
// We can only save video frames as pngs, so we skip the rest
if (auto vf = frame.as<rs2::video_frame>())
{
auto stream = frame.get_profile().stream_type();
// Use the colorizer to get an rgb image for the depth stream
if (vf.is<rs2::depth_frame>()) vf = color_map.process(frame);
// Write images to disk
std::stringstream png_file;
png_file << "rs-save-to-disk-output-" << imgCount++ << ".png";
stbi_write_png(png_file.str().c_str(), vf.get_width(), vf.get_height(),
vf.get_bytes_per_pixel(), vf.get_data(), vf.get_stride_in_bytes());
std::cout << "Saved " << png_file.str() << std::endl;
}
}
// RS-SAVE-TO-DISK ENDS ..!!!!!!!!
// RS-TRAJECTORY BEGIN....
// Wait for the next set of frames from the camera
auto frames = pipe.wait_for_frames();
std::cout << frames << std::endl;
// Get a frame from the pose stream
auto f = frames.first_or_default(RS2_STREAM_POSE);
// Cast the frame to pose_frame and get its data
auto pose_data = f.as<rs2::pose_frame>().get_pose_data();
float r[16];
// Calculate current transformation matrix
tracker.calc_transform(pose_data, r);
if (myfile.is_open())
{
std::cout << "going to write in matrix file "<< imgCount++ << std::endl;
myfile << "";
for (int count = 0 ; count <15; count++)
{
myfile << r[count] << " " ;
}
myfile << "\n";
}
else std::cout<< "unable to open file";
// From the matrix we found, get the new location point
rs2_vector tr{ r[12], r[13], r[14] };
// Create a new point to be added to the trajectory
tracked_point p{ tr , pose_data.tracker_confidence };
// Register the new point
tracker.add_to_trajectory(p);
// Draw the trajectory from different perspectives
screen_renderer.draw_windows(app.width(), app.height(), app_state, r);
}
myfile.close();
return EXIT_SUCCESS;
}
catch (const rs2::error & e)
{
std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} -
The GitHub will be the better place for advice on scripting.
If I were writing this program myself though, I would put the save-to-disk section after the rs-trajectory section and not before it. If the save-to-disk function only runs for a second before exiting, I would suspect from this script structure that the script first performs a save operation that contains little or no data because it comes before the trajectory code has started running. The trajectory section then probably starts running after the save routine has already ended.
Please sign in to leave a comment.
Comments
6 comments