您的位置:首页 > 编程语言 > Delphi

zw版【转发·台湾nvp系列Delphi例程】HALCON 3D Position Of Circles

2015-10-01 16:21 525 查看
zw版【转发·台湾nvp系列Delphi例程】HALCON 3D Position Of Circles



procedure TForm1.action();
var
ho_Image, ho_EllipseContoursLarge : HUntypedObjectX;
ho_EllipseContoursSmall, ho_EllipseContours : HUntypedObjectX;
hv_Width, hv_Height : OleVariant;
hv_WindowHandle, hv_NumberLarge : OleVariant;
hv_NumberSmall, hv_RadiusLarge : OleVariant;
hv_RadiusSmall, hv_CamParam : OleVariant;
hv_Pose1, hv_Pose2, hv_CenterNormal1 : OleVariant;
hv_CenterNormal2, hv_ClusterP1 : OleVariant;
hv_ClusterP2, hv_ClusterCN1 : OleVariant;
hv_ClusterCN2, hv_HomMat3D : OleVariant;
hv_i : Longint;
hv_Qx, hv_Qy, hv_Qz : OleVariant;
hv_Row, hv_Column : OleVariant;
val1, val2 : double;
begin
hv_WindowHandle := HWindowXCtrl1.HalconWindow.HalconID;
Op.ReadImage(ho_Image, 'rim');
Op.GetImageSize(ho_Image, hv_Width, hv_Height);
Op.SetPart(hv_WindowHandle, 0, 0, hv_Height - 1, hv_Width - 1);
set_display_font(hv_WindowHandle, 16, 'courier', 'true', 'false');
Op.DispObj(ho_Image, hv_WindowHandle);
Op.SetLineWidth(hv_WindowHandle, 3);
p_determine_ellipse_contours(hv_WindowHandle, ho_Image, ho_EllipseContoursLarge, ho_EllipseContoursSmall, 0, hv_NumberLarge, hv_NumberSmall);
Op.ConcatObj(ho_EllipseContoursLarge, ho_EllipseContoursSmall, ho_EllipseContours);
hv_RadiusLarge := Tuple.TupleDiv(10.25, 1000.0);
hv_RadiusSmall := Tuple.TupleDiv(5.91, 1000.0);
val1 := 0.00000739;
val2 := 0.0000074;
hv_CamParam := Tuple.TupleConcat(Tuple.TupleConcat(Tuple.TupleConcat(Tuple.TupleConcat(Tuple.TupleConcat(Tuple.TupleConcat(Tuple.TupleConcat(0.0122, -261.04), val1), val2), 303.12), 234.17), 652), 494);
Op.GetCirclePose(ho_EllipseContours, hv_CamParam, Tuple.TupleConcat(Tuple.TupleGenConst(hv_NumberLarge, hv_RadiusLarge), Tuple.TupleGenConst(hv_NumberSmall, hv_RadiusSmall)), 'pose', hv_Pose1, hv_Pose2);
Op.GetCirclePose(ho_EllipseContours, hv_CamParam, Tuple.TupleConcat(Tuple.TupleGenConst(hv_NumberLarge, hv_RadiusLarge), Tuple.TupleGenConst(hv_NumberSmall, hv_RadiusSmall)), 'center_normal', hv_CenterNormal1, hv_CenterNormal2);
p_cluster_normals(hv_Pose1, hv_Pose2, hv_CenterNormal1, hv_CenterNormal2, hv_ClusterP1, hv_ClusterP2, hv_ClusterCN1, hv_ClusterCN2);
Op.DispObj(ho_Image, hv_WindowHandle);
Op.SetColored(hv_WindowHandle, 12);
Op.DispObj(ho_EllipseContours, hv_WindowHandle);
for hv_i := 0 to Longint(Tuple.TupleSub(Tuple.TupleAdd(hv_NumberLarge, hv_NumberSmall), 1)) do
begin
Op.PoseToHomMat3d(Tuple.TupleSelectRange(hv_ClusterP1, Tuple.TupleMult(hv_i, 7), Tuple.TupleAdd(Tuple.TupleMult(hv_i, 7), 6)), hv_HomMat3D);
Op.AffineTransPoint3D(hv_HomMat3D, 0, 0, 0, hv_Qx, hv_Qy, hv_Qz);
Op.Project3DPoint(hv_Qx, hv_Qy, hv_Qz, hv_CamParam, hv_Row, hv_Column);
hv_Row := Tuple.TupleSub(hv_Row, 95);
hv_Column := Tuple.TupleSub(hv_Column, 60);
disp_message(hv_WindowHandle, Tuple.TupleConcat(Tuple.TupleConcat(Tuple.TupleAdd('X=', Tuple.TupleString(Tuple.TupleSelect(hv_ClusterCN1, Tuple.TupleMult(hv_i, 6)), '6.3f')), Tuple.TupleAdd('Y=', Tuple.TupleString(Tuple.TupleSelect(hv_ClusterCN1, Tuple.TupleAdd(Tuple.TupleMult(hv_i, 6), 1)), '6.3f'))), Tuple.TupleAdd('Z=', Tuple.TupleString(Tuple.TupleSelect(hv_ClusterCN1, Tuple.TupleAdd(Tuple.TupleMult(hv_i, 6), 2)), '6.3f'))), 'window', hv_Row, hv_Column, 'black', 'true');
end;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: