Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated cells to using PclCell and to reflect changes in pose_corrector
API
- Loading branch information
Mike Krainin
committed
Sep 3, 2011
1 parent
a32fce4
commit 2e84582
Showing
6 changed files
with
149 additions
and
143 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
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 |
---|---|---|
@@ -1,48 +1,59 @@ | ||
#!/usr/bin/env python | ||
|
||
import ecto, ecto_ros, ecto_pcl, ecto_pcl_ros, ecto_sensor_msgs, ecto_opencv.highgui | ||
import ecto_corrector | ||
import ecto, ecto_ros | ||
from ecto_openni import Capture, ResolutionMode, Device | ||
from ecto_pcl import NiConverter, NormalEstimation, KDTREE_ORGANIZED_INDEX | ||
from ecto_corrector import Segmenter | ||
from ecto_opencv.highgui import imshow | ||
|
||
import sys | ||
|
||
debug = False | ||
|
||
#openni capture | ||
device = Capture('ni device', rgb_resolution=ResolutionMode.VGA_RES, | ||
depth_resolution=ResolutionMode.VGA_RES, | ||
rgb_fps=30, depth_fps=30, | ||
device_number=0, | ||
registration=True, | ||
synchronize=False, | ||
device=Device.KINECT | ||
) | ||
cloud_generator = NiConverter('cloud_generator') | ||
graph = [ device[:] >> cloud_generator[:] ] | ||
|
||
#normals | ||
normals = NormalEstimation("Normals", k_search=0, radius_search=0.006, | ||
spatial_locator=KDTREE_ORGANIZED_INDEX) | ||
graph += [ cloud_generator[:] >> normals[:] ] | ||
|
||
#segmentation | ||
segmenter = Segmenter("Segmenter",pixel_step=2, | ||
depth_threshold=0.0015, #0.0015 | ||
normal_threshold=0.98, #0.96 | ||
curvature_threshold=10) #not using curvature threshold | ||
graph += [ cloud_generator[:] >> segmenter["input"], | ||
normals[:] >> segmenter["normals"], ] | ||
|
||
#drawing | ||
im_drawer = imshow("Drawer",name="segments", waitKey=10) | ||
graph += [ segmenter[:] >> im_drawer[:] ] | ||
|
||
|
||
plasm = ecto.Plasm() | ||
plasm.connect(graph) | ||
|
||
if __name__ == "__main__": | ||
ecto_ros.init(sys.argv, "segmenter_test") | ||
|
||
#subscribers | ||
sub_cloud = ecto_sensor_msgs.Subscriber_PointCloud2("Cloud2 Subscriber",topic_name="/camera/rgb/points") | ||
|
||
#converters (PointCloud2 -> type erased PointCloud -> PointCloud<PointXYZ>) | ||
msg2cloud = ecto_pcl_ros.Message2PointCloud("Cloud2 To Type-Erased",format=ecto_pcl.XYZ) | ||
#cloud2typed = ecto_pcl.PointCloud2PointCloudT("Type-Erased To XYZ",format=ecto_pcl.XYZ) | ||
|
||
#normals | ||
normals = ecto_pcl.NormalEstimation("Normals", k_search=0, radius_search=0.006, spatial_locator=ecto_pcl.KDTREE_ORGANIZED_INDEX) | ||
#normals = ecto_pcl.NormalEstimation("Normals", k_search=20, radius_search=0, spatial_locator=ecto_pcl.KDTREE_FLANN) | ||
|
||
#segmentation | ||
segmenter = ecto_corrector.Segmenter("Segmenter",pixel_step=2, | ||
depth_threshold=0.0015, #0.0015 | ||
normal_threshold=0.98, #0.96 | ||
curvature_threshold=10) #not using curvature threshold | ||
|
||
#drawing | ||
im_drawer = ecto_opencv.highgui.imshow("Drawer",name="segments", waitKey=10) | ||
|
||
graph = [ | ||
sub_cloud[:] >> msg2cloud[:], | ||
msg2cloud[:] >> normals[:], | ||
msg2cloud[:] >> segmenter["input"], | ||
normals[:] >> segmenter["normals"], | ||
segmenter[:] >> im_drawer[:] | ||
] | ||
|
||
plasm = ecto.Plasm() | ||
plasm.connect(graph) | ||
|
||
if(debug): | ||
ecto.view_plasm(plasm) | ||
|
||
sched = ecto.schedulers.Threadpool(plasm) | ||
sched.execute() | ||
|
||
if debug: | ||
sched.execute_async() | ||
from IPython.Shell import IPShellEmbed | ||
ipshell = IPShellEmbed() | ||
ipshell() | ||
|
||
else: | ||
sched.execute() |
Oops, something went wrong.