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

Add clouds/meshes file format converter #1442

Merged
merged 1 commit into from
Dec 11, 2015
Merged

Add clouds/meshes file format converter #1442

merged 1 commit into from
Dec 11, 2015

Conversation

VictorLamoine
Copy link
Contributor

Aims to replace:

convert_pcd_ascii_binary.cpp
pcd2ply.cpp
obj2pcd.cpp
obj2ply.cpp
obj2vtk.cpp
pcd2ply.cpp
pcd2vtk.cpp
ply2pcd.cpp
ply2vtk.cpp
vtk2obj.cpp
vtk2pcd.cpp
vtk2ply.cpp

This will also add STL format converter.

@VictorLamoine
Copy link
Contributor Author

A first review would be appreciated, the program is working fine though I have not extensively tested it.

if (pcl::console::find_switch (argc, argv, "-h") != 0 || pcl::console::find_switch (argc, argv, "--help") != 0)
{
displayHelp (argc, argv);
return (-1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would return 0 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

@SergioRAgostinho
Copy link
Member

Looking forward to see this merged :)

@VictorLamoine
Copy link
Contributor Author

I think I fixed everything above, the program is now "finished".
Color is lost during conversion into an OBJ file, thats the only issue I have identified right now.

Give it a test and tell me if something is wrong!

@VictorLamoine VictorLamoine changed the title [WIP] Add clouds/meshes file format converter Add clouds/meshes file format converter Nov 24, 2015
//TODO: Support precision
//FIXME: Color is lost during conversion (OBJ supports color)
if (output_type == BINARY || output_type == BINARY_COMPRESSED)
PCL_WARN ("OBJ file format supports only ASCII.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning will also be printed in saveMesh() better to just remove it. This branch of your if statement can pretty much disappear and be moved to the else branch with ply and vtk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I fixed that. Interestingly savePolygonFile does not allow to save OBJ files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked at the source and it definitely looks like bug, especially given the fact that you can load OBJ files in the function above :D

If you patched it you could even move L155-165 into L174-188 adding the additional check for the output_type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forget about my last suggestion. I just noticed that there are seemingly close functionalities implemented in pcl::io::save and pcl::io::savePolygonFile. This should probably be addressed in another pull request. Thanks for you effort!

@VictorLamoine
Copy link
Contributor Author

I've just added an option to transform a mesh into a point cloud using the -c or --cloud switches. It just discards all faces in the file.

@SergioRAgostinho
Copy link
Member

Sorry, I wasn't clear enough on my last comment about the warning. Note that L102-110 are similar to L139-144, which basically means you can delete L102-110.

@VictorLamoine
Copy link
Contributor Author

Oh that's right I must have not read the right lines when reading your comment 😄
All of these remarks makes the code much cleaner!

@VictorLamoine
Copy link
Contributor Author

@jspricke Friendly pi(n)g 🐷

/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2009, Willow Garage, Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the copyright?

@taketwo
Copy link
Member

taketwo commented Dec 10, 2015

Victor, great work!

I find the filename argument handling to be unnecessary verbose though. Instead of lines 213-217, 223-228, 247-265 we can write something like (untested):

const std::vector<std::string> supported_extensions = {".obj", ".pcd", ".ply", ".stl", ".vtk"};
std::vector<int> file_args;
for (int i = 1; i < argc; ++i)
  for (size_t j = 0; j < supported_extensions.size (); ++j)
    if (boost::algorithm::ends_with (argv[i], supported_extensions[j])
    {
      file_args.push_back (i);
      break;
    }

if (file_args.size () != 2)
  // error message, return

std::string input = argv[file_args[0]];
std::string output = argv[file_args[1]];

@VictorLamoine
Copy link
Contributor Author

I've done it your way Sergey, it's shorter and still very readable. I did not use the C++11 vector initializer because C++11 is not enabled in PCL.

@taketwo
Copy link
Member

taketwo commented Dec 11, 2015

I did not use the C++11 vector initializer because C++11 is not enabled in PCL.

Yeah, right, I suspected that line would not compile with the old standard :)

What about the name of the tool, maybe just pcl_converter or pcl_convert?

@VictorLamoine
Copy link
Contributor Author

Now it's named pcl_converter

@taketwo
Copy link
Member

taketwo commented Dec 11, 2015

Thanks! I haven't tried it, but the code looks good for me.

Do we want to merge this before the release or immediately after?

@VictorLamoine
Copy link
Contributor Author

I don't mind; I think it's a useful tool so I would merge before.
One more thing to add to your giant changelog :)

@SergioRAgostinho
Copy link
Member

Agree with Victor on both statements. Kudos for your massive changelog Sergey ;)

@taketwo
Copy link
Member

taketwo commented Dec 11, 2015

Thanks guys.
@jspricke please merge if you think it's ready.

jspricke added a commit that referenced this pull request Dec 11, 2015
@jspricke jspricke merged commit af5f9d8 into PointCloudLibrary:master Dec 11, 2015
@VictorLamoine VictorLamoine deleted the pcl_convert_clouds_meshes branch December 15, 2015 15:50
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

Successfully merging this pull request may close these issues.

4 participants