Skip to content

Commit

Permalink
Merge pull request #6 from for-geeks/seg
Browse files Browse the repository at this point in the history
exercise: add mass point line test codes
  • Loading branch information
mickeyouyou authored Dec 14, 2019
2 parents 10f511d + 4ad3669 commit e84d0f8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
For Geeks Python PCL Introduction
Python PCL Introduction For Geeks
============

This is a small python binding to the `pointcloud <http://pointclouds.org/>`_ library.
Expand Down
18 changes: 9 additions & 9 deletions examples/official/Features/moment_of_inertia.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# http://pointclouds.org/documentation/tutorials/moment_of_inertia.php#moment-of-inertia

import pcl

import pcl.pcl_visualization

def main():
cloud = pcl.load('./examples/pcldata/tutorials/lamppost.pcd')
cloud = pcl.load('/python-pcl/examples/pcldata/tutorials/lamppost.pcd')

# 1.8
# pcl::MomentOfInertiaEstimation <pcl::PointXYZ> feature_extractor;
Expand Down Expand Up @@ -50,11 +50,11 @@ def main():
# viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
# viewer->addCube (min_point_AABB.x, max_point_AABB.x, min_point_AABB.y, max_point_AABB.y, min_point_AABB.z, max_point_AABB.z, 1.0, 1.0, 0.0, "AABB");
###
viewer = pcl.visualization.PCLVisualizing()
viewer = pcl.pcl_visualization.PCLVisualizering()
viewer.SetBackgroundColor(0, 0, 0)
viewer->InitCameraParameters()
# viewer->InitCameraParameters()
# viewer->AddPointCloud (cloud, 'sample cloud', 0)
viewer->AddPointCloud(cloud)
# viewer->AddPointCloud(cloud)
viewer.AddCube(min_point_AABB.x, max_point_AABB.x, min_point_AABB.y,
max_point_AABB.y, min_point_AABB.z, max_point_AABB.z, 1.0, 1.0, 0.0, "AABB")

Expand All @@ -78,9 +78,9 @@ def main():
middle_vector[1] + mass_center[1], middle_vector[2] + mass_center[2])
z_axis = pcl.PointCloud(
minor_vector[0] + mass_center[0], minor_vector[1] + mass_center[1], minor_vector[2] + mass_center[2])
viewer.AddLine(center, x_axis, 1.0f, 0.0f, 0.0f, "major eigen vector")
viewer.AddLine(center, y_axis, 0.0f, 1.0f, 0.0f, "middle eigen vector")
viewer.AddLine(center, z_axis, 0.0f, 0.0f, 1.0f, "minor eigen vector")
viewer.AddLine(center, x_axis, 1.0, 0.0, 0.0, "major eigen vector")
viewer.AddLine(center, y_axis, 0.0, 1.0, 0.0, "middle eigen vector")
viewer.AddLine(center, z_axis, 0.0, 0.0, 1.0, "minor eigen vector")

# while(!viewer->wasStopped())
# {
Expand All @@ -89,7 +89,7 @@ def main():
# }
v = true
while v:
v = not(visual.WasStopped())
v = not(viewer.WasStopped())
# visual.spinOnce (100)
# boost::this_thread::sleep (boost::posix_time::microseconds (100000));

Expand Down
8 changes: 5 additions & 3 deletions exercises/3.2.example.segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,19 @@ def main():
cloud_input[indice][0],
cloud_input[indice][1],
cloud_input[indice][2]])

if cloud_input[indice][0] < min_x: min_x = cloud_input[indice][0]
if cloud_input[indice][1] < min_y: min_y = cloud_input[indice][1]
if cloud_input[indice][2] < min_z: min_z = cloud_input[indice][2]

if cloud_input[indice][0] > max_x: max_x = cloud_input[indice][0]
if cloud_input[indice][1] > max_y: max_y = cloud_input[indice][1]
if cloud_input[indice][2] > max_z: max_z = cloud_input[indice][2]

print('cluster size:' + str(len(cluster_points)))
cluster_cloud = pcl.PointCloud()
cluster_cloud.from_list(cluster_points)
# mass center
# mass_center_point = pcl.PointCloud(min_x + (min_x+max_x)/2, min_y + (min_y+max_y)/2, min_z + (min_z+max_z)/2)
# z_axis = pcl.PointCloud(min_x, min_y, min_z)
# CLOUD RGB COLOR
r = int(cluster_color[j][0])
g = int(cluster_color[j][1])
Expand All @@ -94,7 +95,8 @@ def main():
cluster_cloud, r, g, b)
# pcl.save(cluster_cloud, str(j) + '.pcd')
viewer.AddPointCloud_ColorHandler(cluster_cloud, cluster_pc_color, 'cloud_cluster:' + str(j))
# viewer.AddCube(min_x, max_x, min_y, max_y, min_z, max_z, 255, 255, 255, 'cloud_cluster:' + str(j))
# viewer.AddCube(min_x, max_x, min_y, max_y, min_z, max_z, 1.0, 1.0, 1.0, 'cloud_cluster:' + str(j))
# viewer.AddLine(mass_center_point, z_axis, 0.0, 0.0, 1.0, "minor eigen vector")

v = True
while v:
Expand Down
1 change: 0 additions & 1 deletion exercises/3.2.todo.segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def main():
cloud_input[indice][0],
cloud_input[indice][1],
cloud_input[indice][2]])

print('cluster size:' + str(len(cluster_points)))
cluster_cloud = pcl.PointCloud()
cluster_cloud.from_list(cluster_points)
Expand Down

0 comments on commit e84d0f8

Please sign in to comment.