跟我学机器视觉--example.doc_第1页
跟我学机器视觉--example.doc_第2页
跟我学机器视觉--example.doc_第3页
跟我学机器视觉--example.doc_第4页
跟我学机器视觉--example.doc_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

HALCON学习例程中文-IC引脚测量路径-C:ProgramFilesMVTecHALCON-10.0exampleshdevelopApplicationsMeasuring-2Dmeasure_pin.hdev Lead Measurement: Example for the application of the measure object including a lot of visualization operators. First, the length of the leads is measured, then, their width and distance from each other. First, read in the image and initialize the programRead_image (Image, icpin)*取得图像第一通道的指针,同时得到图像宽度高度*Get_image_pointer1 (Image, Pointer, Type, Width, Height)*get_image_pointer1 ( Image : : : Pointer, Type, Width, Height ) ;获得图像的数据。如:类型(= 字节, ,uint2 int2 等等) 和图像的尺寸( 的宽度和高度)Dev_close_window ()dev_close_window ( : : : ) 关闭活跃的图形窗口。Dev_open_window_fit_image (Image, 0, 0, 509, 509, WindowHandle)设置窗口自适应图片,获得句柄Set_display_font (WindowHandle, 14, mono, true, false)内部程序,设置字体dev_display (Image)*显示图像如下:* Define and display the rectangular ROIs within which the edges will be detected /ROI设置Dev_set_draw (margin)Dev_se_tline_width (3)Row := 55RowBottom := 955Column := 200Phi := rad(-90)Length1 := 50Length2 := 35devsetcolor (gray)gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)gen_rectangle2 (Rectangle, RowBottom, Column, Phi, Length1, Length2)创建ROI的矩形显示区域 *测量位置如绿色矩形所示下:*Disp_continue_message (WindowHandle, black, true)显示继续信息stop () Create a measure object for the ROI at the top of the image.*获取一阶灰度剖面图的插值方法,测量矩形框与图像坐标系之间有角度时生效*Interpolation := nearest_neighbor*生成测量矩形框,先测上部*Gen_measure_rectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, Interpolation, MeasureHandle) Determine all edges and calculate the lead height at the top of the image/垂直与矩形的直线边缘的提取。Sigma := 1.0Threshold := 30Transition := allSelect := all*进行测量*measure_pos (Image, MeasureHandle, Sigma, Threshold, Transition, Select, RowEdge, ColumnEdge, Amplitude, Distance)提取与矩形或环状弧垂直的直线边缘。LeadLength1 := Distance Display the resultsdevsetcolor (white)*将测量结果画出*disp_line (WindowHandle, RowEdge, ColumnEdge-Length2, RowEdge, ColumnEdge+Length2)disp_message (WindowHandle, Lead Length: +LeadLength1$.2f, window, RowEdge1+40, ColumnEdge1+100, yellow, false)程序写入文本信息 Shift the measure object and determine the lead height at the bottom of the image*转移测量框至新的参考坐标点,及测量下部*translate_measure (MeasureHandle, RowBottom, Column)*进行测量*measure_pos (Image, MeasureHandle, Sigma, Threshold, Transition, Select, RowEdge, ColumnEdge, Amplitude, Distance)LeadLength2 := Distance Display the resultsdevsetcolor (white) *将测量结果画出*disp_line (WindowHandle, RowEdge, ColumnEdge-Length2, RowEdge, ColumnEdge+Length2)disp_message (WindowHandle, Lead Length: +LeadLength2$.2f, window, 360, ColumnEdge1+100, red, false) Close the measureclose_measure (MeasureHandle)清除一个测试对象。Disp_continue_message (WindowHandle, black, true)等待用户操作是否继续stop () Now, define and display a rectangular ROI perpendicular to the leads and create the measuredev_display (Image)Row := 47Column := 485Phi := 0Length1 := 420Length2 := 8Interpolation := nearest_neighbordevsetcolor (black) *创建新的测量矩形ROI,如图蓝色矩形:*gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)创建ROI矩形gen_measure_rectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, Interpolation, MeasureHandle)垂直与矩形的直线边缘的提取。 Determine all edge pairs that have a negative transition, i.e., edge pairs that enclose dark regions.Sigma := 1.0Threshold := 30Transition := negativeSelect := all*进行测量计算并显示结果*measure_pairs (Image, MeasureHandle, Sigma, Threshold, Transition, Select, RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)提取测量与矩形或环状弧垂直的直线边缘。dispcontinuemessage (WindowHandle, black, true)stop ()devsetcolor (white)disp_line (WindowHandle, RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond)avgLeadWidth := sum(IntraDistance)/|IntraDistance|avgLeadDistance := sum(InterDistance)/|InterDistance|numLeads := |IntraDistance|disp_message (WindowHandle, Number of Leads: +numLeads, window, 200, 100, yellow, false)disp_message (WindowHandle, Average Lead Width: +avgLeadWidth$.2f, window, 260, 100, yellow, false)disp_message (WindowHandle, Average Lead Distance: +avgLeadDistance$.2f, window, 320, 100, yellow, false)信息显示dispcontinuemessage (WindowHandle, black, true)dispcontinuemessage (WindowHandle, black, true)stop () Zoom in to visualize the measurement results in more detail. First, define and display the zoom window.Row1 := 0Column1 := 600Row2 := 100Column2 := 700devsetcolor (blue)*设置放大区域矩形并显示,图中绿色矩形*disp_rectangle1 (WindowHandle, Row1, Column1, Row2, Column2)显示和坐标轴对齐的矩形。dispcontinuemessage (WindowHandle, black, true)stop () Then, zoom the image and display the results.*设置图像放大区域并显示*Dev_set_part (Row1, Column1, Row2, Column2)修改显示图像部分。dev_display (Image) dev_set_color (black) *画出测量矩形ROI和测得的边缘如图*dev_display (Rectangle)pdispedge_marker (RowEdgeFirst, ColumnEdgeFirst, Phi, 5, white, 3, WindowHand

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论