Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignment to depth causes segmentation fault #2567

Closed
DuccioLenkowicz opened this issue Oct 19, 2018 · 7 comments
Closed

Alignment to depth causes segmentation fault #2567

DuccioLenkowicz opened this issue Oct 19, 2018 · 7 comments
Assignees

Comments

@DuccioLenkowicz
Copy link


Required Info
Camera Model { D435 }
Operating System & Version { Win (10) }
SDK Version { 2.16.1 }
Language {C++}

Issue Description

I'm trying to align the rgb to the depth to obtain something similar to #2560 , the code i'm using is the following:

pipeline pipe;
config cfg;
cfg.enable_stream( rs2_stream::RS2_STREAM_COLOR, 848, 480, rs2_format::RS2_FORMAT_BGR8, 30 );
cfg.enable_stream( rs2_stream::RS2_STREAM_DEPTH, 848, 480, rs2_format::RS2_FORMAT_Z16, 30 );
pipe.start(cfg);
align align(rs2_stream::RS2_STREAM_DEPTH);

// ...
// ... later in a loop
// ...

 auto frameset = pipe.wait_for_frames();
 auto processed = align.process(frameset);

The segfault happens in the process function.

@DuccioLenkowicz
Copy link
Author

I fixed it by looking at the rs-measure example, the color stream must be of the format RS2_FORMAT_BGRA8 or RS2_FORMAT_RGBA8 in order for the alignment to work.

@RealSense-Customer-Engineering
Copy link
Collaborator

[Realsense Customer Engineering Team Comment]
@DuccioLenkowicz Thanks for the update! We'll close the ticket accordingly.

@ThomasBrandonD
Copy link

I wanted to reopen this issue because I've been struggling with it for several weeks. Has anyone else encountered the same issue as OP except his fix didn't work?

@whatisor
Copy link

I also get same problem when try to run on Raspbian. Color formats did not help.
If do not call align process, it runs well.

@ThomasBrandonD
Copy link

Ah, I should also mention I'm running on Ubuntu, so technically its a different problem than OP because he's on Windows. Is there an open ticket for this on linux?

@whatisor
Copy link

whatisor commented Nov 16, 2019

This seems to be very strange but issue only occurs if I "link" my program with other library(OpenVINO).

`

//#include "AIClient.h"

//#include "GlobalMatching.h"

#include <thread>

#include  <librealsense2/rs.hpp>

#include "opencv2/highgui.hpp"

#include "opencv2/imgproc.hpp"

#include "RealsenseTool.hpp"

int main(int argc, char** argv)

{

//      GlobalMatching globalMatch;

//AIClient aiClient1("829212072062", globalMatch);

//AIClient aiClient2("912112074076", globalMatch);

if(argc > 1)

;//aiClient1.model = argv[1];

if (argc > 2)

;//aiClient1.device = argv[2];

//aiClient1.start();

 //aiClient2.start();

//aiClient1.join();

//aiClient2.join();

rs2::pipeline pipe;

rs2::config cfg;

cfg.enable_stream(RS2_STREAM_INFRARED);

cfg.enable_stream(RS2_STREAM_DEPTH);

cfg.enable_stream(RS2_STREAM_COLOR);

pipe.start(cfg);

rs2::align align_to_color(RS2_STREAM_COLOR);

rs2::colorizer c;

while(1){

auto frameset = pipe.wait_for_frames();

frameset = align_to_color.process(frameset);//segmentation fault here

auto depth = frameset.get_depth_frame();

auto color = frameset.get_color_frame();

auto colorized = c.colorize(depth);

cv::Mat dMat = frame_to_mat(depth);

cv::Mat cMat = frame_to_mat(color);

cv::imshow("Color",cMat);

//cv::imshow("Depth",dMat);

int a = cv::waitKey(1);

if(a == 'q')break;

}        return 0;

}

`

@whatisor
Copy link

And here is gdb log:

0x763f4134 in librealsense::align::create_aligned_profile (this=this@entry=0x1bdfa4,
original_profile=..., to_profile=...)
at /home/pi/OpenVINO/build/librealsense/src/../include/librealsense2/hpp/rs_frame.hpp:48
warning: Source file is more recent than executable.
48 /
(gdb) bt
#0 0x763f4134 in librealsense::align::create_aligned_profile(rs2::video_stream_profile&, rs2::video_stream_profile&)
(this=this@entry=0x1bdfa4, original_profile=..., to_profile=...)
at /home/pi/OpenVINO/build/librealsense/src/../include/librealsense2/hpp/rs_frame.hpp:48
#1 0x763f4a3c in librealsense::align::allocate_aligned_frame(rs2::frame_source const&, rs2::video_frame const&, rs2::video_frame const&)
(this=this@entry=0x1bdfa4, source=..., from=..., to=...)
at /home/pi/OpenVINO/build/librealsense/src/proc/align.cpp:218
#2 0x763f50d0 in librealsense::align::process_frame(rs2::frame_source const&, rs2::frame const&) (this=0x1bdfa4, source=..., f=...)
at /home/pi/OpenVINO/build/librealsense/src/proc/align.cpp:278
#3 0x764083e8 in librealsense::generic_processing_block::<lambda(rs2::frame, const rs2::frame_source&)>::operator() (__closure=0x1cb574, source=..., f=...)
at /home/pi/OpenVINO/build/librealsense/src/proc/synthetic-stream.cpp:67
#4 0x764083e8 in rs2::frame_processor_callback<librealsense::generic_processing_block::generic_processing_block(char const
)::<lambda(rs2::frame, const rs2::frame_source&)> >::on_frame(rs2_frame , rs2_source )
(this=0x1cb570, f=, source=)
at /home/pi/OpenVINO/build/librealsense/src/../include/librealsense2/hpp/rs_processing.hpp:109
#5 0x764066d4 in librealsense::processing_block::invoke(librealsense::frame_holder)
(this=0x1bdfa4, f=...)
at /home/pi/OpenVINO/build/librealsense/src/proc/synthetic-stream.h:37
#6 0x764f4dd8 in rs2_process_frame(rs2_processing_block
, rs2_frame
, rs2_error**)
(block=, frame=, error=0x7effef40)
at /home/pi/OpenVINO/build/librealsense/src/core/streaming.h:138
#7 0x00031c38 in main ()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants