3dhalcon

Render pointcloud parts from the same perspective


When slicing a objectModel3D into horizontal layers using select_points_object_model_3d and rendering these layers using render_object_model_3d(), I noticed that smaller parts of the bigger pointcloud get centered and scaled up to fit the graphics window.

Instead I would like these rendered parts to be te same size and location as when they were part of the bigger objectModel3D.

I have a workaround where I make four small objects at certain distance to each other that I rendered in the image together with the part, this made sure the area to render was always the same and prevented the scaling. But this method is a bit hacky and far from perfect so I was wondering if there is a better way.

How can I render parts of a pointcloud from the same perspective?

EDIT:

Here is the source I use:

for j := 0 to |ROI_slice_zFrom|-1 by 1
  select_points_object_model_3d (scene, 'point_coord_z', ROI_slice_zFrom[j], ROI_slice_zTo[j], slice)
  render_object_model_3d (rendered_image, [borderObjects, slice], CameraParam, [], colorParam, colorValues)
endfor

I expected this to generate images of horizontal layers that would be correctly aligned (with each other) over the x- and y-axis, unfortunately this is not the case. I thought maybe I am supposed insert a pose into the render procedure, but I wouldn't know what pose to use as the camera pose has been invalidated by many transformations.

The borderobjects are just 4 small blocks that create an area bigger than and overlapping the ROI:

*borderobjects
lenUnit                  := 3500
distLen                  := 1500

* borderobject poses
create_pose (distLen, 0, 0, 0, 0, 0, 'Rp+T', 'gba', 'point', pose0)
create_pose (0, distLen, 0, 0, 0, 0, 'Rp+T', 'gba', 'point', pose1)
create_pose (-distLen, 0, 0, 0, 0, 0, 'Rp+T', 'gba', 'point', pose2)
create_pose (0, -distLen, 0, 0, 0, 0, 'Rp+T', 'gba', 'point', pose3)
* offset
create_pose (-3000, -3000, 0, 0, 0, 0, 'Rp+T', 'gba', 'point', borderObjects_XYoffset)

* composed poses
pose_compose (pose0, borderObjects_XYoffset, pose0)
pose_compose (pose1, borderObjects_XYoffset, pose1)
pose_compose (pose2, borderObjects_XYoffset, pose2)
pose_compose (pose3, borderObjects_XYoffset, pose3)

* borderobject   
gen_object_model_3d_from_points (lenUnit, lenUnit, lenUnit, borderObject)

* borderobjects        
rigid_trans_object_model_3d (borderObject, pose0, borderObject_trans0)
rigid_trans_object_model_3d (borderObject, pose1, borderObject_trans1)
rigid_trans_object_model_3d (borderObject, pose2, borderObject_trans2)
rigid_trans_object_model_3d (borderObject, pose3, borderObject_trans3)
borderObjects := [borderObject_trans0, borderObject_trans1, borderObject_trans2, borderObject_trans3]

Solution

  • If you want to render horizontal layers of a pointcloud to images and you don't want things to center of scale then you must use a pose AND in/decrement the trans-Z value of the pose to coincide with de in/decrementation of the trans-Z value used to slice the pointcloud. Doing this will keep the distance between the viewpoint/camera and the rendered part the same and also prevent the centering.