************************************************************************* Example for Surface-Based 3D Matching
** This example shows Surface-Based 3D Matching on data taken with a
* Time-of-flight camera(TOF/PMD).* The model for the matching is created from a reference view of the
* object, i.e., no CAD model is used.* The created model is then searched for in a number of 3D scenes.** The example demonstrates how to use the operators
* xyz_to_object_model_3d,* create_surface_model, and
* find_surface_model.*************************************************************************** Initialization
dev_update_off()gen_empty_obj(EmptyObject)
ImagePath :='time_of_flight/'dev_close_window()************************************************************************** Offline-Phase: Model generation from a reference XYZ Image
************************************************************************** Load the XYZ images with the reference object
* 读取图片
read_image(Image, ImagePath +'engine_cover_xyz_01')* 分成3通道
decompose3(Image, Xm, Ym, Zm)* Remove the background plane
* 阈值处理
threshold(Zm, ModelZ,0,650)* Find connected regions
* 分割
connection(ModelZ, ConnectedModel)* Select the regions for the ROI of the reference model
* 选择物体
select_obj(ConnectedModel, ModelROI,[10,9])* 进行联合
union1(ModelROI, ModelROI)* Create the ROI
* 裁剪获取Xm
reduce_domain(Xm, ModelROI, Xm)** Display model image and ROI
dev_open_window_fit_image(Zm,0,0,-1,-1, WindowHandle)set_display_font(WindowHandle,14,'mono','true','false')dev_display(Zm)dev_set_line_width(2)dev_set_draw('margin')dev_set_color('green')dev_display(ModelROI)disp_message(WindowHandle,'Create surface model from XYZ image region','window',12,12,'black','true')disp_continue_message(WindowHandle,'black','true')stop()dev_clear_window()** Create the surface model from the reference view
* 将3D点转换为3D模型
xyz_to_object_model_3d(Xm, Ym, Zm, ObjectModel3DModel)visualize_object_model_3d(WindowHandle, ObjectModel3DModel,[],[],[],[],[],[],[], PoseOut1)* 创建匹配模型
create_surface_model(ObjectModel3DModel,0.03,[],[], SFM)** Display the model
Instructions[0]:='Rotate: Left button'
Instructions[1]:='Zoom: Shift + left button'
Instructions[2]:='Move: Ctrl + left button'*
Message :='Surface model'visualize_object_model_3d(WindowHandle, ObjectModel3DModel,[],[],[],[], Message,[], Instructions, PoseOut)************************************************************************** Online-Phase: Match the reference object in 3D scenes
*************************************************************************
NumImages :=10for Index :=2 to NumImages by 1***************************************** Acquire scene
***************************************** Load the XYZ Images
read_image(Image, ImagePath +'engine_cover_xyz_'+ Index$'02')decompose3(Image, X, Y, Z)* Remove the background plane to increase the speed and
* robustness of the surface-based matching
threshold(Z, SceneGood,0,666)reduce_domain(X, SceneGood, XReduced)xyz_to_object_model_3d(XReduced, Y, Z, ObjectModel3DSceneReduced)****************************************** Match: Find the reference model in the
*3D scene
****************************************count_seconds(T0)find_surface_model(SFM, ObjectModel3DSceneReduced,0.05,0.3,0.2,'true','num_matches',10, Pose, Score, SurfaceMatchingResultID)count_seconds(T1)
TimeForMatching :=(T1 - T0)*1000****************************************** Display: Visualize the result(s)***************************************** Prepare the visualization of the result(s)
ObjectModel3DResult :=[]for Index2 :=0 to |Score|-1 by 1if(Score[Index2]<0.11)continue
endif
* 获取位姿
CPose := Pose[Index2 *7:Index2 *7+6]* 放射运算
rigid_trans_object_model_3d(ObjectModel3DModel, CPose, ObjectModel3DRigidTrans)
ObjectModel3DResult :=[ObjectModel3DResult,ObjectModel3DRigidTrans]
endfor
*visualize_object_model_3d(WindowHandle, ObjectModel3DRigidTrans,[], Pose,[],[],[],[],[], PoseOut2)*xyz_to_object_model_3d(X, Y, Z, ObjectModel3DScene)** Visualize matching scene and key points
Message :='Original scene points (white)'
Message[1]:='Sampled scene points (cyan)'
Message[2]:='Key points (yellow)'* 获取采样场景
get_surface_matching_result(SurfaceMatchingResultID,'sampled_scene',[], SampledScene)* 获取关键点
get_surface_matching_result(SurfaceMatchingResultID,'key_points',[], KeyPoints)dev_clear_window()visualize_object_model_3d(WindowHandle,[ObjectModel3DScene,SampledScene,KeyPoints],[],[],['color_'+[0,1,2],'point_size_'+[0,1,2]],['gray','cyan','yellow',1.0,3.0,5.0], Message,[], Instructions, PoseOut)** Visualize result(s)
Message :='Scene: '+ Index
Message[1]:='Found '+|ObjectModel3DResult|+' object(s) in '+ TimeForMatching$'.3'+' ms'
ScoreString :=sum(Score$'.2f'+' / ')
Message[2]:='Score(s): '+ ScoreString{0:strlen(ScoreString)-4}
NumResult :=|ObjectModel3DResult|tuple_gen_const(NumResult,'green', Colors)tuple_gen_const(NumResult,'circle', Shapes)tuple_gen_const(NumResult,3, Radii)
Indices :=[1:NumResult]*dev_clear_window()*显示匹配结果
visualize_object_model_3d(WindowHandle,[ObjectModel3DScene,ObjectModel3DResult],[], PoseOut,['color_'+[0,Indices],'point_size_0'],['gray',Colors,1.0], Message,[], Instructions, PoseOut)****************************************** Clear: Free result(s) 清除句柄
****************************************clear_object_model_3d(ObjectModel3DSceneReduced)clear_object_model_3d(ObjectModel3DScene)clear_object_model_3d(ObjectModel3DResult)clear_object_model_3d(SampledScene)clear_object_model_3d(KeyPoints)clear_surface_matching_result(SurfaceMatchingResultID)
endfor
clear_object_model_3d(ObjectModel3DModel)clear_surface_model(SFM)
近日,阿里云人工智能平台PAI与华南理工大学金连文教授团队合作,在自然语言处理顶级会议EMNLP 2024 上发表论文《VideoCLIP-XL: Advancing Long Description Understanding for Video CLIP Models》。该工作提出了一个名为VideoCLIP-XL的视频CLIP模型&…