0

How can I paint 3D orientation arrows onto an image in Halcon to illustrate the orientation of a pointcloud I'm rendering?

First I figured I would generate a 2D image of the arrows, rotate as needed (pointcloud will only rotate over z-axis) and just paint it on. So I've looked through the examples and searched online but I could only find add_image() which just adds the values together.

If I could generate a small 3D orientation arrow object (not like the big option disp_pose in render_object_model_3d()) object to render along with the image that would be even better. Any advice on how to tackle this problem is welcome.

Malinko
  • 124
  • 11

1 Answers1

1

The easiest way would be to render a 3D object. There is a cylinder in the image, you'd need to add a cone to it to be an arrow:

*** create a scene
create_scene_3d(Scene3D)

*** add camera with custom camera pose
ImageWidth := 1280
ImageHeight := 1024
Cx := 640
Cy := 512
gen_cam_par_area_scan_division(0.008, 0.0, 5.2e-06, 5.2e-06, Cx, Cy, ImageWidth, 1024, CameraParam)

create_pose(Cx, Cy, -200, 0, 0, 0, 'Rp+T', 'gba', 'point', CameraPose)

add_scene_3d_camera(Scene3D, CameraParam, CameraIndex)
set_scene_3d_camera_pose(Scene3D, CameraIndex, CameraPose)
set_scene_3d_param (Scene3D, 'object_index_persistence', 'true')

*** add light to scene
add_scene_3d_light(Scene3D, [1.0, 1.0, 1.0], 'point_light', LightIndex)
set_scene_3d_light_param(Scene3D, LightIndex, 'diffuse', [0.8, 0.8, 0.8])
set_scene_3d_light_param(Scene3D, LightIndex, 'ambient', [0.5, 0.5, 0.5])

*** create object
create_pose(0.0, 0.0, 0.0, 0, 0, 0, 'Rp+T', 'gba', 'point', Pose)
gen_cylinder_object_model_3d(Pose, 20.0, 100.0, 200.0, ObjectModel3D)

*** add object to scene
create_pose(ImageWidth/2.0, ImageHeight/2.0, 0, 30, 0, 0, 'Rp+T', 'gba', 'point', InstancePose)
add_scene_3d_instance(Scene3D, ObjectModel3D, InstancePose, InstanceIndex)
set_scene_3d_instance_param (Scene3D, InstanceIndex, 'alpha', .8)

*** render scene
render_scene_3d(Image, Scene3D, InstanceIndex)
dev_display (Image)

enter image description here

Vladimir Perković
  • 1,351
  • 3
  • 12
  • 30
  • 1
    Thank you for your suggestion. I can see how this can become a solution. Unfortunately I am not able to make a coordinate system object in Halcon due to a lack of 3D-design knowhow (not for a lack of trying, it's a mess). I found a function that does exactly what I want ('disp_3d_coord_system()') but this is just for use with a Halcon graphic windows – Malinko May 04 '23 at 11:23