Analysis of a small case of a halcon grasping edge fitting straight line

Source: Internet
Author: User

Example diagram:

Complete algorithm:

1Read_image (Image,'C:/users/administrator/desktop/1.png') 2Threshold (Image, regions,0, the) 3 4  Skeleton (Regions,triangleskeleton) 5 6 gen_contours_skeleton_xld (triangleskeleton,trianglecontours,1, ' filter ') 7 8 segment_contours_xld (trianglecontours,contourssplit, ' Lines_circles ', 5, 4, 2) 9 Ten select_contours_xld (contourssplit,selectedcontours, ' contour_length ', 999, -0.5, 0.5) One  A  fit_line_contour_xld (selectedcontours, ' Tukey ',-1, ten, 5, 2, Rowbegin, Colbegin, Rowend, Colend, N R, Nc, Dist)   -  -*calculation of three angles theAngle_ll (rowbegin[0], colbegin[0], rowend[0], colend[0], rowbegin[1], colbegin[1], rowend[1], colend[1], Angle1) -Angle_ll (rowbegin[0], colbegin[0], rowend[0], colend[0], rowbegin[2], colbegin[2], rowend[2], colend[2], Angle2) -Angle_ll (rowbegin[1], colbegin[1], rowend[1], colend[1], rowbegin[2], colbegin[2], rowend[2], colend[2], Angle3) -  +angle1:=ABS (deg (ANGLE1)) -angle2:=ABS (deg (ANGLE2)) +angle3:=ABS (deg (ANGLE3)) A  at Dev_display (Image) - Dev_display (selectedcontours) -Disp_message (3600,'angle:'+ Angle1 +'°,'+ Angle2 +'°,'+ Angle3 +'°','Image', -, -,'Red','true')

Results:

Step Analysis:

① image triangle is mainly composed of 3 straight lines;

threshold, skeleton extract skeleton, the skeleton (region) to Xld, the xld break split, filter XLD get 3 main xld, the 3 xld to be synthesized 3 straight lines .

Effect Analysis:

Although the procedure is simple, the robustness is not good. The main risk in the " screening xld get 3 main xld" This step, sometimes, it can not be accurately screened to the xld we want, so that the exact fitting of the back will not be able to talk about.

Used Visionpro know, visionpro it has the edge of the caliper tool, it directly acting on the image, simple analysis will know that the robustness is much better. Unfortunately, Halcon does not provide a similar tool directly, but there is a great God on the Web Halcon his own caliper tool--rake function.

Unless the line features a particularly obvious picture, it is not recommended to use this example of the algorithm to grab edge, similar to Rake's grasp tool better robustness, edge-grasping ability is also stronger.

Of course, if you are patient enough, you can also design your own grab tool (function) based on this example and Halcon's measurement (Measure) assistant .

Analysis of a small case of a halcon grasping edge fitting straight line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.