best_matchT_best_matchBestMatchBestMatchbest_match最佳匹配(算子)

名称

best_matchT_best_matchBestMatchBestMatchbest_match — 搜索模板和图像的最佳匹配。

警告

best_matchbest_matchBestMatchBestMatchBestMatchbest_match 已过时,仅出于向后兼容性考虑而保留。新应用程序应改用基于形状或基于 NCC 的算子。

签名

best_match(Image : : TemplateID, MaxError, SubPixel : Row, Column, Error)

Herror T_best_match(const Hobject Image, const Htuple TemplateID, const Htuple MaxError, const Htuple SubPixel, Htuple* Row, Htuple* Column, Htuple* Error)

void BestMatch(const HObject& Image, const HTuple& TemplateID, const HTuple& MaxError, const HTuple& SubPixel, HTuple* Row, HTuple* Column, HTuple* Error)

void HTemplate::BestMatch(const HImage& Image, double MaxError, const HString& SubPixel, HTuple* Row, HTuple* Column, HTuple* Error) const

void HTemplate::BestMatch(const HImage& Image, double MaxError, const HString& SubPixel, double* Row, double* Column, double* Error) const

void HTemplate::BestMatch(const HImage& Image, double MaxError, const char* SubPixel, double* Row, double* Column, double* Error) const

void HTemplate::BestMatch(const HImage& Image, double MaxError, const wchar_t* SubPixel, double* Row, double* Column, double* Error) const   ( Windows only)

void HImage::BestMatch(const HTemplate& TemplateID, double MaxError, const HString& SubPixel, HTuple* Row, HTuple* Column, HTuple* Error) const

void HImage::BestMatch(const HTemplate& TemplateID, double MaxError, const HString& SubPixel, double* Row, double* Column, double* Error) const

void HImage::BestMatch(const HTemplate& TemplateID, double MaxError, const char* SubPixel, double* Row, double* Column, double* Error) const

void HImage::BestMatch(const HTemplate& TemplateID, double MaxError, const wchar_t* SubPixel, double* Row, double* Column, double* Error) const   ( Windows only)

static void HOperatorSet.BestMatch(HObject image, HTuple templateID, HTuple maxError, HTuple subPixel, out HTuple row, out HTuple column, out HTuple error)

void HTemplate.BestMatch(HImage image, double maxError, string subPixel, out HTuple row, out HTuple column, out HTuple error)

void HTemplate.BestMatch(HImage image, double maxError, string subPixel, out double row, out double column, out double error)

void HImage.BestMatch(HTemplate templateID, double maxError, string subPixel, out HTuple row, out HTuple column, out HTuple error)

void HImage.BestMatch(HTemplate templateID, double maxError, string subPixel, out double row, out double column, out double error)

def best_match(image: HObject, template_id: HHandle, max_error: float, sub_pixel: str) -> Tuple[Sequence[float], Sequence[float], Sequence[float]]

def best_match_s(image: HObject, template_id: HHandle, max_error: float, sub_pixel: str) -> Tuple[float, float, float]

描述

算子 best_matchbest_matchBestMatchBestMatchBestMatchbest_match 执行模板 of TemplateIDTemplateIDTemplateIDTemplateIDtemplateIDtemplate_id 与图像 ImageImageImageImageimageimage 的匹配操作。在此过程中,模板将沿 ImageImageImageImageimageimage 点位移动,确保模板始终位于 ImageImageImageImageimageimage 内部。 best_matchbest_matchBestMatchBestMatchBestMatchbest_match 的工作原理与 fast_matchfast_matchFastMatchFastMatchFastMatchfast_match 类似,区别在于每次找到更佳匹配时,其内部会将 MaxErrorMaxErrorMaxErrorMaxErrormaxErrormax_error 值更新为更低数值,从而缩短运行时间。

关于参数 SubPixelSubPixelSubPixelSubPixelsubPixelsub_pixel,位置将以亚像素精度进行标注。匹配标准(“位移帧差异”)定义如下: 该算子的运行时间取决于 ImageImageImageImageimageimage 域的大小。因此,尽可能限制定义域范围至关重要,即仅在非常狭窄的“感兴趣区域(region of interest,ROI)”内应用该算子。参数 MaxErrorMaxErrorMaxErrorMaxErrormaxErrormax_error 决定了搜索位置允许存在的最大误差值。该值越低,算子运行速度越快。

RowRowRowRowrowrowColumnColumnColumnColumncolumncolumn 返回最佳匹配的位置,其中 ErrorErrorErrorErrorerrorerror 表示灰度值的平均差异。若未找到误差值低于 MaxErrorMaxErrorMaxErrorMaxErrormaxErrormax_error 的位置,则返回位置 (0,0) 及 ErrorErrorErrorErrorerrorerror 为 255 的匹配结果。此时需将 MaxErrorMaxErrorMaxErrorMaxErrormaxErrormax_error 设置得更大。

位置的最大误差(无噪声)为 0.1 像素。平均误差为 0.03 像素。

执行信息

参数

ImageImageImageImageimageimage (输入对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte)

需要在其中查找模式的输入图像。

TemplateIDTemplateIDTemplateIDTemplateIDtemplateIDtemplate_id (输入控制)  template HTemplate, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

模板编号。

MaxErrorMaxErrorMaxErrorMaxErrormaxErrormax_error (输入控制)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

灰度值的最大平均差值。

默认值: 20.0

建议值: 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0, 15.0, 17.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0

值范围: 0 ≤ MaxError MaxError MaxError MaxError maxError max_error ≤ 255

最小增量: 1

建议增量: 3

SubPixelSubPixelSubPixelSubPixelsubPixelsub_pixel (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

当为 'true'"true""true""true""true""true" 时,实现亚像素级精度。

默认值: 'false' "false" "false" "false" "false" "false"

值列表: 'false'"false""false""false""false""false", 'true'"true""true""true""true""true"

RowRowRowRowrowrow (输出控制)  point.y(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

最佳匹配的行位置。

ColumnColumnColumnColumncolumncolumn (输出控制)  point.x(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

最佳匹配的列位置。

ErrorErrorErrorErrorerrorerror (输出控制)  real(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

最佳匹配的灰度值平均差异。

结果

如果参数值正确,算子 best_matchbest_matchBestMatchBestMatchBestMatchbest_match 返回值 2 ( H_MSG_TRUE )。当输入为空(没有可用输入图像)时,可设置行为通过算子 set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>)。如有必要,则抛出异常。

可能的前趋

create_templatecreate_templateCreateTemplateCreateTemplateCreateTemplatecreate_template, read_templateread_templateReadTemplateReadTemplateReadTemplateread_template, set_offset_templateset_offset_templateSetOffsetTemplateSetOffsetTemplateSetOffsetTemplateset_offset_template, set_reference_templateset_reference_templateSetReferenceTemplateSetReferenceTemplateSetReferenceTemplateset_reference_template, adapt_templateadapt_templateAdaptTemplateAdaptTemplateAdaptTemplateadapt_template, draw_regiondraw_regionDrawRegionDrawRegionDrawRegiondraw_region, draw_rectangle1draw_rectangle1DrawRectangle1DrawRectangle1DrawRectangle1draw_rectangle1, reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain

替代

fast_matchfast_matchFastMatchFastMatchFastMatchfast_match, fast_match_mgfast_match_mgFastMatchMgFastMatchMgFastMatchMgfast_match_mg, best_match_mgbest_match_mgBestMatchMgBestMatchMgBestMatchMgbest_match_mg, best_match_pre_mgbest_match_pre_mgBestMatchPreMgBestMatchPreMgBestMatchPreMgbest_match_pre_mg, best_match_rotbest_match_rotBestMatchRotBestMatchRotBestMatchRotbest_match_rot, best_match_rot_mgbest_match_rot_mgBestMatchRotMgBestMatchRotMgBestMatchRotMgbest_match_rot_mg, exhaustive_matchexhaustive_matchExhaustiveMatchExhaustiveMatchExhaustiveMatchexhaustive_match, exhaustive_match_mgexhaustive_match_mgExhaustiveMatchMgExhaustiveMatchMgExhaustiveMatchMgexhaustive_match_mg

模块

匹配