Search code examples
halcon

Render RGB pointcloud together with surface match result


(HalconDotNET)

I want to render an image from a visualized match result with a colored pointcloud.

In the example program find_surface_model_with_edges_simple.hdev after running find_surface_model() you receive a pose, with this pose you can visualize how the surface model matched in the scene using: visualize_object_model_3d(). From a visualization like this I want to create a rendered image to display the matching result in an application I am making.

To render a colored pointcloud I use: render_object_model_3d (Image, ObjectModel3DSceneRaw_ccs, camPar, Pose_0, ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'])

To render a match result I use: render_object_model_3d (Image, [ObjectModel3DSceneRaw_ccs, ObjectModel3D], camPar, [Pose_0, detectedPose], ['color_0', 'color_1'], ['white', 'red'])

I can not get the two objects in this function and still have the RGB attributes, Halcon gives parameter errors. I would also like to specify the color of the objectmodel.

I also tried to use 3D scene:

create_scene_3d (Scene3D)
add_scene_3d_camera (Scene3D, camPar, CameraIndex)
set_scene_3d_camera_pose (Scene3D, CameraIndex, detectedPose)
add_scene_3d_light (Scene3D, PoseInvert[0:2], 'point_light', LightIndex)
* The scene
add_scene_3d_instance (Scene3D, ObjectModel3DSceneRaw_ccs, detectedPose, InstanceIndex)
set_scene_3d_instance_param (Scene3D, InstanceIndex, ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'])
* The transformed objectModel
add_scene_3d_instance (Scene3D, ObjectModel3DRigidTrans, Pose_0, InstanceIndex2)
set_scene_3d_instance_param (Scene3D, InstanceIndex2, 'color', 'red')
* Display
display_scene_3d (WindowHandle, Scene3D, CameraIndex)

But this only shows the scene and not the matched objectmodel.

Anyone know what I'm doing wrong?


Solution

  • This hack worked well enough for my purposes:

    
    HT empty = new HT();
    
    hop.CreatePose(0, 0, 0, 0, 0, 0, "Rp+T", "gba", "point", out HT pose_0);
    HT camParam = new HT(0.008, 0, 0, 0, 0, 0, 5.2e-006, 5.2e-006, 960, 600, 1920, 1200);
    HT renderGenParam = new HT("red_channel_attrib", "green_channel_attrib", "blue_channel_attrib");
    HT renderGenValue = new HT("red", "green", "blue");
    
    hop.ReadObjectModel3d(om3Path, 'm', empty, empty, out HT om3, out HT status);
    
    hop.RenderObjectModel3d(out HObject sceneImage, current_OM3, camParam, pose_0, renderGenParam, renderGenValue);
    hop.RenderObjectModel3d(out HObject objectImage, om3, camParam, avg_pose, "color_0", "green");
    hop.AddImage(sceneImage, objectImage, out HObject resultImage, 0.6, 0);
    hop.CropRectangle1(resultImage, out HObject resultCropped, 250, 400, 935, 1450);
    hop.WriteImage(resultCropped, "tiff", 0, @"./testImage.tiff");
    
    

    Not a real solution tho.