create_ocr_class_svmT_create_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm创建光学字符识别类支持向量机(算子)

名称

create_ocr_class_svmT_create_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm — 使用支持向量机创建 OCR 分类器。

签名

create_ocr_class_svm( : : WidthCharacter, HeightCharacter, Interpolation, Features, Characters, KernelType, KernelParam, Nu, Mode, Preprocessing, NumComponents : OCRHandle)

Herror T_create_ocr_class_svm(const Htuple WidthCharacter, const Htuple HeightCharacter, const Htuple Interpolation, const Htuple Features, const Htuple Characters, const Htuple KernelType, const Htuple KernelParam, const Htuple Nu, const Htuple Mode, const Htuple Preprocessing, const Htuple NumComponents, Htuple* OCRHandle)

void CreateOcrClassSvm(const HTuple& WidthCharacter, const HTuple& HeightCharacter, const HTuple& Interpolation, const HTuple& Features, const HTuple& Characters, const HTuple& KernelType, const HTuple& KernelParam, const HTuple& Nu, const HTuple& Mode, const HTuple& Preprocessing, const HTuple& NumComponents, HTuple* OCRHandle)

void HOCRSvm::HOCRSvm(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, const HString& KernelType, double KernelParam, double Nu, const HString& Mode, const HString& Preprocessing, Hlong NumComponents)

void HOCRSvm::HOCRSvm(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, const HString& KernelType, double KernelParam, double Nu, const HString& Mode, const HString& Preprocessing, Hlong NumComponents)

void HOCRSvm::HOCRSvm(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, const char* KernelType, double KernelParam, double Nu, const char* Mode, const char* Preprocessing, Hlong NumComponents)

void HOCRSvm::HOCRSvm(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, const wchar_t* KernelType, double KernelParam, double Nu, const wchar_t* Mode, const wchar_t* Preprocessing, Hlong NumComponents)   ( Windows only)

void HOCRSvm::CreateOcrClassSvm(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, const HString& KernelType, double KernelParam, double Nu, const HString& Mode, const HString& Preprocessing, Hlong NumComponents)

void HOCRSvm::CreateOcrClassSvm(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, const HString& KernelType, double KernelParam, double Nu, const HString& Mode, const HString& Preprocessing, Hlong NumComponents)

void HOCRSvm::CreateOcrClassSvm(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, const char* KernelType, double KernelParam, double Nu, const char* Mode, const char* Preprocessing, Hlong NumComponents)

void HOCRSvm::CreateOcrClassSvm(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, const wchar_t* KernelType, double KernelParam, double Nu, const wchar_t* Mode, const wchar_t* Preprocessing, Hlong NumComponents)   ( Windows only)

static void HOperatorSet.CreateOcrClassSvm(HTuple widthCharacter, HTuple heightCharacter, HTuple interpolation, HTuple features, HTuple characters, HTuple kernelType, HTuple kernelParam, HTuple nu, HTuple mode, HTuple preprocessing, HTuple numComponents, out HTuple OCRHandle)

public HOCRSvm(int widthCharacter, int heightCharacter, string interpolation, HTuple features, HTuple characters, string kernelType, double kernelParam, double nu, string mode, string preprocessing, int numComponents)

public HOCRSvm(int widthCharacter, int heightCharacter, string interpolation, string features, HTuple characters, string kernelType, double kernelParam, double nu, string mode, string preprocessing, int numComponents)

void HOCRSvm.CreateOcrClassSvm(int widthCharacter, int heightCharacter, string interpolation, HTuple features, HTuple characters, string kernelType, double kernelParam, double nu, string mode, string preprocessing, int numComponents)

void HOCRSvm.CreateOcrClassSvm(int widthCharacter, int heightCharacter, string interpolation, string features, HTuple characters, string kernelType, double kernelParam, double nu, string mode, string preprocessing, int numComponents)

def create_ocr_class_svm(width_character: int, height_character: int, interpolation: str, features: MaybeSequence[str], characters: Sequence[str], kernel_type: str, kernel_param: float, nu: float, mode: str, preprocessing: str, num_components: int) -> HHandle

描述

create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm 创建一个使用支持向量机(SVM)的 OCR 分类器。该 OCR 分类器的句柄将通过 OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle 返回。

有关 SVM 的工作原理说明,请参阅 create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvmcreate_class_svmcreate_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm 根据 ModeModeModeModemodemode 指定的分类模式创建用于分类的 SVM。该 SVM 的特征向量长度(create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvmcreate_class_svm 中的 NumFeaturesNumFeaturesNumFeaturesNumFeaturesnumFeaturesnum_features)由 OCR 使用的特征决定,这些特征通过 FeaturesFeaturesFeaturesFeaturesfeaturesfeatures 参数传递。特征说明如下。与 create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvmcreate_class_svm 类似,内核通过 KernelTypeKernelTypeKernelTypeKernelTypekernelTypekernel_typeKernelParamKernelParamKernelParamKernelParamkernelParamkernel_paramNuNuNuNununu 进行参数化。SVM 的类数(create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvmcreate_class_svm 中的 NumClassesNumClassesNumClassesNumClassesnumClassesnum_classes)由 OCR 使用的字符名称决定,这些名称通过 CharactersCharactersCharactersCharacterscharacterscharacters 参数传递。如 create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvmcreate_class_svm 所述,参数 PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessingNumComponentsNumComponentsNumComponentsNumComponentsnumComponentsnum_components 可用于指定数据(即特征向量)的预处理方式。为确保数值稳定性,PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing 通常可设置为 'normalization'"normalization""normalization""normalization""normalization""normalization"。为加快分类速度,可使用 'principal_components'"principal_components""principal_components""principal_components""principal_components""principal_components"'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates""canonical_variates",因其可在不降低识别率的前提下显著减少输入特征数量。

用于分类的特征由 FeaturesFeaturesFeaturesFeaturesfeaturesfeatures 决定。FeaturesFeaturesFeaturesFeaturesfeaturesfeatures 可以包含一个特征名称元组。每个特征名都会导致为分类器计算一个或多个特征。部分特征名用于计算灰度值特征(如 'pixel_invar'"pixel_invar""pixel_invar""pixel_invar""pixel_invar""pixel_invar")。由于分类器需要固定数量的特征(输入变量),待分类字符将被转换为标准尺寸,该尺寸由 WidthCharacterWidthCharacterWidthCharacterWidthCharacterwidthCharacterwidth_characterHeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_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_projectionsHeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_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_characterHeightCharacterHeightCharacterHeightCharacterHeightCharacterheightCharacterheight_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,1 个特征)。

'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,12 个特征)。

'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_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmTrainfOcrClassSvmtrainf_ocr_class_svm 进行训练。训练完成后,可通过 write_ocr_class_svmwrite_ocr_class_svmWriteOcrClassSvmWriteOcrClassSvmWriteOcrClassSvmwrite_ocr_class_svm 保存分类器。或者,训练完成后可立即使用 do_ocr_single_class_svmdo_ocr_single_class_svmDoOcrSingleClassSvmDoOcrSingleClassSvmDoOcrSingleClassSvmdo_ocr_single_class_svmdo_ocr_multi_class_svmdo_ocr_multi_class_svmDoOcrMultiClassSvmDoOcrMultiClassSvmDoOcrMultiClassSvmdo_ocr_multi_class_svm 进行字符分类。

SVM 与多层感知器(MLP)(参见 create_ocr_class_mlpcreate_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpCreateOcrClassMlpcreate_ocr_class_mlp)的对比通常表明: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"]

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

内核类型。

默认值: 'rbf' "rbf" "rbf" "rbf" "rbf" "rbf"

值列表: 'linear'"linear""linear""linear""linear""linear", 'polynomial_homogeneous'"polynomial_homogeneous""polynomial_homogeneous""polynomial_homogeneous""polynomial_homogeneous""polynomial_homogeneous", 'polynomial_inhomogeneous'"polynomial_inhomogeneous""polynomial_inhomogeneous""polynomial_inhomogeneous""polynomial_inhomogeneous""polynomial_inhomogeneous", 'rbf'"rbf""rbf""rbf""rbf""rbf"

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

内核函数的附加参数。

默认值: 0.02

建议值: 0.01, 0.02, 0.05, 0.1, 0.5

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

SVM 的正则化常数。

默认值: 0.05

建议值: 0.0001, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3

限制: Nu > 0.0 && Nu < 1.0

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

SVM 的模式。

默认值: 'one-versus-one' "one-versus-one" "one-versus-one" "one-versus-one" "one-versus-one" "one-versus-one"

值列表: 'one-versus-all'"one-versus-all""one-versus-all""one-versus-all""one-versus-all""one-versus-all", 'one-versus-one'"one-versus-one""one-versus-one""one-versus-one""one-versus-one""one-versus-one"

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

用于转换特征向量的预处理类型。

默认值: 'normalization' "normalization" "normalization" "normalization" "normalization" "normalization"

值列表: '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

OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle (输出控制)  ocr_svm HOCRSvm, 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_svm (8, 10, 'constant', 'default', CharacterNames, \
                      'rbf', 0.01, 0.01, 'one-versus-all', \
                      'principal_components', 10, OCRHandle)
trainf_ocr_class_svm (OCRHandle, 'letters.trf', 0.001, 'default')
* Re-classify the characters in the image.
do_ocr_multi_class_svm (Characters, Image, OCRHandle, Class)

结果

如果参数有效,算子 create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvmcreate_ocr_class_svm 返回值 2 (H_MSG_TRUE)。如有必要,则抛出异常。

可能的后继

trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmTrainfOcrClassSvmtrainf_ocr_class_svm

替代

create_ocr_class_mlpcreate_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpCreateOcrClassMlpcreate_ocr_class_mlp

另见

do_ocr_single_class_svmdo_ocr_single_class_svmDoOcrSingleClassSvmDoOcrSingleClassSvmDoOcrSingleClassSvmdo_ocr_single_class_svm, do_ocr_multi_class_svmdo_ocr_multi_class_svmDoOcrMultiClassSvmDoOcrMultiClassSvmDoOcrMultiClassSvmdo_ocr_multi_class_svm, clear_ocr_class_svmclear_ocr_class_svmClearOcrClassSvmClearOcrClassSvmClearOcrClassSvmclear_ocr_class_svm, create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvmcreate_class_svm, train_class_svmtrain_class_svmTrainClassSvmTrainClassSvmTrainClassSvmtrain_class_svm, classify_class_svmclassify_class_svmClassifyClassSvmClassifyClassSvmClassifyClassSvmclassify_class_svm

模块

光学字符识别/光学字符验证