Halcon学习笔记:xyz_attrib_to_object_model_3d示例
生活随笔
收集整理的這篇文章主要介紹了
Halcon学习笔记:xyz_attrib_to_object_model_3d示例
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Halcon學(xué)習(xí)筆記:xyz_attrib_to_object_model_3d——從X、Y和Z圖像中創(chuàng)建3D對(duì)象模型同時(shí)附加屬性
xyz_attrib_to_object_model_3d.hdev
- This example program shows the usage of the procedure
- xyz_attrib_to_object_model_3d.
- It can be used to create 3D object models from X, Y and Z images,
- and simultaneously attach attributes to every point.
- 這個(gè)示例程序展示了 xyz_attrib_to_object_model_3d 算子的用法。
- 它可以用于從X、Y和Z圖像中創(chuàng)建3D對(duì)象模型,并同時(shí)將屬性附加到每個(gè)點(diǎn)上。
源碼
* 初始化 dev_update_off () dev_close_window () * * Read the digital surface model. * 1、讀取數(shù)字表面模型 read_image (Z, 'mreut_dgm_2.0.tif') get_image_size (Z, Width, Height) * * 2、讀取包含灰色值的圖像,這些灰色值將作為屬性添加到3D對(duì)象模型中 read_image (AerialImage, 'mreut4_3.png') * * Generate a label image with a second attribute. * In this case, we label different terrain types very simply, just for demonstration purposes. * 3、用第二個(gè)屬性生成標(biāo)簽圖像。 * 在這種情況下,我們很簡(jiǎn)單的為不同的地形類型標(biāo)記,只是為了演示。* 1)將區(qū)域轉(zhuǎn)換為標(biāo)簽圖像 auto_threshold (AerialImage, Regions, 4) region_to_label (Regions, LabelImage, 'byte', Width, Height) * * Create a multichannel image from both attribute images. * 4、從兩個(gè)屬性圖像中創(chuàng)建一個(gè)多通道圖像 compose2 (AerialImage, LabelImage, MultiChannelAttribImage) * * Create images that contain X and Y coordinates in a regular grid. * For a simple gray ramp, the input parameters of gen_image_surface_first_order are very simple: * 5、在常規(guī)網(wǎng)格中創(chuàng)建包含X和Y坐標(biāo)的圖像。對(duì)于一個(gè)簡(jiǎn)單的灰色漸變,gen_image_surface_first_order 的輸入?yún)?shù)非常簡(jiǎn)單:* 1)用一階多項(xiàng)式創(chuàng)建兩個(gè)傾斜(減變)的灰色表面(X Y) GroundResolution := 2.0 gen_image_surface_first_order (X, 'real', 0, GroundResolution, 0, 0, 0, Width, Height) gen_image_surface_first_order (Y, 'real', -GroundResolution, 0, 0, 0, 0, Width, Height) * * The following procedure creates a 3D object model from * the X, Y and Z image and adds the information contained in the attribute image to each point. * 6、下面的過(guò)程從X、Y和Z圖像中創(chuàng)建一個(gè)3D對(duì)象模型,并將屬性圖像中包含的信息添加到每個(gè)點(diǎn)* 1)將3D點(diǎn)從圖像轉(zhuǎn)換為3D對(duì)象模型,并向?qū)ο竽P偷狞c(diǎn)添加擴(kuò)展屬性。(gray 灰度 + terrain 地形:添加兩個(gè)通道進(jìn)去) AttribName := ['&gray','&terrain'] xyz_attrib_to_object_model_3d (X, Y, Z, MultiChannelAttribImage, AttribName, ObjectModel3D) * * 7、顯示結(jié)果 * 1)顯示“地形類型” dev_open_window (Height / 2, 0, Width / 2, Height / 2, 'black', WindowHandle1) dev_set_part (0, 0, Height - 1, Width - 1) set_display_font (WindowHandle1, 16, 'mono', 'true', 'false') dev_set_color (['red','green','blue']) dev_set_draw ('fill') dev_display (Regions) disp_message (WindowHandle1, 'Terrain types', 'window', 12, 12, 'black', 'true')* 2)顯示“鳥(niǎo)瞰圖” dev_open_window (0, 0, Width / 2, Height / 2, 'black', WindowHandle2) set_display_font (WindowHandle2, 16, 'mono', 'true', 'false') dev_display (AerialImage) disp_message (WindowHandle2, 'Aerial image', 'window', 12, 12, 'black', 'true')* 3)顯示“數(shù)字表面模型” dev_open_window (0, Width / 2 + 8, Width, Height, 'gray', WindowHandle3) set_display_font (WindowHandle3, 16, 'mono', 'true', 'false') dev_display (Z) disp_message (WindowHandle3, 'Digital surface model', 'window', 12, 12, 'black', 'true') disp_continue_message (WindowHandle3, 'black', 'true') stop () * * Perform fast triangulation of the object model for better visualization. * 8、對(duì)對(duì)象模型進(jìn)行快速的三角測(cè)量,以便更好地進(jìn)行可視化。* 1)為某個(gè)操作準(zhǔn)備一個(gè)3D對(duì)象模型(此操作為segmentation分割) prepare_object_model_3d (ObjectModel3D, 'segmentation', 'true', [], []) * Visualize 3d object model interactively * 9、交互式地可視化3d對(duì)象模型 create_pose (-620, -85, 17000, 135, 2, 10, 'Rp+T', 'gba', 'point', Pose) Instructions := 'Rotate: Left button' Instructions[1] := 'Zoom: Shift + left button' Instructions[2] := 'Move: Ctrl + left button'* 1)創(chuàng)建使用了屬性為:"&gray"的可視化的3D模型 visualize_object_model_3d (WindowHandle3, ObjectModel3D, [], Pose, ['color_attrib','color_attrib_start','color_attrib_end'], ['&gray',0,255], ['Created 3D model','Attribute used for visualization: \'&gray\''], [], Instructions, PoseOut)* 2)創(chuàng)建使用了屬性為:"&terrain"的可視化的3D模型屬性: visualize_object_model_3d (WindowHandle3, ObjectModel3D, [], PoseOut, ['color_attrib','lut'], ['&terrain','color1'], ['Created 3D model','Attribute used for visualization: \'&terrain\''], [], Instructions, PoseOut) disp_end_of_program_message (WindowHandle3, 'black', 'true') stop () * clear_object_model_3d (ObjectModel3D)結(jié)果:
1、獲得兩個(gè)屬性的多通道圖像
2、創(chuàng)建 X Y 圖像,灰度值變化方向如圖:
3、結(jié)果顯示
4、驗(yàn)證結(jié)果:
總結(jié)
以上是生活随笔為你收集整理的Halcon学习笔记:xyz_attrib_to_object_model_3d示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: tf.nn.embedding_look
- 下一篇: 使用python的butter带通滤波器