This repository has been archived by the owner on Dec 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 703
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from larsmans/io
New Pythonic pcl.{load,save} functions; PLY format support
- Loading branch information
Showing
12 changed files
with
182 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
*.pcd | ||
|
||
pcl.cpp | ||
pcl.html | ||
pcl/_pcl.cpp | ||
pcl/_pcl.html | ||
|
||
*.py[co] | ||
*.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# XXX do a more specific import! | ||
from ._pcl import * | ||
|
||
|
||
def load(path, format=None): | ||
"""Load pointcloud from path. | ||
Currently supports PCD and PLY files. | ||
Format should be "pcd", "ply", or None to infer from the pathname. | ||
""" | ||
format = _infer_format(path, format) | ||
p = PointCloud() | ||
try: | ||
loader = getattr(p, "_from_%s_file" % format) | ||
except AttributeError: | ||
raise ValueError("unknown file format %s" % format) | ||
if loader(path): | ||
raise IOError("error while loading pointcloud from %r (format=%r)" | ||
% (path, format)) | ||
return p | ||
|
||
|
||
def save(cloud, path, format=None, binary=False): | ||
"""Save pointcloud to file. | ||
Format should be "pcd", "ply", or None to infer from the pathname. | ||
""" | ||
format = _infer_format(path, format) | ||
try: | ||
dumper = getattr(cloud, "_to_%s_file" % format) | ||
except AttributeError: | ||
raise ValueError("unknown file format %s" % format) | ||
if dumper(path, binary): | ||
raise IOError("error while saving pointcloud to %r (format=%r)" | ||
% (path, format)) | ||
|
||
|
||
def _infer_format(path, format): | ||
if format is not None: | ||
return format.lower() | ||
|
||
for candidate in ["pcd", "ply"]: | ||
if path.endswith("." + candidate): | ||
return candidate | ||
|
||
raise ValueError("Could not determine file format from pathname %s" % path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,8 @@ def pkgconfig(flag): | |
author='John Stowers', | ||
author_email='[email protected]', | ||
license='BSD', | ||
ext_modules=[Extension("pcl", ["pcl.pyx", "minipcl.cpp"], | ||
packages=["pcl"], | ||
ext_modules=[Extension("pcl._pcl", ["pcl/_pcl.pyx", "pcl/minipcl.cpp"], | ||
language="c++", **ext_args)], | ||
cmdclass={'build_ext': build_ext} | ||
) |
Oops, something went wrong.