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

get_texture_coordinates() returns array filled with 0 values #1939

Closed
eMrazSVK opened this issue Jun 22, 2018 · 2 comments
Closed

get_texture_coordinates() returns array filled with 0 values #1939

eMrazSVK opened this issue Jun 22, 2018 · 2 comments
Assignees
Labels

Comments

@eMrazSVK
Copy link

| Required Info
| Camera Model D415
| Firmware Version 05.09.11.00
| Operating System & Version Ubuntu 16
| Kernel Version (Linux Only) 4.4.38
| Platform Jetson TX2
| SDK Version 2.0
| Language C++
| Segment Robotics

Hello,

I am developing an application, where I would like to use PCL library and so is that, I need to save point cloud data from realsense D415 to .PCD format. This has been discussed here and also in the community quite a lot, but I ran into a strange behavior.

Here is the link to question I have asked in community forum, the link points to the code which is supposed to work /- https://communities.intel.com/message/551252#551252. I have successfully converted depth frame to PCD format, but only the XYZ values. As far as my application is concerned, I need RGB values too. So I want to add RGB values to each point in the pointcloud. What is actually happening is that each point has same color. I tried a little bit of debugging and what I have found is that point coordinates which are calculated at https://github.com/eMrazSVK/JetsonSLAM/blob/master/pcl_testing.cpp#L24 are always zero. (I printed it like std::cout<<x<<std::endl and found out it is always zero for every pair of coordinates). Another thing when I tried to print out output of get_texture coordinates(), like this:
auto tex_coords = points.get_texture_coordinates();
std::cout << tex_coords[100].v << std::endl;
It prints out zero again. So according to this, I guess - every point of the point cloud has color of point [0,0] in the RGB image. Maybe information, that I am able to display RGB frame without any problem could be helpful.

This is the whole code: https://github.com/eMrazSVK/JetsonSLAM/blob/master/pcl_testing.cpp

Thank you for any suggestions!

@ev-mp
Copy link
Collaborator

ev-mp commented Jun 25, 2018

Hello @eMrazSVK ,
The sample you refer to does not use the API correctly - the order of API calls is reversed.
The pointcloud is generated with the pc.calculate(.. call. If the other (color) image is not set at this stage, then the point cloud will be generated without texture coordinates.
It should be

# Tell pointcloud object to map to this color frame
pc.map_to(color)

# Generate the pointcloud and texture mappings
points = pc.calculate(depth)

In addition, it make sense to check that both color and depth frames are not empty.

See the a following example as a reference.
Additionally, review #1601 for PCL-specific info.

@ev-mp ev-mp added the question label Jun 25, 2018
@eMrazSVK
Copy link
Author

eMrazSVK commented Jun 25, 2018

Hello,

Thank you very much, yeah... You solved the problem very quickly, changing the order of the two lines did it. Now the colors are a bit weird, but I think this is solved, since the color was not the point of this question.

EDIT: Here is the working version with colors fixed https://github.com/eMrazSVK/JetsonSLAM/blob/master/pcl_testing.cpp - at lines 69-71 it needs to be in 2-1-0 order beacause of BGR model instead of RGB. (I dont know why, you have to CTR-C the link and paste it in to address bar of your browser to access it).

Many thanks!

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

No branches or pull requests

3 participants