opt光源控制部分

news/2024/10/30 19:34:43/

opt光源通过串口无法进行控制打开和关闭通道。只能修改光强部分。

软件部分实现控制的话通过服务器发送指令进行打开关闭。

binary_threshold (Image, Region, 'smooth_histo', 'light', UsedThreshold)

connection (Region, ConnectedRegions)
*closing_rectangle1 (ConnectedRegions, RegionClosing, 45,45)
*opening_rectangle1 (ConnectedRegions, RegionOpening, 30, 30)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 1500, 99999)
area_center (SelectedRegions, Area, Row, Column)
orientation_region (SelectedRegions, Phi2)
vector_angle_to_rigid (Row, Column, Phi2, Row, Column, Phi2, HomMat2D)
affine_trans_region (SelectedRegions, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
*gen_contour_region_xld (RegionAffineTrans, Contours, 'border')
smallest_rectangle2(RegionAffineTrans,Row, Column, Phi, Length1, Length2)
gen_rectangle2_contour_xld (Rectangle,Row, Column, Phi, Length1, Length2)
orientation_region(RegionAffineTrans, Phi11)
get_contour_xld (Rectangle, Row6, Col6)
gen_cross_contour_xld (Cross2, Row, Column, 6, Phi)
*orientation_region (RegionAffineTrans, Phi1)
*gen_cross_contour_xld (Cross1, Row6, Col6, 60, Phi)
if(abs(deg(Phi))>45)
    Phi:=rad(deg(Phi)-90*(Phi/abs(Phi)))
    Tmp:=Length1
    Length1:=Length2
    Length2:=Tmp
endif
tuple_sin (Phi, Sin)
tuple_cos (Phi, Cos)

*左上角
TopLeft_X := -Length1*Cos - Length2*Sin
TopLeft_Y := -Length1*Sin + Length2*Cos
TopLeft_Row := Row - TopLeft_Y 
TopLeft_Col := Column + TopLeft_X 

*右上角
TopRight_X := Length1*Cos - Length2*Sin
TopRight_Y := Length1*Sin + Length2*Cos
TopRight_Row := Row - TopRight_Y 
TopRight_Col := Column + TopRight_X 

*右下角
LowerRight_X := Length1*Cos + Length2*Sin
LowerRight_Y := Length1*Sin - Length2*Cos
LowerRight_Row := Row - LowerRight_Y 
LowerRight_Col := Column + LowerRight_X 
 
*左下角
LowerLeft_X := -Length1*Cos + Length2*Sin
LowerLeft_Y := -Length1*Sin - Length2*Cos
LowerLeft_Row := Row - LowerLeft_Y 
LowerLeft_Col := Column + LowerLeft_X 

 affine_trans_pixel (HomMat2D, TopLeft_Row, TopLeft_Col, RowTrans, ColTrans)
 affine_trans_pixel (HomMat2D, LowerLeft_Row, LowerLeft_Col, RowTrans1, ColTrans1)
gen_region_line (RegionLines3, RowTrans, ColTrans, RowTrans1, ColTrans1)
LinePara:=[RowTrans, ColTrans, RowTrans1, ColTrans1]

dev_display (RegionLines3)
*测试
*边缘强度
MeasureThreshold:=100
*创建卡尺句柄
create_metrology_model (MetrologyHandle)
*设置被测图尺寸
set_metrology_model_image_size (MetrologyHandle, 120, 40)
*添加直线模型,卡尺尺寸设定,边缘强度设定
add_metrology_object_line_measure (MetrologyHandle,RowTrans, ColTrans, RowTrans1, ColTrans1, 20, 5, 1, 30, [], [], Index)
*add_metrology_object_generic (MetrologyHandle, 'line', LinePara, 20, 3, 1, 40, [], [], Index)
set_metrology_object_param (MetrologyHandle, 'all', 'num_measures',6)
*set_metrology_object_param (MetrologyHandle, 'all', 'num_instances', 1)
*set_metrology_object_param (MetrologyHandle, 'all', 'measure_sigma', 1)
*set_metrology_object_param (MetrologyHandle, 'all', 'measure_threshold',15)
*set_metrology_object_param (MetrologyHandle, 'all', 'measure_interpolation', 'bicubic')
*set_metrology_object_param (MetrologyHandle, 'all', 'measure_select', 'all')
*set_metrology_object_param (MetrologyHandle, 'all', 'min_score', 0.7)
*执行测量
apply_metrology_model (Image, MetrologyHandle)
*获取测量Contours
get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row3, Column3)
*gen_cross_contour_xld (Cross1, Row3, Column3, 3, 0)
*dev_display (Contours)
*获取测量数据
get_metrology_object_result (MetrologyHandle, 'all', 'all', 'result_type', 'all_param', Parameter)
*获取测量直线
get_metrology_object_result_contour (Contour, MetrologyHandle,'all', 'all', 1.5)
*获取直线的两个端点
*smallest_rectangle1_xld (Contour, Row4, Column4, Row21, Column21)

*angle_lx ( Row4, Column4, Row21, Column21, Angle)
*andle:=deg(Angle)
*显示 交点
*gen_cross_contour_xld (Cross, Row21, Column21, 3, Phi+rad(30))
dev_display (Image)
dev_set_color ('red')
dev_display (Contour)
dev_display (Contours)
dev_display (Cross2)


http://www.ppmy.cn/news/347938.html

相关文章

Sui x KuCoin Labs夏季黑客松|本周Workshop预告

由Sui和KuCoin Labs联合主办的夏季黑客松正如火如荼的报名中。了解黑客松详情:Sui与KuCoin Labs联合推出夏季黑客松,奖池高达28.5万美金! 👉 黑客松官方网站:Sui x KuCoin Labs Summer Hackathon | Sui x KuCoin Labs…

【Linux 学习 ①】- Linux 环境搭建

目录 一、GouMai 云服务器 二、使用 Xshell 远程登录服务器 三、编写一个 C 程序 四、多用户共享同一个服务器 一、GouMai 云服务器 我们以腾讯云为例(购买其他厂商的云服务器,例如:华为云、阿里云,其操作也是类似的&#…

Visual Studio Professional 2015 简体中文专业版

Visual Studio Professional 2015 简体中文专业版 专业版激活密钥:HMGNV-WCYXV-X7G9W-YCX63-B98R2 http://download.microsoft.com/download/B/8/9/B898E46E-CBAE-4045-A8E2-2D33DD36F3C4/vs2015.pro_chs.iso

office 2016安装包下载

伙伴们,今天给大家带来一个office 2016的安装包。 百度云下载 提取码:gho0 记得点赞。

Visual Studio Enterprise 2015简体中文版(企业版)

Visual Studio Enterprise 2015简体中文版(企业版) KEY:HM6NR-QXX7C-DFW2Y-8B82K-WTYJV

Visual Studio 2015下载地址

Visual Studio 2015下载地址: VS2015 专业版下载链接 http://download.microsoft.com/download/B/8/9/B898E46E-CBAE-4045-A8E2-2D33DD36F3C4/vs2015.pro_chs.iso VS2015 企业版下载链 http://download.microsoft.com/download/B/8/F/B8F1470D-2396-4E7A-83F5-AC0…

Windows10下安装vs2013旗舰版(Visual Studio 2013 Ultimate)

本此次安装选用环境是"windows10 专业版",选用的版本包是 "Visual Studio 2013 Ultimate for blend",安装过程有一点小插曲,不过最后还是解决的。 下载的vs2013是镜像版,我用UltraISO加载到虚拟光驱运行&…

微软正式提供Visual Studio 2013正式版下载(附直接链接汇总)

转自 http://www.iruanmi.com/visual-studio-2013/ 微软已经向MSDN订阅用户提供了Visual Studio 2013正式版镜像下载,不过非MSDN用户可以在微软的Visual Studio 2013官方网站上下载到正式版镜像(通过下载专业版本,已验证与MSDN版本一致&…