create_ocr_class_mlpT_create_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpcreate_ocr_class_mlp创建光学字符识别类多层感知器(算子)
名称
create_ocr_class_mlpT_create_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpcreate_ocr_class_mlp — 使用多层感知器创建 OCR 分类器。
签名
void CreateOcrClassMlp(const HTuple& WidthCharacter, const HTuple& HeightCharacter, const HTuple& Interpolation, const HTuple& Features, const HTuple& Characters, const HTuple& NumHidden, const HTuple& Preprocessing, const HTuple& NumComponents, const HTuple& RandSeed, HTuple* OCRHandle)
void HOCRMlp::HOCRMlp(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, Hlong NumHidden, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed)
void HOCRMlp::HOCRMlp(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, Hlong NumHidden, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed)
void HOCRMlp::HOCRMlp(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, Hlong NumHidden, const char* Preprocessing, Hlong NumComponents, Hlong RandSeed)
void HOCRMlp::HOCRMlp(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, Hlong NumHidden, const wchar_t* Preprocessing, Hlong NumComponents, Hlong RandSeed)
(
Windows only)
void HOCRMlp::CreateOcrClassMlp(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, Hlong NumHidden, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed)
void HOCRMlp::CreateOcrClassMlp(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, Hlong NumHidden, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed)
void HOCRMlp::CreateOcrClassMlp(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, Hlong NumHidden, const char* Preprocessing, Hlong NumComponents, Hlong RandSeed)
void HOCRMlp::CreateOcrClassMlp(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, Hlong NumHidden, const wchar_t* Preprocessing, Hlong NumComponents, Hlong RandSeed)
(
Windows only)
static void HOperatorSet.CreateOcrClassMlp(HTuple widthCharacter, HTuple heightCharacter, HTuple interpolation, HTuple features, HTuple characters, HTuple numHidden, HTuple preprocessing, HTuple numComponents, HTuple randSeed, out HTuple OCRHandle)
public HOCRMlp(int widthCharacter, int heightCharacter, string interpolation, HTuple features, HTuple characters, int numHidden, string preprocessing, int numComponents, int randSeed)
public HOCRMlp(int widthCharacter, int heightCharacter, string interpolation, string features, HTuple characters, int numHidden, string preprocessing, int numComponents, int randSeed)
void HOCRMlp.CreateOcrClassMlp(int widthCharacter, int heightCharacter, string interpolation, HTuple features, HTuple characters, int numHidden, string preprocessing, int numComponents, int randSeed)
void HOCRMlp.CreateOcrClassMlp(int widthCharacter, int heightCharacter, string interpolation, string features, HTuple characters, int numHidden, string preprocessing, int numComponents, int randSeed)
描述
create_ocr_class_mlpcreate_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpCreateOcrClassMlpcreate_ocr_class_mlp 创建一个使用多层感知器(MLP)的 OCR 分类器。该 OCR 分类器的句柄将通过 OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle 返回。
有关多层感知器(MLP)的工作原理说明,请参阅 create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlpcreate_class_mlp。create_ocr_class_mlpcreate_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpCreateOcrClassMlpcreate_ocr_class_mlp 创建的 MLP 具有
OutputFunctionOutputFunctionOutputFunctionOutputFunctionoutputFunctionoutput_function = 'softmax'"softmax""softmax""softmax""softmax""softmax"。MLP 的特征向量长度(create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlpcreate_class_mlp 中的 NumInputNumInputNumInputNumInputnumInputnum_input)由用于 OCR 的特征决定,这些特征通过 FeaturesFeaturesFeaturesFeaturesfeaturesfeatures 参数传递。特征说明如下。隐藏层的单元数量由 NumHiddenNumHiddenNumHiddenNumHiddennumHiddennum_hidden 决定。MLP 的输出变量数量(create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlpcreate_class_mlp 中的NumOutputNumOutputNumOutputNumOutputnumOutputnum_output )由 OCR 使用的字符名称决定,这些名称通过
CharactersCharactersCharactersCharacterscharacterscharacters 参数传递。如 create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlpcreate_class_mlp 所述,可通过 PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing 和 NumComponentsNumComponentsNumComponentsNumComponentsnumComponentsnum_components 参数指定数据(即特征向量)的预处理方式。OCR 已对特征进行近似归一化处理。因此 PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing 通常可设为 'none'"none""none""none""none""none"。RandSeedRandSeedRandSeedRandSeedrandSeedrand_seed 参数含义与 create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlpcreate_class_mlp 相同。此外,如同通用 MLP 分类器(参见 create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlpcreate_class_mlp 和 set_regularization_params_class_mlpset_regularization_params_class_mlpSetRegularizationParamsClassMlpSetRegularizationParamsClassMlpSetRegularizationParamsClassMlpset_regularization_params_class_mlp),对 OCR 分类器进行正则化处理可能有益。可在训练 OCR 分类器前调用
set_regularization_params_ocr_class_mlpset_regularization_params_ocr_class_mlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlpset_regularization_params_ocr_class_mlp 实现。此外,与通用 MLP 分类器类似(参见
create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlpcreate_class_mlp 和 set_rejection_params_class_mlpset_rejection_params_class_mlpSetRejectionParamsClassMlpSetRejectionParamsClassMlpSetRejectionParamsClassMlpset_rejection_params_class_mlp),为 OCR 分类器添加未知字符拒绝功能可能较为理想。按惯例,拒绝类是一个额外的符号 chr(26),必须在 CharactersCharactersCharactersCharacterscharacterscharacters 中提供。训练 OCR 分类器前调用
set_rejection_params_ocr_class_mlpset_rejection_params_ocr_class_mlpSetRejectionParamsOcrClassMlpSetRejectionParamsOcrClassMlpSetRejectionParamsOcrClassMlpset_rejection_params_ocr_class_mlp 可设置拒绝类参数。
用于分类的特征由
FeaturesFeaturesFeaturesFeaturesfeaturesfeatures 决定。FeaturesFeaturesFeaturesFeaturesfeaturesfeatures 可包含多个特征名的元组。每个特征名都会导致为分类器计算一个或多个特征。部分特征名用于计算灰度值特征(如 'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar")。由于分类器需要固定数量的特征(输入变量),待分类字符将被转换为标准尺寸,该尺寸由 WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_character 和 HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character 决定。转换所用的插值方式由 InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation 决定。其含义与 affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImageaffine_trans_image 中相同。应选择能避免转换产生锯齿效应的插值方式。多数应用场景应采用 InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation =
'constant'"constant""constant""constant""constant""constant"。需注意转换后字符尺寸不宜过大,否则分类器的泛化性能可能恶化。特别是,当尺寸较大时,若采用灰度值特征,微小的分割误差将对计算出的特征产生显著影响。这是因为分割误差会改变区域的最小包围矩形,导致该字符的缩放效果与训练集中的字符存在差异。多数应用场景中,建议采用 6x8 至 10x14 的尺寸范围。
FeaturesFeaturesFeaturesFeaturesfeaturesfeatures 参数可包含以下字符分类特征名称。
- 'default'"default""default""default""default""default"
-
选择 'ratio'"ratio""ratio""ratio""ratio""ratio" 和
'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar"。
- 'pixel'"pixel""pixel""pixel""pixel""pixel"
-
字符的灰度值(WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_character x
HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character 特征)。
- 'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar"
-
字符灰度值经最大化缩放后的灰度值(WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_character x HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character 特征)。
- 'pixel_binary'"pixel_binary""pixel_binary""pixel_binary""pixel_binary""pixel_binary"
-
字符区域作为二值图像放大至
WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_character x HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character 尺寸(WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_character x HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character 特征)。
- 'gradient_8dir'"gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir"
-
在字符图像上计算梯度。梯度方向离散化为 8 个方向。振幅图像按离散化方向分解为 8 个通道。每个通道提取 5x5 网格上的 25 个采样点,作为特征点(共 200 个特征)。
- 'projection_horizontal'"projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal"
-
灰度值的水平投影(参见
gray_projectionsgray_projectionsGrayProjectionsGrayProjectionsGrayProjectionsgray_projections,HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character 特征)。
- 'projection_horizontal_invar'"projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar"
-
灰度值的最大缩放水平投影(HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character 特征)。
- 'projection_vertical'"projection_vertical""projection_vertical""projection_vertical""projection_vertical""projection_vertical"
-
灰度值的垂直投影(参见 gray_projectionsgray_projectionsGrayProjectionsGrayProjectionsGrayProjectionsgray_projections, WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_character 特征)。
- 'projection_vertical_invar'"projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar"
-
灰度值的最大缩放垂直投影(WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_character 特征)。
- 'ratio'"ratio""ratio""ratio""ratio""ratio"
-
字符的宽高比(参见 height_width_ratioheight_width_ratioHeightWidthRatioHeightWidthRatioHeightWidthRatioheight_width_ratio,1 个特征)。
- 'anisometry'"anisometry""anisometry""anisometry""anisometry""anisometry"
-
特征的各向异性(参见 eccentricityeccentricityEccentricityEccentricityEccentricityeccentricity,1 个特征)。
- 'width'"width""width""width""width""width"
-
特征缩放至标准尺寸前的宽度(非尺度不变,参见
height_width_ratioheight_width_ratioHeightWidthRatioHeightWidthRatioHeightWidthRatioheight_width_ratio,1 个特征)。
- 'height'"height""height""height""height""height"
-
字符缩放至标准尺寸前的高度(非尺度不变,参见
height_width_ratioheight_width_ratioHeightWidthRatioHeightWidthRatioHeightWidthRatioheight_width_ratio,1 个特征)。
- 'zoom_factor'"zoom_factor""zoom_factor""zoom_factor""zoom_factor""zoom_factor"
-
字符与
WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_character 和 HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character 值之间的尺寸差异(非尺度不变,1 个特征)。
- 'foreground'"foreground""foreground""foreground""foreground""foreground"
-
前景像素占比(1 个特征)。
- 'foreground_grid_9'"foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9"
-
字符最小包围矩形内 3x3 网格中前景像素占比(9 个特征)。
- 'foreground_grid_16'"foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16"
-
字符最小包围矩形内 4x4 网格中前景像素占比(16 个特征)。
- 'compactness'"compactness""compactness""compactness""compactness""compactness"
-
字符紧凑性(参见 compactnesscompactnessCompactnessCompactnessCompactnesscompactness,1 个特征)。
- 'convexity'"convexity""convexity""convexity""convexity""convexity"
-
字符凸度(参见 convexityconvexityConvexityConvexityConvexityconvexity,1 个特征)。
- 'moments_region_2nd_invar'"moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar"
-
字符的归一化二阶矩(参见
moments_region_2nd_invarmoments_region_2nd_invarMomentsRegion2ndInvarMomentsRegion2ndInvarMomentsRegion2ndInvarmoments_region_2nd_invar,3 个特征)。
- 'moments_region_2nd_rel_invar'"moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar"
-
字符的归一化二阶相对矩(参见
moments_region_2nd_rel_invarmoments_region_2nd_rel_invarMomentsRegion2ndRelInvarMomentsRegion2ndRelInvarMomentsRegion2ndRelInvarmoments_region_2nd_rel_invar,2 个特征)。
- 'moments_region_3rd_invar'"moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar"
-
字符的归一化三阶矩(参见
moments_region_3rd_invarmoments_region_3rd_invarMomentsRegion3rdInvarMomentsRegion3rdInvarMomentsRegion3rdInvarmoments_region_3rd_invar,4 个特征)。
- 'moments_central'"moments_central""moments_central""moments_central""moments_central""moments_central"
-
字符的归一化中心矩(参见
moments_region_centralmoments_region_centralMomentsRegionCentralMomentsRegionCentralMomentsRegionCentralmoments_region_central,4 个特征)。
- 'moments_gray_plane'"moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane"
-
归一化的灰度值矩及灰度值平面角度(参见 moments_gray_planemoments_gray_planeMomentsGrayPlaneMomentsGrayPlaneMomentsGrayPlanemoments_gray_plane,4 个特征)。
- 'phi'"phi""phi""phi""phi""phi"
-
字符方向(角度)的正弦和余弦(参见 elliptic_axiselliptic_axisEllipticAxisEllipticAxisEllipticAxiselliptic_axis,2 个特征)。
- 'num_connect'"num_connect""num_connect""num_connect""num_connect""num_connect"
-
连通分量数量(参见 connect_and_holesconnect_and_holesConnectAndHolesConnectAndHolesConnectAndHolesconnect_and_holes,1 个特征)。
- 'num_holes'"num_holes""num_holes""num_holes""num_holes""num_holes"
-
孔数(参见 connect_and_holesconnect_and_holesConnectAndHolesConnectAndHolesConnectAndHolesconnect_and_holes,1 个特征)。
- 'cooc'"cooc""cooc""cooc""cooc""cooc"
-
二值共生矩阵的值(参见
gen_cooc_matrixgen_cooc_matrixGenCoocMatrixGenCoocMatrixGenCoocMatrixgen_cooc_matrix,8 个特征)。
- 'num_runs'"num_runs""num_runs""num_runs""num_runs""num_runs"
-
区域内按高度归一化的弦数量(1 个特征)。
- 'chord_histo'"chord_histo""chord_histo""chord_histo""chord_histo""chord_histo"
-
每行弦的频率(非尺度不变,HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character 特征)。
创建分类器后,使用
trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlptrainf_ocr_class_mlp 进行训练。训练完成后,可通过 write_ocr_class_mlpwrite_ocr_class_mlpWriteOcrClassMlpWriteOcrClassMlpWriteOcrClassMlpwrite_ocr_class_mlp 保存分类器。或者,训练完成后可立即使用 do_ocr_single_class_mlpdo_ocr_single_class_mlpDoOcrSingleClassMlpDoOcrSingleClassMlpDoOcrSingleClassMlpdo_ocr_single_class_mlp 或 do_ocr_multi_class_mlpdo_ocr_multi_class_mlpDoOcrMultiClassMlpDoOcrMultiClassMlpDoOcrMultiClassMlpdo_ocr_multi_class_mlp 进行字符分类。
HALCON 提供多种预训练 OCR 分类器(详见
“解决方案指南I” 中 'OCR' 一章的 '预训练 OCR 字体' 部分)。这些预训练分类器可通过
read_ocr_class_mlpread_ocr_class_mlpReadOcrClassMlpReadOcrClassMlpReadOcrClassMlpread_ocr_class_mlp 直接读取,无需训练即可识别多种字体。因此建议优先尝试使用预训练OCR分类器。若能成功应用,则无需创建和训练 OCR 分类器。
MLP 与支持向量机(SVM)(参见
create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm)的对比通常表明:SVM 在训练速度上普遍更快,尤其面对海量训练集时优势显著,且识别率略优于 MLP。而 MLP 在分类速度上更具优势,因此在时间敏感型应用中更值得优先选用。请注意,本指南假设参数已进行最优调优。
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
此算子返回一个句柄。请注意,即使该句柄被用作特定算子的输入参数,这些算子仍可能改变此句柄类型的实例状态。
参数
WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_character (输入控制) integer → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
分割字符灰度值被放大的矩形宽度。
默认值:
8
建议值:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20
值范围:
4
≤
WidthCharacter
WidthCharacter
WidthCharacter
WidthCharacter
widthCharacter
width_character
≤
20
HeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_character (输入控制) integer → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
分割字符灰度值被放大的矩形高度。
默认值:
10
建议值:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20
值范围:
4
≤
HeightCharacter
HeightCharacter
HeightCharacter
HeightCharacter
heightCharacter
height_character
≤
20
InterpolationInterpolationInterpolationInterpolationinterpolationinterpolation (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
字符缩放的插值模式。
默认值:
'constant'
"constant"
"constant"
"constant"
"constant"
"constant"
值列表:
'bicubic'"bicubic""bicubic""bicubic""bicubic""bicubic", 'bilinear'"bilinear""bilinear""bilinear""bilinear""bilinear", 'constant'"constant""constant""constant""constant""constant", 'nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor", 'weighted'"weighted""weighted""weighted""weighted""weighted"
FeaturesFeaturesFeaturesFeaturesfeaturesfeatures (输入控制) string(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
用于分类的特征。
默认值:
'default'
"default"
"default"
"default"
"default"
"default"
值列表:
'anisometry'"anisometry""anisometry""anisometry""anisometry""anisometry", 'chord_histo'"chord_histo""chord_histo""chord_histo""chord_histo""chord_histo", 'compactness'"compactness""compactness""compactness""compactness""compactness", 'convexity'"convexity""convexity""convexity""convexity""convexity", 'cooc'"cooc""cooc""cooc""cooc""cooc", 'default'"default""default""default""default""default", 'foreground'"foreground""foreground""foreground""foreground""foreground", 'foreground_grid_16'"foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16""foreground_grid_16", 'foreground_grid_9'"foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9""foreground_grid_9", 'gradient_8dir'"gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir""gradient_8dir", 'height'"height""height""height""height""height", 'moments_central'"moments_central""moments_central""moments_central""moments_central""moments_central", 'moments_gray_plane'"moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane""moments_gray_plane", 'moments_region_2nd_invar'"moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar""moments_region_2nd_invar", 'moments_region_2nd_rel_invar'"moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar""moments_region_2nd_rel_invar", 'moments_region_3rd_invar'"moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar""moments_region_3rd_invar", 'num_connect'"num_connect""num_connect""num_connect""num_connect""num_connect", 'num_holes'"num_holes""num_holes""num_holes""num_holes""num_holes", 'num_runs'"num_runs""num_runs""num_runs""num_runs""num_runs", 'phi'"phi""phi""phi""phi""phi", 'pixel'"pixel""pixel""pixel""pixel""pixel", 'pixel_binary'"pixel_binary""pixel_binary""pixel_binary""pixel_binary""pixel_binary", 'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar", 'projection_horizontal'"projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal""projection_horizontal", 'projection_horizontal_invar'"projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar""projection_horizontal_invar", 'projection_vertical'"projection_vertical""projection_vertical""projection_vertical""projection_vertical""projection_vertical", 'projection_vertical_invar'"projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar""projection_vertical_invar", 'ratio'"ratio""ratio""ratio""ratio""ratio", 'width'"width""width""width""width""width", 'zoom_factor'"zoom_factor""zoom_factor""zoom_factor""zoom_factor""zoom_factor"
CharactersCharactersCharactersCharacterscharacterscharacters (输入控制) string-array → HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)
待读取字符集中的所有字符。
默认值:
['0','1','2','3','4','5','6','7','8','9']
["0","1","2","3","4","5","6","7","8","9"]
["0","1","2","3","4","5","6","7","8","9"]
["0","1","2","3","4","5","6","7","8","9"]
["0","1","2","3","4","5","6","7","8","9"]
["0","1","2","3","4","5","6","7","8","9"]
NumHiddenNumHiddenNumHiddenNumHiddennumHiddennum_hidden (输入控制) integer → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
MLP 中隐藏层的单元数量。
默认值:
80
建议值:
1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 150
限制:
NumHidden >= 1
PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
用于转换特征向量的预处理类型。
默认值:
'none'
"none"
"none"
"none"
"none"
"none"
值列表:
'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates""canonical_variates", 'none'"none""none""none""none""none", 'normalization'"normalization""normalization""normalization""normalization""normalization", 'principal_components'"principal_components""principal_components""principal_components""principal_components""principal_components"
NumComponentsNumComponentsNumComponentsNumComponentsnumComponentsnum_components (输入控制) integer → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
预处理参数:转换特征的数量(当 PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing
= 'none'"none""none""none""none""none" 和 PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing
= 'normalization'"normalization""normalization""normalization""normalization""normalization" 时忽略此参数)。
默认值:
10
建议值:
1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100
限制:
NumComponents >= 1
RandSeedRandSeedRandSeedRandSeedrandSeedrand_seed (输入控制) integer → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
用于将 MLP 初始化为随机值的随机数生成器的种子值。
默认值:
42
OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle (输出控制) ocr_mlp → HOCRMlp, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
OCR 分类器的句柄。
示例(HDevelop)
read_image (Image, 'letters')
* Segment the image.
binary_threshold(Image,&Region, 'otsu', 'dark', &UsedThreshold);
dilation_circle (Region, RegionDilation, 3.5)
connection (RegionDilation, ConnectedRegions)
intersection (ConnectedRegions, Region, RegionIntersection)
sort_region (RegionIntersection, Characters, 'character', 'true', 'row')
* Generate the training file.
count_obj (Characters, Number)
Classes := []
for J := 0 to 25 by 1
Classes := [Classes,gen_tuple_const(20,chr(ord('a')+J))]
endfor
Classes := [Classes,gen_tuple_const(20,'.')]
write_ocr_trainf (Characters, Image, Classes, 'letters.trf')
* Generate and train the classifier.
read_ocr_trainf_names ('letters.trf', CharacterNames, CharacterCount)
create_ocr_class_mlp (8, 10, 'constant', 'default', CharacterNames, 20, \
'none', 81, 42, OCRHandle)
trainf_ocr_class_mlp (OCRHandle, 'letters.trf', 100, 0.01, 0.01, Error, \
ErrorLog)
* Re-classify the characters in the image.
do_ocr_multi_class_mlp (Characters, Image, OCRHandle, Class, Confidence)
结果
如果参数有效,算子
create_ocr_class_mlpcreate_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpCreateOcrClassMlpcreate_ocr_class_mlp 返回值 2 (H_MSG_TRUE)。如有必要,则抛出异常。
可能的后继
trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlptrainf_ocr_class_mlp,
set_regularization_params_ocr_class_mlpset_regularization_params_ocr_class_mlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlpset_regularization_params_ocr_class_mlp,
set_rejection_params_ocr_class_mlpset_rejection_params_ocr_class_mlpSetRejectionParamsOcrClassMlpSetRejectionParamsOcrClassMlpSetRejectionParamsOcrClassMlpset_rejection_params_ocr_class_mlp
替代
create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm
另见
do_ocr_single_class_mlpdo_ocr_single_class_mlpDoOcrSingleClassMlpDoOcrSingleClassMlpDoOcrSingleClassMlpdo_ocr_single_class_mlp,
do_ocr_multi_class_mlpdo_ocr_multi_class_mlpDoOcrMultiClassMlpDoOcrMultiClassMlpDoOcrMultiClassMlpdo_ocr_multi_class_mlp,
clear_ocr_class_mlpclear_ocr_class_mlpClearOcrClassMlpClearOcrClassMlpClearOcrClassMlpclear_ocr_class_mlp,
create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlpcreate_class_mlp,
train_class_mlptrain_class_mlpTrainClassMlpTrainClassMlpTrainClassMlptrain_class_mlp,
classify_class_mlpclassify_class_mlpClassifyClassMlpClassifyClassMlpClassifyClassMlpclassify_class_mlp
模块
光学字符识别/光学字符验证