日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > ChatGpt >内容正文

ChatGpt

Halcon几何定位

發布時間:2024/3/24 ChatGpt 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Halcon几何定位 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Halcon幾何定位Halcon幾何定位Halcon


建模經驗

  • 知道什么是關鍵輪廓】什么是干擾輪廓
  • 邊緣數量越少越好,邊緣數量多了,速度會變慢
  • 邊緣越長越好
  • 干擾邊越少越好
  • 關鍵邊緣越多越好,占模板輪廓的比例越多越好
  • 可以用PhotoShop制造理想的模板圖像
  • 靈活運用區域操作技術,獲取關鍵邊緣區域
    difference和union:特別對于:回型區域,需要挖洞區域

  • 定位經驗

  • 頻繁調節的參數:角度、縮放、分數、極性
  • 多次搜索策略(分類):匹配分數逐步降低:for循環
  • 合理設置旋轉角度范圍
  • 合理設置貪婪度:定位要求高、貪婪度越小越好,但是時間會變長
  • 有效提高匹配分數措施:縮放、會增加時間。對分數提高的效果:異步>同步>不縮放。合理設置縮放。

  • 灰度定位與輪廓定位的對比

    幾何定位 = 輪廓定位

    運行時間對縮放的適應性對灰度的適應性(光照的變化,物體本身材質等造成的灰度的線性和非線性變化)對旋轉的適應性對物體遮擋和缺失的適應性
    灰度定位
    輪廓定位

    灰度定位,一般指的就是Blob分析
    幾何定位:支持單模板定位和多模板定位
    幾何定位分三種:無縮放、xy同步縮放、xy異步縮放
    幾何定位工具:匹配助手


    模板匹配的重要參數
    1.對比度
    2.最小組件尺寸
    3.金字塔等級(等級越高,模板越模糊,匹配越容易)
    4.角度范圍
    5.縮放參數
    6.極性(度量)
    7.最小分數(相似度、匹配分數)
    8.匹配最大數
    9.貪心算法
    10.最大重疊比
    11.形狀模板可能與圖像邊緣交叉


    對比度
    Contrast不僅僅是對比度,根據數組元素數量不同,其意義不同
    1個元素時:10,對比度,直接提取邊緣
    2個元素時:[10,20],表示10提取不出邊緣,則使用20作為參數提取邊緣
    3個元素時:[10,30,5],前兩個參數同上,最后一個參數表示所提取邊緣的長度最小為5


    幾何定位的流程

  • 圖像預處理,創建ROI
  • 準備模板圖像
  • 創建模板(參數設置)
  • 輸入需要模板匹配的輸入圖像
  • 使用模板進行定位(參數設置)
  • 得到定位結果:位置、角度、縮放比、分值等
  • 釋放模板資源




  • read_image (Image, '1.BMP')* * Matching 02: ************************************************ * Matching 02: BEGIN of generated code for model initialization * Matching 02: ************************************************ set_system ('border_shape_models', 'false') * * Matching 02: Obtain the model image * Matching 02: ************* * Matching 02: * ATTENTION * * Matching 02: ************* * Matching 02: The image from the graphics window is not available. At this point, * Matching 02: it is necessary to ensure an image is stored in the variable 'Image' * * Matching 02: Build the ROI from basic regions gen_rectangle1 (ModelRegion, 198.514, 448.541, 267.264, 514.813) * * Matching 02: Reduce the model template reduce_domain (Image, ModelRegion, TemplateImage) * * Matching 02: Create the shape model create_scaled_shape_model (TemplateImage, 3, rad(0), rad(360), rad(3.5798), 0.89, 1.1, 0.0312, ['none','no_pregeneration'], 'use_polarity', [10,11,4], 4, ModelID) * * Matching 02: Get the model contour for transforming it later into the image get_shape_model_contours (ModelContours, ModelID, 1) * * Matching 02: Get the reference position area_center (ModelRegion, ModelRegionArea, RefRow, RefColumn) vector_angle_to_rigid (0, 0, 0, RefRow, RefColumn, 0, HomMat2D) affine_trans_contour_xld (ModelContours, TransContours, HomMat2D) * * Matching 02: Display the model contours dev_display (Image) dev_set_color ('green') dev_set_draw ('margin') dev_display (ModelRegion) dev_display (TransContours) stop () * * Matching 02: END of generated code for model initialization * Matching 02: * * * * * * * * * * * * * * * * * * * * * * * * Matching 02: BEGIN of generated code for model application * * Matching 02: Loop over all specified test images TestImages := ['1.BMP'] for T := 0 to 0 by 1* * Matching 02: Obtain the test imageread_image (Image, TestImages[T])* * Matching 02: Find the modelfind_scaled_shape_model (Image, ModelID, rad(0), rad(360), 0.89, 1.1, 0.8, 27, 0.5, 'least_squares', [3,1], 0.4, Row, Column, Angle, Scale, Score)* * Matching 02: Transform the model contours into the detected positionsdev_display (Image)for I := 0 to |Score| - 1 by 1hom_mat2d_identity (HomMat2D)hom_mat2d_scale (HomMat2D, Scale[I], Scale[I], 0, 0, HomMat2D)hom_mat2d_rotate (HomMat2D, Angle[I], 0, 0, HomMat2D)hom_mat2d_translate (HomMat2D, Row[I], Column[I], HomMat2D)affine_trans_contour_xld (ModelContours, TransContours, HomMat2D)dev_set_color ('green')dev_display (TransContours)stop ()endfor endfor * * Matching 02: ******************************************* * Matching 02: END of generated code for model application * Matching 02: ******************************************* *

    實例

    * * online shape-based matching with adaptation to illumination changes * rotational invariant * rotation/translation to "normalize" the input image * * set online to true if you are using an image acquisition device * if online is set to false, a virtual image acquisition device is opened which reads an image sequence from hard disk * online := false VisUndefPixelBlack := 1 dev_update_window ('off') dev_update_pc ('off') dev_update_var ('off') dev_update_time ('off') if (online)* open the 'real' image acquisition deviceinfo_framegrabber ('1394IIDC', 'revision', RevisionInfo, RevisionInfoValues)open_framegrabber ('1394IIDC', 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1, 'default', 'default', 'default', -1, -1, AcqHandle) else* open the virtual image acquisition deviceinfo_framegrabber ('File', 'general', Information, ValueList)open_framegrabber ('File', 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1, 'default', 'pendulum/pendulum', 'default', -1, 1, AcqHandle) endif grab_image (Image, AcqHandle) get_image_size (Image, Width, Height) dev_close_window () dev_open_window (0, Width + 30, Width, Height, 'black', WindowRot) dev_open_window (0, 0, Width, Height, 'black', WindowID) dev_set_window (WindowID) dev_set_part (0, 0, Height - 1, Width - 1) dev_set_window (WindowRot) dev_set_part (0, 0, Height - 1, Width - 1) dev_display (Image) set_display_font (WindowID, 16, 'mono', 'true', 'false') hom_mat2d_identity (HomMat2DIdentity) * disp_continue_message (WindowID, 'black', 'true') * stop () * ------------------------ * select the model object * ------------------------ if (online)* * define template by drawing a rectangle* dev_update_pc ('off')dev_set_window (WindowID)dev_set_draw ('margin')dev_set_line_width (5)grab_image (ImageTempl, AcqHandle)dev_set_window (WindowID)dev_display (ImageTempl)disp_message (WindowID, 'define the template', 'window', 12, 12, 'black', 'true')dev_set_color ('green')draw_rectangle2 (WindowID, RowTempl, ColumnTempl, PhiTempl, Length1, Length2)gen_rectangle2 (Rectangle, RowTempl, ColumnTempl, PhiTempl, Length1, Length2)dev_display (Rectangle)reduce_domain (ImageTempl, Rectangle, ImageReduced)create_shape_model (ImageReduced, 4, 0, rad(360), 'auto', 'none', 'use_polarity', 30, 10, ModelID)intensity (ImageReduced, Image, TemplMean, Deviation)dev_update_pc ('on') else* * load default object for virtual framegrabber* Length1 := 32.0Length2 := 12.5PhiTempl := -0.315RowTempl := 112.5ColumnTempl := 92.0copy_obj (Image, ImageTempl, 1, 1)gen_rectangle2 (Rectangle, RowTempl, ColumnTempl, PhiTempl, Length1, Length2)reduce_domain (Image, Rectangle, ImageReduced)create_shape_model (ImageReduced, 4, 0, rad(360), 'auto', 'none', 'use_polarity', 30, 10, ModelID)intensity (ImageReduced, Image, TemplMean, Deviation) endif * RowRot := RowTempl * ColumnRot := ColumnTempl RowRot := Height / 2 ColumnRot := Width / 2 * ------------------------------------------ * visualize normalized input image * ------------------------------------------ * Compensate for rotation and translation vector_angle_to_rigid (RowTempl, ColumnTempl, PhiTempl, RowRot, ColumnRot, 0, HomMat2DRotate) affine_trans_image (ImageTempl, ImageAffineTrans, HomMat2DRotate, 'constant', 'false') if (VisUndefPixelBlack == 1)full_domain (ImageAffineTrans, ImageFull)dev_set_window (WindowRot)dev_display (ImageFull) elsedev_set_window (WindowRot)dev_display (ImageAffineTrans) endif dev_set_window (WindowID) dev_display (ImageTempl) disp_message (WindowID, 'run the template matching', 'image', 20, 20, 'yellow', 'false') disp_message (WindowID, 'run the template matching', 'image', 20, 20, 'yellow', 'false') disp_message (WindowID, '(click left to start,', 'image', 50, 20, 'yellow', 'false') disp_message (WindowID, 'right to stop)', 'image', 80, 20, 'yellow', 'false') * disp_continue_message (WindowID, 'black', 'true') * stop () Button := 0 while (Button != 1)get_mbutton (WindowID, dummy, dummy, Button) endwhile dev_update_pc ('off') * ------------------------ * shape-based matching * ------------------------ Button := 0 Exp := 1 while (Button != 4)if (online)grab_image_async (Image, AcqHandle, -1)elsegrab_image (Image, AcqHandle)endifcount_seconds (Seconds1)find_shape_model (Image, ModelID, 0, rad(360), 0.7, 1, 0.5, 'least_squares', 0, 0.7, Row, Column, Angle, Score)if (Score > 0.5)gen_rectangle2 (Rectangle, Row, Column, PhiTempl + Angle, Length1, Length2)reduce_domain (Image, Rectangle, ImageReduced)intensity (ImageReduced, Image, Mean, Deviation)* Compensate for rotation and translationvector_angle_to_rigid (Row, Column, Angle, RowRot, ColumnRot, 0, HomMat2DRotate)affine_trans_image (Image, ImageAffineTrans, HomMat2DRotate, 'constant', 'false')count_seconds (Seconds2)Time := round(1000 * (Seconds2 - Seconds1))if (VisUndefPixelBlack == 1)full_domain (ImageAffineTrans, ImageFull)dev_set_window (WindowRot)dev_display (ImageFull)elsedev_set_window (WindowRot)dev_display (ImageAffineTrans)endifdev_set_window (WindowID)dev_display (Image)disp_message (WindowID, Time + ' ms', 'window', 12, 12, 'black', 'true')dev_set_color ('green')dev_display (Rectangle)elsedev_display (Image)endif* --------------------------* Exit with mouse click* --------------------------dev_error_var (Error, 1)dev_set_check ('~give_error')get_mposition (WindowID, R, C, Button)dev_error_var (Error, 0)dev_set_check ('give_error')if (Error != H_MSG_TRUE)Button := 0endif endwhile clear_shape_model (ModelID) disp_continue_message (WindowID, 'black', 'true') stop () close_framegrabber (AcqHandle) dev_set_window (WindowRot) dev_close_window () dev_update_pc ('on') dev_update_var ('on') dev_update_time ('on') dev_update_window ('on')

    總結

    以上是生活随笔為你收集整理的Halcon几何定位的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。