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

getting depths in meters in matlab from bag file #5892

Closed
nawara72 opened this issue Feb 20, 2020 · 6 comments
Closed

getting depths in meters in matlab from bag file #5892

nawara72 opened this issue Feb 20, 2020 · 6 comments

Comments

@nawara72
Copy link

Hi

I recorded a bag file using rs-record-playback

i used rs_bag2image to generate the depths images. When I read those images in matlab and get the values for a specific coordinate, I get the correct distance
eg
d=imread('000089.png');
d(256,400)
ans =
uint16
1894

How can I achieve the same thing using rs-convert?
I converted the bag to png & raw but i get incorrect values when I load in matlab. What am I doing wrong?
eg
FID=fopen("_Depth_89.raw");
depth=fread(FID,[640,480],'uint16');
depth(256,400)
ans =
0

Thanks in advance for all your help

@MartyG-RealSense
Copy link
Collaborator

There is a long discussion in the link below about getting depth from a bag in MATLAB.

#3241

I also recall that an Intel RealSense support member once recommended the script below for reading a RealSense raw file in MATLAB.

fid = fopen("FilesName.Raw");
Depth = fread(fid, [1280 720], '*uint16')';
fclose(fid);

@nawara72
Copy link
Author

MartyG-RealSense
Thank you so much for your extremely quick reply. I just have to first say the always quick replies from you guys is amazing, so helpful and very appreciated.

As you see from my question, I already use the method you mention to read the image but somehow I am not getting the correct value. Even though rs_bag2image is giving me the correct values, I would prefer to use rs-convert instead.

Thanks again for your help

There is a long discussion in the link below about getting depth from a bag in MATLAB.

#3241

I also recall that an Intel RealSense support member once recommended the script below for reading a RealSense raw file in MATLAB.

fid = fopen("FilesName.Raw");
Depth = fread(fid, [1280 720], '*uint16')';
fclose(fid);

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Feb 20, 2020

Yes, I saw that your .raw loading code was mostly similar to the Intel support member's version. I just wanted to post it so you could compare it to your own as verification.

The author of rs_bag2image, UnaNancyOwen, once said that their program "outputs the original data as it is". This may account for your successful results with PNGs generated from it.

Another RealSense user provided further explanation about differences between the functioning of rs_bag2image and rs-convert:

#3208 (comment)

@nawara72
Copy link
Author

Saw those pages, didn't really help much. Thanks you

Hope someone else has any ideas

Thanks

Yes, I saw that your .raw loading code was mostly similar to the Intel support member's version. I just wanted to post it so you could compare it to your own as verification.

The author of rs_bag2image, UnaNancyOwen, once said that their program "outputs the original data as it is". This may account for your successful results with PNGs generated from it.

Another RealSense user provided further explanation about differences between the functioning of rs_bag2image and rs-convert:

#3208 (comment)

@nawara72
Copy link
Author

Just figured out, I had the image size wrong, so now all working fine

Thanks MartyG

Saw those pages, didn't really help much. Thanks you

Hope someone else has any ideas

Thanks

Yes, I saw that your .raw loading code was mostly similar to the Intel support member's version. I just wanted to post it so you could compare it to your own as verification.
The author of rs_bag2image, UnaNancyOwen, once said that their program "outputs the original data as it is". This may account for your successful results with PNGs generated from it.
Another RealSense user provided further explanation about differences between the functioning of rs_bag2image and rs-convert:
#3208 (comment)

@MartyG-RealSense
Copy link
Collaborator

Awesome news, thanks so much for the update!

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

2 participants