{"id":66139,"date":"2026-01-26T10:17:06","date_gmt":"2026-01-26T02:17:06","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/66139.html"},"modified":"2026-01-26T10:17:06","modified_gmt":"2026-01-26T02:17:06","slug":"halcon%e5%b0%8f%e6%a1%88%e4%be%8b%e5%9f%ba%e4%ba%8e%e7%81%b0%e5%ba%a6%e5%80%bc%e7%9a%84%e6%a8%a1%e6%9d%bf%e5%8c%b9%e9%85%8d%e5%92%8c%e5%9f%ba%e4%ba%8e%e5%bd%a2%e7%8a%b6%e7%9a%84%e6%a8%a1%e6%9d%bf","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/66139.html","title":{"rendered":"Halcon\u5c0f\u6848\u4f8b\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d\u548c\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d"},"content":{"rendered":"<h3>*\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d:<\/h3>\n<h5>\u2022\u83b7\u53d6\u56fe\u7247:read_image ()<\/h5>\n<h5>\u2022\u83b7\u53d6\u53e5\u67c4:dev_get_window()<\/h5>\n<h5>\u2022\u8bbe\u7f6e\u533a\u57df\u586b\u5145\u65b9\u5f0f:dev_set_draw()<\/h5>\n<h5>\u2022\u8bbe\u7f6e\u989c\u8272:dev_set_color()<\/h5>\n<h5>\u2022\u7ed8\u5236\u77e9\u5f62ROI:gen_rectangle1 ()<\/h5>\n<h5>\u2022\u83b7\u53d6\u533a\u57df\u7684\u9762\u79ef\u548c\u4e2d\u5fc3\u70b9\u5750\u6807:area_center ()<\/h5>\n<h5>\u751f\u6210\u5341\u5b57\u5f62\u7684\u4e9a\u50cf\u7d20\u7ea7&#xff08;XLD&#xff09;\u8f6e\u5ed3:gen_cross_contour_xld<\/h5>\n<h5>\u2022\u62a0\u56fe:reduce_domain()<\/h5>\n<h5>\u2022\u521b\u5efa\u5f52\u4e00\u5316\u4e92\u76f8\u5173&#xff08;NCC&#xff09;\u6a21\u677f&#xff08;\u57fa\u4e8e\u7070\u5ea6\u503c&#xff09;:create_ncc_model()<\/h5>\n<h5>\u2022\u521b\u5efa\u4eff\u5c04\u53d8\u6362\u77e9\u9635\u5e76\u4e14\u8ba1\u7b97\u4eff\u5c04\u53d8\u6362\u77e9\u9635:vector_angle_to_rigid()<\/h5>\n<h5>\u2022\u6267\u884c\u4eff\u5c04\u53d8\u6362:affine_trans_contour_xld ()<\/h5>\n<h5>\u2022\u5c55\u793a\u6a21\u677f\u5339\u914d\u7684\u8f6e\u5ed3:dev_display_shape_matching_results()<\/h5>\n<h5>\u2022\u67e5\u627eNCC\u6a21\u677f:find_ncc_model()<\/h5>\n<h5>\u2022\u5bf9\u533a\u57df\u8fdb\u884c\u4eff\u5c04\u53d8\u6362:affine_trans_region()<\/h5>\n<h5>\u2022\u91ca\u653e NCC \u6a21\u677f:clear_ncc_model()<\/h5>\n<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260126021659-6976ce9bb789f.png\" \/><\/p>\n<p>*\/\/ \u83b7\u53d6\u56fe\u7247<br \/>\nread_image (Image, &#039;smd\/smd_on_chip_05.png&#039;)<br \/>\n*\/\/ \u83b7\u53d6\u7a97\u53e3\u53e5<br \/>\ndev_get_window (WindowHandle)<br \/>\n*\/\/ \u8bbe\u7f6e\u7ed8\u5236\u7684\u586b\u5145\u6a21\u5f0f<br \/>\ndev_set_draw (&#039;margin&#039;)<br \/>\n*\/\/ \u989c\u8272<br \/>\ndev_set_color (&#039;green&#039;)<\/p>\n<p>*\/\/ \u7ed8\u5236\u611f\u5174\u8da3\u533a\u57df<br \/>\ngen_rectangle1 (ROI_0, 192.328, 179.323, 430.036, 451.181)<br \/>\n*\/\/ \u83b7\u53d6\u611f\u5174\u8da3\u533a\u57df\u4e2d\u5fc3\u70b9<br \/>\narea_center (ROI_0, Area, Row, Column)<br \/>\n*\/\/ \u751f\u6210\u5341\u5b57\u5f62\u7684\u4e9a\u50cf\u7d20\u7ea7&#xff08;XLD&#xff09;\u8f6e\u5ed3&#xff0c;\u7528\u4e8e\u6807\u8bb0\u56fe\u50cf\u4e2d\u7684\u6307\u5b9a\u5750\u6807\u70b9<br \/>\n*\/\/ \u53c2\u65701 Cross \u8f93\u51fa\u53c2\u6570&#xff0c;\u751f\u6210\u7684\u5341\u5b57\u5f62XLD\u8f6e\u5ed3\u5bf9\u8c61<br \/>\n*\/\/ \u53c2\u65702 Rows \u8f93\u5165\u53c2\u6570&#xff0c;\u5341\u5b57\u5f62\u4e2d\u5fc3\u7684\u884c\u5750\u6807<br \/>\n*\/\/ \u53c2\u65703 Columns \u8f93\u5165\u53c2\u6570&#xff0c;\u5341\u5b57\u5f62\u4e2d\u5fc3\u7684\u5217\u5750\u6807<br \/>\n*\/\/ \u53c2\u65704 Size \u8f93\u5165\u53c2\u6570&#xff0c;\u5341\u5b57\u5f62\u5355\u81c2\u7684\u957f\u5ea6&#xff08;\u50cf\u7d20\u5355\u4f4d&#xff0c;\u59826\u8868\u793a\u6bcf\u4e2a\u81c2\u4ece\u4e2d\u5fc3\u5411\u5916\u5ef6\u4f386\u50cf\u7d20&#xff09;<br \/>\n*\/\/ \u53c2\u65705 Angle \u8f93\u5165\u53c2\u6570&#xff0c;\u5341\u5b57\u5f62\u7684\u65cb\u8f6c\u89d2\u5ea6&#xff08;\u5f27\u5ea6\u5355\u4f4d&#xff0c;0.785398&#061;\u03c0\/4&#061;45\u5ea6&#xff0c;0\u4e3a\u6c34\u5e73\/\u5782\u76f4\u65b9\u5411&#xff09;<br \/>\ngen_cross_contour_xld (Cross, Row, Column, 10, 0)<br \/>\n*\/\/ \u88c1\u526a\u611f\u5174\u8da3\u533a\u57df\u7684\u56fe\u50cf<br \/>\nreduce_domain (Image, ROI_0, ImageReduced)<\/p>\n<p>*\/\/ \u521b\u5efa\u4e00\u4e2a\u6a21\u677f,\u57fa\u4e8e\u7070\u5ea6\u503c<br \/>\n*\/\/ \u53c2\u65701 \u6a21\u677f\u56fe\u7247<br \/>\n*\/\/ \u53c2\u65702 \u91d1\u5b57\u5854\u5c42\u7ea7 \u6bcf\u5c42\u91d1\u5b57\u5854\u4ee3\u8868\u4e00\u79cd\u6a21\u677f\u56fe\u50cf<br \/>\n*\/\/ auto\u81ea\u52a8\u9009\u62e9\u5c42\u7ea7,\u503c\u8d8a\u5927 \u5339\u914d\u901f\u5ea6\u8d8a\u5feb \u53ef\u80fd\u4f1a\u4e22\u5931\u50cf\u7d20;\u503c\u8d8a\u5c0f \u5339\u914d\u7cbe\u5ea6\u8d8a\u9ad8<br \/>\n*\/\/ \u53c2\u65703 \u5f00\u59cb\u89d2\u5ea6 \u5355\u4f4d\u662f\u5f27\u5ea6<br \/>\n*\/\/ \u53c2\u65704 \u7ed3\u675f\u89d2\u5ea6<br \/>\n*\/\/ \u53c2\u65705 \u89d2\u5ea6\u7684\u9012\u589e\u91cf auto<br \/>\n*\/\/ \u53c2\u65706 \u6a21\u677f\u7684\u65b9\u5f0f use_polarity \u4f7f\u7528\u6781\u6027;ignore_global_polarity \u5ffd\u7565\u6781\u6027<br \/>\n*\/\/ \u53c2\u65707 ModelID \u6a21\u677f\u7684id<br \/>\ncreate_ncc_model (ImageReduced, &#039;auto&#039;, rad(-180), rad(180), &#039;auto&#039;, &#039;use_polarity&#039;, ModelID)<\/p>\n<p>*\/\/ \u5bf9\u591a\u5f20\u56fe\u7247\u8fdb\u884c\u67e5\u627e<br \/>\nfor Index :&#061; 1 to 11 by 1<br \/>\n    *\/\/ \u904d\u5386\u83b7\u53d6\u56fe\u7247\u5730\u5740<br \/>\n    path:&#061;&#039;smd\/smd_on_chip_&#039;&#043;Index$&#039;02&#039;&#043;&#039;.png&#039;\/\/$&#039;02&#039;\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u4e0d\u6ee1\u8db3\u4e24\u4f4d\u5728\u5341\u4f4d\u88650<br \/>\n    *\/\/ \u83b7\u53d6\u56fe\u7247<br \/>\n    read_image (Image1, path)<\/p>\n<p>    *\/\/ \u67e5\u627e\u6a21\u677f<br \/>\n    *\/\/ \u53c2\u65701 \u67e5\u627e\u7684\u56fe\u50cf\u6e90<br \/>\n    *\/\/ \u53c2\u65702 \u5bf9\u5e94\u7684\u6a21\u677f ModelID<br \/>\n    *\/\/ \u53c2\u65703\u30014 \u67e5\u627e\u89d2\u5ea6\u8303\u56f4<br \/>\n    *\/\/ \u53c2\u65705 \u6700\u5c0f\u5f97\u5206<br \/>\n    *\/\/ \u53c2\u65706 \u5339\u914d\u7684\u4e2a\u6570 1\u5339\u914d1\u4e2a, 0\u5339\u914d\u591a\u4e2a<br \/>\n    *\/\/ \u53c2\u65707 \u6700\u5927\u7684\u91cd\u53e0\u5ea6 0.5 \u5927\u4e8e0.5\u7684\u8bdd\u4e24\u4e2a\u7269\u54c1\u8c01\u7684\u5f97\u5206\u9ad8\u9009\u8c01<br \/>\n    *\/\/ \u53c2\u65708 SubPixel \u662f\u5426\u4f7f\u7528\u4e9a\u50cf\u7d20\u68c0\u6d4b true\u4f7f\u7528\u4e9a\u50cf\u7d20\u68c0\u6d4b<br \/>\n    *\/\/ \u53c2\u65709 NumLevels \u91d1\u5b57\u5854\u5c42\u7ea7,\u4e00\u822c\u51990,\u4fdd\u7559\u539f\u59cb\u7ec6\u8282,\u4f46\u662f\u8ba1\u7b97\u91cf\u5927<br \/>\n    *\/\/ \u53c2\u657010\u300111 \u8f93\u51fa\u5339\u914d\u70b9\u7684\u5750\u6807<br \/>\n    *\/\/ \u53c2\u657012\u300113 \u8f93\u51fa\u89d2\u5ea6\u548c\u5f97\u5206<br \/>\n    find_ncc_model (Image1, ModelID, rad(-180), rad(180), 0.5, 1, 0.5, &#039;true&#039;, 0, Row1, Column1, Angle, Score)<\/p>\n<p>    *\/\/ \u4eff\u5c04\u53d8\u6362 vector_angle_to_rigid\u521a\u6027\u53d8\u6362 \u751f\u6210\u4e00\u4e2a\u53d8\u6362\u77e9\u9635<br \/>\n    *\/\/ \u53c2\u65701\u3001\u53c2\u65702 \u53d8\u6362\u7684\u8d77\u59cb\u70b9\u4f4d\u7f6e<br \/>\n    *\/\/ \u53c2\u65703 \u65cb\u8f6c\u7684\u8d77\u59cb\u89d2\u5ea6<br \/>\n    *\/\/ \u53c2\u65704\u30015 \u53d8\u6362\u7684\u7ed3\u675f\u70b9\u4f4d\u7f6e<br \/>\n    *\/\/ \u53c2\u65706 \u53d8\u6362\u7684\u7ed3\u675f\u70b9\u7684\u89d2\u5ea6<br \/>\n    *\/\/ \u53c2\u65707 HomMat2D\u53d8\u6362\u77e9\u9635<br \/>\n    vector_angle_to_rigid (Row, Column, 0, Row1, Column1, Angle, HomMat2D)<\/p>\n<p>    *\/\/ \u4f7f\u7528\u53d8\u6362\u77e9\u9635\u5e94\u7528\u5230\u54ea\u4e2a\u533a\u57df\u4e0a<br \/>\n    *\/\/ \u6700\u540e\u4e00\u4e2a\u53c2\u6570 \u5728\u53d8\u6362\u4e4b\u540e\u627e\u4e0d\u5230\u539f\u59cb\u56fe\u50cf\u5bf9\u5e94\u7684\u50cf\u7d20\u7684\u65f6\u5019,\u586b\u5145\u7684\u5904\u7406\u65b9\u5f0f<br \/>\n    *\/\/ nearest_neighbor \u6700\u8fd1\u90bb\u63d2\u503c\u6cd5,\u901f\u5ea6\u5feb\u9002\u5408\u533a\u57df\u53d8\u6362<br \/>\n    *\/\/ biliner \u53cc\u7ebf\u6027\u63d2\u503c\u6cd5 \u7cbe\u5ea6\u66f4\u9ad8<br \/>\n    affine_trans_region (ROI_0, RegionAffineTrans, HomMat2D, &#039;nearest_neighbor&#039;)<br \/>\n    *\/\/ \u7ed8\u5236\u4e00\u4e2a\u5341\u5b57\u5f62\u8f6e\u5ed3<br \/>\n    gen_cross_contour_xld (Cross1, Row1, Column1, 6, Angle)<br \/>\n    *\/\/ \u5c55\u793a\u4eff\u5c04\u53d8\u6362\u4e4b\u540e\u7684\u533a\u57df<br \/>\n    dev_display (RegionAffineTrans)<\/p>\n<p>    *\/\/ \u5224\u65ad\u662f\u5426\u5339\u914d\u5230<br \/>\n    if (|Row1|&gt;0)<br \/>\n        *\/\/ \u5224\u65ad\u5f97\u5206<br \/>\n        if (Score&gt;0.9)<br \/>\n            *\/\/ \u7ed8\u5236\u5339\u914d\u51fa\u7684\u8f6e\u5ed3<br \/>\n            *\/\/ \u6700\u540e\u4e00\u4e2a\u53c2\u6570 0\u9ed8\u8ba4\u5927\u5c0f<br \/>\n*             dev_display_ncc_matching_results (ModelID, &#039;green&#039;, Row1, Column1, Angle, 0)<br \/>\n            dev_disp_text (&#039;OK:&#039;&#043;Score, &#039;window&#039;, Row1, Column1, &#039;black&#039;, [], [])<br \/>\n        else<br \/>\n            *\/\/ \u7ed8\u5236\u5339\u914d\u51fa\u7684\u8f6e\u5ed3<br \/>\n            *\/\/ \u6700\u540e\u4e00\u4e2a\u53c2\u6570 0\u9ed8\u8ba4\u5927\u5c0f<br \/>\n*             dev_display_ncc_matching_results (ModelID, &#039;red&#039;, Row1, Column1, Angle, 0)<br \/>\n            dev_disp_text (&#039;NG:&#039;&#043;Score, &#039;window&#039;, Row1, Column1, &#039;black&#039;, [], [])<br \/>\n        endif<br \/>\n    endif<br \/>\n    *\/\/ \u505c\u6b62\u8fd0\u884c<br \/>\n    stop ()<br \/>\nendfor<br \/>\n*\/\/ \u91ca\u653e\u6a21\u677f<br \/>\nclear_ncc_model (ModelID) <\/p>\n<h3>*\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d:<\/h3>\n<h5>\u2022\u83b7\u53d6\u56fe\u7247:read_image ()<\/h5>\n<h5>\u2022\u83b7\u53d6\u53e5\u67c4:dev_get_window()<\/h5>\n<h5>\u2022\u8bbe\u7f6e\u533a\u57df\u586b\u5145\u65b9\u5f0f:dev_set_draw()<\/h5>\n<h5>\u2022\u8bbe\u7f6e\u989c\u8272:dev_set_color()<\/h5>\n<h5>\u2022\u8bbe\u7f6e\u533a\u57df\u7ebf\u5bbd:dev_set_line_width()<\/h5>\n<h5>\u2022\u7ed8\u5236\u5706\u5f62:draw_circle()<\/h5>\n<h5>\u2022\u62a0\u56fe:reduce_domain()<\/h5>\n<h5>\u5c55\u793a\u56fe\u50cf:dev_display ()<\/h5>\n<h5>\u2022\u521b\u5efa\u652f\u6301\u7f29\u653e\u7684\u5f62\u72b6\u6a21\u677f:create_scaled_shape_model()<\/h5>\n<h5>\u2022\u83b7\u53d6\u5bf9\u5e94\u91d1\u5b57\u5854\u5c42\u7ea7\u7684\u56fe\u50cf:get_shape_model_contours ()<\/h5>\n<h5>\u2022\u521b\u5efa\u4eff\u5c04\u53d8\u6362\u77e9\u9635\u5e76\u4e14\u8ba1\u7b97\u4eff\u5c04\u53d8\u6362\u77e9\u9635:vector_angle_to_rigid()<\/h5>\n<h5>\u2022\u6267\u884c\u4eff\u5c04\u53d8\u6362:affine_trans_contour_xld ()<\/h5>\n<h5>\u2022\u67e5\u627e\u5177\u6709\u7f29\u653e\u53d8\u5316\u7684\u5f62\u72b6\u6a21\u578b:find_scaled_shape_model()<\/h5>\n<h5>\u2022\u5c55\u793a\u6a21\u677f\u5339\u914d\u7684\u8f6e\u5ed3:dev_display_shape_matching_results()<\/h5>\n<h5>\u2022\u6e05\u7a7a\u7a97\u4f53:dev_clear_window ()<\/h5>\n<h5>\u2022\u751f\u6210\u521d\u59cb\u5316\u7684 2D \u9f50\u6b21\u4eff\u5c04\u53d8\u6362\u77e9\u9635&#xff08;\u5355\u4f4d\u77e9\u9635&#xff09;: hom_mat2d_identity()<\/h5>\n<h5>\u2022\u751f\u6210\u5e26\u5e73\u79fb\u7684 2D \u4eff\u5c04\u53d8\u6362\u77e9\u9635:hom_mat2d_translate ()<\/h5>\n<h5>\u2022\u751f\u6210\u5e26\u65cb\u8f6c\u7684 2D \u4eff\u5c04\u53d8\u6362\u77e9\u9635:hom_mat2d_rotate()<\/h5>\n<h5>\u2022\u751f\u6210\u5e26\u7f29\u653e\u7684 2D \u4eff\u5c04\u53d8\u6362\u77e9\u9635:hom_mat2d_scale()<\/h5>\n<h5>\u2022\u6e05\u7a7a\u6a21\u677f\u7684\u53e5\u67c4:clear_shape_model()<\/h5>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260126021701-6976ce9d8b0e0.png\" \/><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260126021702-6976ce9ec13c8.png\" \/><\/p>\n<p>*\/\/ \u83b7\u53d6\u56fe\u50cf<br \/>\nread_image (Image, &#039;green-dot&#039;)<br \/>\n*\/\/ \u83b7\u53d6\u7a97\u4f53\u53e5\u67c4<br \/>\ndev_get_window (WindowHandle)<br \/>\n*\/\/ \u8bbe\u7f6e\u586b\u5145\u6a21\u5f0f<br \/>\ndev_set_draw (&#039;margin&#039;)<br \/>\n*\/\/ \u8bbe\u7f6e\u989c\u8272<br \/>\ndev_set_color (&#039;green&#039;)<br \/>\n*\/\/ \u8bbe\u7f6e\u7ebf\u5bbd<br \/>\ndev_set_line_width (2)<\/p>\n<p>*\/\/ \u7ed8\u5236\u533a\u57df<br \/>\ngen_circle (ROI_0, 273.703, 285.367, 92.2865)<br \/>\n*\/\/ \u83b7\u53d6\u9762\u79ef\u548c\u4e2d\u5fc3\u70b9\u5750\u6807<br \/>\narea_center (ROI_0, Area, Row, Column)<br \/>\n*\/\/ \u88c1\u526a<br \/>\nreduce_domain (Image, ROI_0, ImageReduced)<\/p>\n<p>*\/\/ \u521b\u5efa\u4e00\u4e2a\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f<br \/>\n*\/\/ \u53c2\u65701 \u521b\u5efa\u7684\u6a21\u677f\u56fe\u50cf<br \/>\n*\/\/ \u53c2\u65702 \u91d1\u5b57\u5854\u5c42\u7ea7<br \/>\n*\/\/ \u53c2\u65703\u30014 \u8d77\u59cb\u89d2\u5ea6 \u7ed3\u675f\u89d2\u5ea6<br \/>\n*\/\/ \u53c2\u65705 \u89d2\u5ea6\u9012\u589e\u91cf<br \/>\n*\/\/ \u53c2\u65706\u30017 \u6700\u5c0f\u7f29\u653e\u6bd4\u4f8b \u6700\u5927\u7f29\u653e\u6bd4\u4f8b<br \/>\n*\/\/ \u53c2\u65708 \u7f29\u653e\u6bd4\u4f8b\u7684\u9012\u589e\u91cf<br \/>\n*\/\/ \u53c2\u65709 \u662f\u5426\u91c7\u7528\u6a21\u578b\u4f18\u5316 auto\u81ea\u52a8\u9009\u62e9\u4f18\u5316\u7ea7\u522b<br \/>\n*\/\/ \u53c2\u657010 \u662f\u5426\u4f7f\u7528\u6781\u6027 use_polarity<br \/>\n*\/\/ \u53c2\u657011 \u5bf9\u6bd4\u5ea6\u9608\u503c \u4e00\u822c\u4f7f\u7528auto\u81ea\u52a8\u8ba1\u7b97<br \/>\n*\/\/ \u53c2\u657012 \u6700\u5c0f\u7684\u5bf9\u6bd4\u5ea6\u9608\u503c \u4e00\u822c\u4f7f\u7528auto\u81ea\u52a8\u8ba1\u7b97<br \/>\n*\/\/ \u53c2\u657013 \u6a21\u677f\u7684\u6807\u8bc6<br \/>\ncreate_scaled_shape_model (ImageReduced, &#039;auto&#039;, rad(-45), rad(90), &#039;auto&#039;, 0.8, 1.1, &#039;auto&#039;, &#039;auto&#039;, &#039;ignore_global_polarity&#039;, &#039;auto&#039;, &#039;auto&#039;, ModelID)<\/p>\n<p>*\/\/ \u5c55\u793a\u56fe\u50cf<br \/>\ndev_display (Image)<br \/>\ndev_display (ImageReduced)<\/p>\n<p>*\/\/ \u83b7\u53d6\u5bf9\u5e94\u91d1\u5b57\u5854\u5c42\u7ea7\u7684\u56fe\u50cf \u9ed8\u8ba4\u4f4d\u7f6e\u5728\u56fe\u7247\u7684\u5de6\u4e0a\u89d2(0,0) \u6ca1\u6709\u65cb\u8f6c0<br \/>\nget_shape_model_contours (ModelContours, ModelID, 1)<br \/>\n*\/\/ \u521b\u5efa\u4e00\u4e2a\u4eff\u5c04\u77e9\u5f62\u77e9\u9635<br \/>\nvector_angle_to_rigid (0, 0, 0, Row, Column, 0, HomMat2D)<br \/>\n*\/\/ \u4f7f\u7528\u77e9\u9635<br \/>\naffine_trans_contour_xld (ModelContours, ContoursAffineTrans, HomMat2D)<br \/>\nstop ()<\/p>\n<p>*\/\/ \u83b7\u53d6\u7167\u7247<br \/>\nread_image (Image1, &#039;green-dots&#039;)<br \/>\n*\/\/ \u67e5\u627e\u5177\u6709\u7f29\u653e\u53d8\u5316\u7684\u5f62\u72b6\u6a21\u578b<br \/>\n*\/\/ SubPixel:\u4e9a\u50cf\u7d20\u7cbe\u5ea6 none\u4e0d\u4f7f\u7528\u4e9a\u50cf\u7d20\u7cbe\u5ea6;&#039;least_squares&#039;\u4f7f\u7528\u6700\u4e0b\u4e8c\u4e58\u6cd5\u63d0\u9ad8\u4e9a\u50cf\u7d20\u7cbe\u5ea6<br \/>\n*\/\/ Greediness \u8d2a\u5a6a\u5ea6 \u53d6\u503c\u8303\u56f40~1 \u503c\u8d8a\u5927\u641c\u7d22\u901f\u5ea6\u8d8a\u5feb\u4f46\u7cbe\u5ea6\u964d\u4f4e \u641c\u7d22\u7ed3\u679c\u4f1a\u5c11<br \/>\nfind_scaled_shape_model (Image1, ModelID, rad(-45), rad(90), 0.8, 1.1, 0.5, 0, 0.5, &#039;least_squares&#039;, 0, 0.9, Row1, Column1, Angle, Scale, Score)<\/p>\n<p>*\/\/ \u5c55\u793a\u5339\u914d\u6210\u529f\u7684\u533a\u57df\u7684\u65b9\u6cd5\u4e00\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n* dev_display_shape_matching_results (ModelID, &#039;green&#039;, Row1, Column1, Angle, 1, 1, 0)<br \/>\ndev_close_window ()<br \/>\nfor Index :&#061; 0 to |Scale|-1 by 1<\/p>\n<p>    *\/\/ \u5c55\u793a\u5339\u914d\u6210\u529f\u7684\u533a\u57df\u7684\u65b9\u6cd5\u4e8c\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n    *\/\/ \u521b\u5efa\u4e00\u4e2a\u4eff\u5c04\u77e9\u5f62\u77e9\u9635\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n*   vector_angle_to_rigid (0, 0, 0, Row1[Index], Column1[Index], Angle[Index], HomMat2D)<br \/>\n    *\/\/ \u4f7f\u7528\u77e9\u9635\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n*   affine_trans_contour_xld (ModelContours, ContoursAffineTrans, HomMat2D)<br \/>\n*   dev_display (ContoursAffineTrans)<\/p>\n<p>    *\/\/ \u5c55\u793a\u5339\u914d\u6210\u529f\u7684\u533a\u57df\u7684\u65b9\u6cd5\u4e09\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n    *\/\/ 1.\u751f\u6210\u4e00\u4e2a\u521d\u59cb\u5316\u7684\u4eff\u5c04\u77e9\u9635(\u9f50\u6b21\u77e9\u9635)\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n    hom_mat2d_identity (HomMat2DIdentity)<br \/>\n    *\/\/ 2.\u751f\u6210\u4e00\u4e2a\u5e73\u79fb\u7684\u53d8\u6362\u77e9\u9635\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n    *\/\/ \u53c2\u65701 \u521d\u59cb\u5316\u7684\u4eff\u5c04\u77e9\u9635<br \/>\n    *\/\/ \u53c2\u65702\u30013 \u7ed3\u675f\u70b9\u7684\u4f4d\u7f6e<br \/>\n    *\/\/ \u53c2\u65704 \u751f\u6210\u7684\u5e73\u79fb\u77e9\u9635<br \/>\n    hom_mat2d_translate (HomMat2DIdentity,Row1[Index],  Column1[Index], HomMat2DTranslate)<br \/>\n    *\/\/ 3.\u751f\u6210\u4e00\u4e2a\u65cb\u8f6c\u7684\u4eff\u5c04\u77e9\u9635\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n    hom_mat2d_rotate (HomMat2DTranslate, Angle[Index],Row1[Index],  Column1[Index],  HomMat2DRotate)<br \/>\n    *\/\/ 4.\u751f\u6210\u4e00\u4e2a\u7f29\u653e\u7684\u4eff\u5c04\u77e9\u9635\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n    hom_mat2d_scale (HomMat2DRotate, Scale[Index], Scale[Index], Row1[Index], Column1[Index],  HomMat2DScale)<br \/>\n    *\/\/ 5.\u4f7f\u7528\u6700\u7ec8\u7684\u4eff\u5c04\u77e9\u9635\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n    affine_trans_contour_xld (ModelContours, ContoursAffineTrans1, HomMat2DScale)<br \/>\n    dev_display (ContoursAffineTrans1)<br \/>\nendfor<\/p>\n<p>*\/\/ \u6e05\u7a7a\u6a21\u677f\u7684\u53e5\u67c4<br \/>\nclear_shape_model (ModelID) <\/p>\n<p>\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9, \u611f\u8c22\u5927\u5bb6\u7684\u5173\u6ce8\u548c\u70b9\u8d5e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>*\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d:<br \/>\n\u2022\u83b7\u53d6\u56fe\u7247:read_image ()<br \/>\n\u2022\u83b7\u53d6\u53e5\u67c4:dev_get_window()<br \/>\n\u2022\u8bbe\u7f6e\u533a\u57df\u586b\u5145\u65b9\u5f0f:dev_set_draw()<br \/>\n\u2022\u8bbe\u7f6e\u989c\u8272:dev_set_color()<br \/>\n\u2022\u7ed8\u5236\u77e9\u5f62ROI:gen_rectangle1 ()<br \/>\n\u2022\u83b7\u53d6\u533a\u57df\u7684\u9762\u79ef\u548c\u4e2d\u5fc3\u70b9\u5750\u6807:area_center ()<br \/>\n\u751f\u6210\u5341\u5b57\u5f62\u7684\u4e9a\u50cf\u7d20\u7ea7&#xff08;XLD&#xff09;\u8f6e\u5ed3:gen_cross_contour_xld<br \/>\n\u2022\u62a0\u56fe:reduce_domain(<\/p>\n","protected":false},"author":2,"featured_media":66136,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[187,81,87,3829,1665,427,1326],"topic":[],"class_list":["post-66139","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-javascript","tag-python","tag-87","tag-3829","tag-1665","tag-427","tag-1326"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Halcon\u5c0f\u6848\u4f8b\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d\u548c\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/66139.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Halcon\u5c0f\u6848\u4f8b\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d\u548c\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"*\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d: \u2022\u83b7\u53d6\u56fe\u7247:read_image () \u2022\u83b7\u53d6\u53e5\u67c4:dev_get_window() \u2022\u8bbe\u7f6e\u533a\u57df\u586b\u5145\u65b9\u5f0f:dev_set_draw() \u2022\u8bbe\u7f6e\u989c\u8272:dev_set_color() \u2022\u7ed8\u5236\u77e9\u5f62ROI:gen_rectangle1 () \u2022\u83b7\u53d6\u533a\u57df\u7684\u9762\u79ef\u548c\u4e2d\u5fc3\u70b9\u5750\u6807:area_center () \u751f\u6210\u5341\u5b57\u5f62\u7684\u4e9a\u50cf\u7d20\u7ea7&#xff08;XLD&#xff09;\u8f6e\u5ed3:gen_cross_contour_xld \u2022\u62a0\u56fe:reduce_domain(\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/66139.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-26T02:17:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260126021659-6976ce9bb789f.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/66139.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/66139.html\",\"name\":\"Halcon\u5c0f\u6848\u4f8b\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d\u548c\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-26T02:17:06+00:00\",\"dateModified\":\"2026-01-26T02:17:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/66139.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/66139.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/66139.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Halcon\u5c0f\u6848\u4f8b\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d\u548c\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Halcon\u5c0f\u6848\u4f8b\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d\u548c\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/66139.html","og_locale":"zh_CN","og_type":"article","og_title":"Halcon\u5c0f\u6848\u4f8b\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d\u548c\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"*\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d: \u2022\u83b7\u53d6\u56fe\u7247:read_image () \u2022\u83b7\u53d6\u53e5\u67c4:dev_get_window() \u2022\u8bbe\u7f6e\u533a\u57df\u586b\u5145\u65b9\u5f0f:dev_set_draw() \u2022\u8bbe\u7f6e\u989c\u8272:dev_set_color() \u2022\u7ed8\u5236\u77e9\u5f62ROI:gen_rectangle1 () \u2022\u83b7\u53d6\u533a\u57df\u7684\u9762\u79ef\u548c\u4e2d\u5fc3\u70b9\u5750\u6807:area_center () \u751f\u6210\u5341\u5b57\u5f62\u7684\u4e9a\u50cf\u7d20\u7ea7&#xff08;XLD&#xff09;\u8f6e\u5ed3:gen_cross_contour_xld \u2022\u62a0\u56fe:reduce_domain(","og_url":"https:\/\/www.wsisp.com\/helps\/66139.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-26T02:17:06+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260126021659-6976ce9bb789f.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/66139.html","url":"https:\/\/www.wsisp.com\/helps\/66139.html","name":"Halcon\u5c0f\u6848\u4f8b\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d\u548c\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-26T02:17:06+00:00","dateModified":"2026-01-26T02:17:06+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/66139.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/66139.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/66139.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Halcon\u5c0f\u6848\u4f8b\u57fa\u4e8e\u7070\u5ea6\u503c\u7684\u6a21\u677f\u5339\u914d\u548c\u57fa\u4e8e\u5f62\u72b6\u7684\u6a21\u677f\u5339\u914d"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/66139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=66139"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/66139\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/66136"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=66139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=66139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=66139"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=66139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}