怎么用ps做网站首页图片,外国人可以在中国做网站吗,重庆装修公司网站建设,包小盒设计网站官网文章目录 前言在MainWindow.xaml里面导入Halcon命名空间WPF简单调用Halcon创建矩形简单调用导出脚本函数 正确显示匹配效果 前言
本章会简单讲解如何调用Halcon组件和接口#xff0c;因为我们是进行混合开发模式。即核心脚本在平台调试#xff0c;辅助脚本C#直接调用。
在M… 文章目录 前言在MainWindow.xaml里面导入Halcon命名空间WPF简单调用Halcon创建矩形简单调用导出脚本函数 正确显示匹配效果 前言
本章会简单讲解如何调用Halcon组件和接口因为我们是进行混合开发模式。即核心脚本在平台调试辅助脚本C#直接调用。
在MainWindow.xaml里面导入Halcon命名空间 Window x:ClassHello_Halcon.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:Hello_Halconxmlns:halconclr-namespace:HalconDotNet;assemblyhalcondotnetmc:IgnorabledTitleMainWindow Height450 Width800GridGrid.RowDefinitionsRowDefinition Heightauto/RowDefinition //Grid.RowDefinitions!--添加Halcon图像导入事件--Button ClickButton_Click Content加载图像/!--添加Halcon窗口--halcon:HSmartWindowControlWPF Grid.Row1 x:NamehSmart//Grid
/Window
按钮事件
private void Button_Click(object sender, RoutedEventArgs e)
{//添加文件路径string fileName D:\\workspace\\program\\Halcon\\Images\\1.png\;var image new HImage(fileName);int width, height;image.GetImageSize(out width, out height);hSmart.HalconWindow.SetPart(0,0,width,height);hSmart.HalconWindow.DispObj(image);//自适应屏幕hSmart.SetFullImagePart();}如果编译报错 安装System.Drawing.Common 如果出现上面问题记得看看有没有写hSmart.SetFullImagePart();
完美解决在我这篇文章中 Halcon WPF 开发学习笔记HSmartWindowControlWPF正常加载 WPF简单调用Halcon
添加两个按钮 Window.ResourcesStyle TargetTypeButton x:KeyMarginButtonSetter PropertyMargin Value3 //Style
/Window.Resources
GridGrid.RowDefinitionsRowDefinition Heightauto /RowDefinition //Grid.RowDefinitions!--添加Halcon图像导入事件--StackPanel OrientationHorizontalButton ClickButton_Click Content加载图像Style{StaticResource MarginButton} /Button ClickButton_Click_1 Content创建圆形Style{StaticResource MarginButton} /Button ClickButton_Click_2 Content创建矩形Style{StaticResource MarginButton} //StackPanel!--添加Halcon窗口--halcon:HSmartWindowControlWPF Grid.Row1 x:NamehSmart /
/Grid添加按钮事件 /// summary/// 画圆/// /summary/// param namesender/param/// param namee/paramprivate void Button_Click_1(object sender, RoutedEventArgs e){//创建一个圆形圆心为(100,100)半径为50var drawingObject HDrawingObject.CreateDrawingObject(HDrawingObject.HDrawingObjectType.CIRCLE, new HTuple[] { 100, 100, 50 });//临时存放ListdrawingObjects.Add(drawingObject);//将圆画再hSmart画布上面hSmart.HalconWindow.AttachDrawingObjectToWindow(drawingObject);}实现效果 这个圆是可以拖动的
创建矩形
和创建圆形一致不再说明
private void Button_Click_2(object sender, RoutedEventArgs e)
{//创建一个矩形var drawingObject HDrawingObject.CreateDrawingObject(HDrawingObject.HDrawingObjectType.RECTANGLE1, new HTuple[] { 100, 100, 150,250 });//临时存放ListdrawingObjects.Add(drawingObject);//将矩形再hSmart画布上面hSmart.HalconWindow.AttachDrawingObjectToWindow(drawingObject);
}简单调用导出脚本函数 这个只是简单的导入脚本不是二次开发。而且打开的窗体是无法关闭的。接下来我会讲解如何使用WPF进行二次开发。
正确显示匹配效果
因为我们直接.net 导出的脚本是不能直接用的用的时候会弹出一个窗体。我们希望能直接再原窗体上使用 private void Button_Click(object sender, RoutedEventArgs e)
{//添加文件路径string fileName Resources\\1.png;var image new HImage(fileName);int width, height;image.GetImageSize(out width, out height);//绘制图片hSmart.HalconWindow.DispObj(image);//获取halcon脚本返回值TemplateService templateService new TemplateService();var res templateService.Action();//绘制十字锚点hSmart.HalconWindow.SetLineWidth(2);hSmart.HalconWindow.SetColor(red);hSmart.HalconWindow.DispCross(res.row,res.column,10,0);}