// // Copyright 2020 FoxyUtils ehf. All rights reserved. // // This is a commercial product and requires a license to operate. // A trial license can be obtained at https://unidoc.io // // DO NOT EDIT: generated by unitwist Go source code obfuscator. // // Use of this source code is governed by the UniDoc End User License Agreement // terms that can be accessed at https://unidoc.io/eula/ package classer ;import (_dd "github.com/unidoc/unipdf/v3/common";_b "github.com/unidoc/unipdf/v3/internal/jbig2/basic";_f "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_e "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_g "image";_d "math";);const (RankHaus Method =iota ;Correlation ;);type Classer struct{BaseIndex int ;Settings Settings ;ComponentsNumber *_b .IntSlice ;TemplateAreas *_b .IntSlice ;Widths map[int ]int ;Heights map[int ]int ;NumberOfClasses int ;ClassInstances *_f .BitmapsArray ;UndilatedTemplates *_f .Bitmaps ;DilatedTemplates *_f .Bitmaps ;TemplatesSize _b .IntsMap ;FgTemplates *_b .NumSlice ;CentroidPoints *_f .Points ;CentroidPointsTemplates *_f .Points ;ClassIDs *_b .IntSlice ;ComponentPageNumbers *_b .IntSlice ;PtaUL *_f .Points ;PtaLL *_f .Points ;};type Method int ;func (_eef *Classer )ComputeLLCorners ()(_cdg error ){const _ff ="\u0043l\u0061\u0073\u0073\u0065\u0072\u002e\u0043\u006f\u006d\u0070\u0075t\u0065\u004c\u004c\u0043\u006f\u0072\u006e\u0065\u0072\u0073";if _eef .PtaUL ==nil {return _e .Error (_ff ,"\u0055\u004c\u0020\u0043or\u006e\u0065\u0072\u0073\u0020\u006e\u006f\u0074\u0020\u0064\u0065\u0066\u0069\u006ee\u0064");};_gcc :=len (*_eef .PtaUL );_eef .PtaLL =&_f .Points {};var (_fc ,_ec float32 ;_cc ,_fb int ;_ac *_f .Bitmap ;);for _ffd :=0;_ffd < _gcc ;_ffd ++{_fc ,_ec ,_cdg =_eef .PtaUL .GetGeometry (_ffd );if _cdg !=nil {_dd .Log .Debug ("\u0047e\u0074\u0074\u0069\u006e\u0067\u0020\u0050\u0074\u0061\u0055\u004c \u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0076",_cdg );return _e .Wrap (_cdg ,_ff ,"\u0050\u0074\u0061\u0055\u004c\u0020\u0047\u0065\u006fm\u0065\u0074\u0072\u0079");};_cc ,_cdg =_eef .ClassIDs .Get (_ffd );if _cdg !=nil {_dd .Log .Debug ("\u0047\u0065\u0074\u0074\u0069\u006e\u0067\u0020\u0043\u006c\u0061s\u0073\u0049\u0044\u0020\u0066\u0061\u0069\u006c\u0065\u0064:\u0020\u0025\u0076",_cdg );return _e .Wrap (_cdg ,_ff ,"\u0043l\u0061\u0073\u0073\u0049\u0044");};_ac ,_cdg =_eef .UndilatedTemplates .GetBitmap (_cc );if _cdg !=nil {_dd .Log .Debug ("\u0047\u0065t\u0074\u0069\u006e\u0067 \u0055\u006ed\u0069\u006c\u0061\u0074\u0065\u0064\u0054\u0065m\u0070\u006c\u0061\u0074\u0065\u0073\u0020\u0066\u0061\u0069\u006c\u0065d\u003a\u0020\u0025\u0076",_cdg );return _e .Wrap (_cdg ,_ff ,"\u0055\u006e\u0064\u0069la\u0074\u0065\u0064\u0020\u0054\u0065\u006d\u0070\u006c\u0061\u0074\u0065\u0073");};_fb =_ac .Height ;_eef .PtaLL .AddPoint (_fc ,_ec +float32 (_fb ));};return nil ;};func (_ae *Classer )getULCorners (_gf *_f .Bitmap ,_edd *_f .Boxes )error {const _cf ="\u0067\u0065\u0074U\u004c\u0043\u006f\u0072\u006e\u0065\u0072\u0073";if _gf ==nil {return _e .Error (_cf ,"\u006e\u0069l\u0020\u0069\u006da\u0067\u0065\u0020\u0062\u0069\u0074\u006d\u0061\u0070");};if _edd ==nil {return _e .Error (_cf ,"\u006e\u0069\u006c\u0020\u0062\u006f\u0075\u006e\u0064\u0073");};if _ae .PtaUL ==nil {_ae .PtaUL =&_f .Points {};};_fe :=len (*_edd );var (_cg ,_df ,_af ,_bbc int ;_faf ,_gg ,_ag ,_da float32 ;_be error ;_cga *_g .Rectangle ;_bgc *_f .Bitmap ;_ef _g .Point ;);for _bbd :=0;_bbd < _fe ;_bbd ++{_cg =_ae .BaseIndex +_bbd ;if _faf ,_gg ,_be =_ae .CentroidPoints .GetGeometry (_cg );_be !=nil {return _e .Wrap (_be ,_cf ,"\u0043\u0065\u006e\u0074\u0072\u006f\u0069\u0064\u0050o\u0069\u006e\u0074\u0073");};if _df ,_be =_ae .ClassIDs .Get (_cg );_be !=nil {return _e .Wrap (_be ,_cf ,"\u0043\u006c\u0061s\u0073\u0049\u0044\u0073\u002e\u0047\u0065\u0074");};if _ag ,_da ,_be =_ae .CentroidPointsTemplates .GetGeometry (_df );_be !=nil {return _e .Wrap (_be ,_cf ,"\u0043\u0065\u006etr\u006f\u0069\u0064\u0050\u006f\u0069\u006e\u0074\u0073\u0054\u0065\u006d\u0070\u006c\u0061\u0074\u0065\u0073");};_ggb :=_ag -_faf ;_ebe :=_da -_gg ;if _ggb >=0{_af =int (_ggb +0.5);}else {_af =int (_ggb -0.5);};if _ebe >=0{_bbc =int (_ebe +0.5);}else {_bbc =int (_ebe -0.5);};if _cga ,_be =_edd .Get (_bbd );_be !=nil {return _e .Wrap (_be ,_cf ,"");};_bee ,_ebf :=_cga .Min .X ,_cga .Min .Y ;_bgc ,_be =_ae .UndilatedTemplates .GetBitmap (_df );if _be !=nil {return _e .Wrap (_be ,_cf ,"\u0055\u006e\u0064\u0069\u006c\u0061\u0074\u0065\u0064\u0054e\u006d\u0070\u006c\u0061\u0074\u0065\u0073.\u0047\u0065\u0074\u0028\u0069\u0043\u006c\u0061\u0073\u0073\u0029");};_ef ,_be =_ded (_gf ,_bee ,_ebf ,_af ,_bbc ,_bgc );if _be !=nil {return _e .Wrap (_be ,_cf ,"");};_ae .PtaUL .AddPoint (float32 (_bee -_af +_ef .X ),float32 (_ebf -_bbc +_ef .Y ));};return nil ;};func (_agg *Classer )verifyMethod (_fcg Method )error {if _fcg !=RankHaus &&_fcg !=Correlation {return _e .Error ("\u0076\u0065\u0072i\u0066\u0079\u004d\u0065\u0074\u0068\u006f\u0064","\u0069\u006e\u0076\u0061li\u0064\u0020\u0063\u006c\u0061\u0073\u0073\u0065\u0072\u0020\u006d\u0065\u0074\u0068o\u0064");};return nil ;};func (_bgd *Classer )classifyCorrelation (_eg *_f .Boxes ,_ebg *_f .Bitmaps ,_cda int )error {const _ffa ="\u0063\u006c\u0061\u0073si\u0066\u0079\u0043\u006f\u0072\u0072\u0065\u006c\u0061\u0074\u0069\u006f\u006e";if _eg ==nil {return _e .Error (_ffa ,"\u006e\u0065\u0077\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074\u0073\u0020\u0062\u006f\u0075\u006e\u0064\u0069\u006e\u0067\u0020\u0062o\u0078\u0065\u0073\u0020\u006eo\u0074\u0020f\u006f\u0075\u006e\u0064");};if _ebg ==nil {return _e .Error (_ffa ,"\u006e\u0065wC\u006f\u006d\u0070o\u006e\u0065\u006e\u0074s b\u0069tm\u0061\u0070\u0020\u0061\u0072\u0072\u0061y \u006e\u006f\u0074\u0020\u0066\u006f\u0075n\u0064");};_cgae :=len (_ebg .Values );if _cgae ==0{_dd .Log .Debug ("\u0063l\u0061\u0073s\u0069\u0066\u0079C\u006f\u0072\u0072\u0065\u006c\u0061\u0074i\u006f\u006e\u0020\u002d\u0020\u0070r\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0070\u0069\u0078\u0061s\u0020\u0069\u0073\u0020\u0065\u006d\u0070\u0074\u0079");return nil ;};var (_cag ,_bed *_f .Bitmap ;_aa error ;);_dg :=&_f .Bitmaps {Values :make ([]*_f .Bitmap ,_cgae )};for _aag ,_fce :=range _ebg .Values {_bed ,_aa =_fce .AddBorderGeneral (JbAddedPixels ,JbAddedPixels ,JbAddedPixels ,JbAddedPixels ,0);if _aa !=nil {return _e .Wrap (_aa ,_ffa ,"");};_dg .Values [_aag ]=_bed ;};_ggbg :=_bgd .FgTemplates ;_fcb :=_f .MakePixelSumTab8 ();_bef :=_f .MakePixelCentroidTab8 ();_afa :=make ([]int ,_cgae );_feg :=make ([][]int ,_cgae );_eab :=_f .Points (make ([]_f .Point ,_cgae ));_aad :=&_eab ;var (_fcgc ,_acb int ;_ga ,_eec ,_eecb int ;_ddd ,_eff int ;_fd byte ;);for _dgb ,_fag :=range _dg .Values {_feg [_dgb ]=make ([]int ,_fag .Height );_fcgc =0;_acb =0;_eec =(_fag .Height -1)*_fag .RowStride ;_ga =0;for _eff =_fag .Height -1;_eff >=0;_eff ,_eec =_eff -1,_eec -_fag .RowStride {_feg [_dgb ][_eff ]=_ga ;_eecb =0;for _ddd =0;_ddd < _fag .RowStride ;_ddd ++{_fd =_fag .Data [_eec +_ddd ];_eecb +=_fcb [_fd ];_fcgc +=_bef [_fd ]+_ddd *8*_fcb [_fd ];};_ga +=_eecb ;_acb +=_eecb *_eff ;};_afa [_dgb ]=_ga ;if _ga > 0{(*_aad )[_dgb ]=_f .Point {X :float32 (_fcgc )/float32 (_ga ),Y :float32 (_acb )/float32 (_ga )};}else {(*_aad )[_dgb ]=_f .Point {X :float32 (_fag .Width )/float32 (2),Y :float32 (_fag .Height )/float32 (2)};};};if _aa =_bgd .CentroidPoints .Add (_aad );_aa !=nil {return _e .Wrap (_aa ,_ffa ,"\u0063\u0065\u006et\u0072\u006f\u0069\u0064\u0020\u0061\u0064\u0064");};var (_ebb ,_eaf ,_bge int ;_agf float64 ;_ebbe ,_bebd ,_dgd ,_gbe float32 ;_def ,_gff _f .Point ;_aff bool ;_fafe *similarTemplatesFinder ;_fg int ;_dff *_f .Bitmap ;_bbf *_g .Rectangle ;_bgg *_f .Bitmaps ;);for _fg ,_bed =range _dg .Values {_eaf =_afa [_fg ];if _ebbe ,_bebd ,_aa =_aad .GetGeometry (_fg );_aa !=nil {return _e .Wrap (_aa ,_ffa ,"\u0070t\u0061\u0020\u002d\u0020\u0069");};_aff =false ;_ebeb :=len (_bgd .UndilatedTemplates .Values );_fafe =_eeb (_bgd ,_bed );for _cgg :=_fafe .Next ();_cgg > -1;{if _dff ,_aa =_bgd .UndilatedTemplates .GetBitmap (_cgg );_aa !=nil {return _e .Wrap (_aa ,_ffa ,"\u0075\u006e\u0069dl\u0061\u0074\u0065\u0064\u005b\u0069\u0063\u006c\u0061\u0073\u0073\u005d\u0020\u003d\u0020\u0062\u006d\u0032");};if _bge ,_aa =_ggbg .GetInt (_cgg );_aa !=nil {_dd .Log .Trace ("\u0046\u0047\u0020T\u0065\u006d\u0070\u006ca\u0074\u0065\u0020\u005b\u0069\u0063\u006ca\u0073\u0073\u005d\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0076",_aa );};if _dgd ,_gbe ,_aa =_bgd .CentroidPointsTemplates .GetGeometry (_cgg );_aa !=nil {return _e .Wrap (_aa ,_ffa ,"\u0043\u0065\u006e\u0074\u0072\u006f\u0069\u0064\u0050\u006f\u0069\u006e\u0074T\u0065\u006d\u0070\u006c\u0061\u0074e\u0073\u005b\u0069\u0063\u006c\u0061\u0073\u0073\u005d\u0020\u003d\u0020\u00782\u002c\u0079\u0032\u0020");};if _bgd .Settings .WeightFactor > 0.0{if _ebb ,_aa =_bgd .TemplateAreas .Get (_cgg );_aa !=nil {_dd .Log .Trace ("\u0054\u0065\u006dp\u006c\u0061\u0074\u0065A\u0072\u0065\u0061\u0073\u005b\u0069\u0063l\u0061\u0073\u0073\u005d\u0020\u003d\u0020\u0061\u0072\u0065\u0061\u0020\u0025\u0076",_aa );};_agf =_bgd .Settings .Thresh +(1.0-_bgd .Settings .Thresh )*_bgd .Settings .WeightFactor *float64 (_bge )/float64 (_ebb );}else {_agf =_bgd .Settings .Thresh ;};_dbdf ,_bd :=_f .CorrelationScoreThresholded (_bed ,_dff ,_eaf ,_bge ,_def .X -_gff .X ,_def .Y -_gff .Y ,MaxDiffWidth ,MaxDiffHeight ,_fcb ,_feg [_fg ],float32 (_agf ));if _bd !=nil {return _e .Wrap (_bd ,_ffa ,"");};if _eee {var (_geg ,_ceb float64 ;_gce ,_fcef int ;);_geg ,_bd =_f .CorrelationScore (_bed ,_dff ,_eaf ,_bge ,_ebbe -_dgd ,_bebd -_gbe ,MaxDiffWidth ,MaxDiffHeight ,_fcb );if _bd !=nil {return _e .Wrap (_bd ,_ffa ,"d\u0065\u0062\u0075\u0067Co\u0072r\u0065\u006c\u0061\u0074\u0069o\u006e\u0053\u0063\u006f\u0072\u0065");};_ceb ,_bd =_f .CorrelationScoreSimple (_bed ,_dff ,_eaf ,_bge ,_ebbe -_dgd ,_bebd -_gbe ,MaxDiffWidth ,MaxDiffHeight ,_fcb );if _bd !=nil {return _e .Wrap (_bd ,_ffa ,"d\u0065\u0062\u0075\u0067Co\u0072r\u0065\u006c\u0061\u0074\u0069o\u006e\u0053\u0063\u006f\u0072\u0065");};_gce =int (_d .Sqrt (_geg *float64 (_eaf )*float64 (_bge )));_fcef =int (_d .Sqrt (_ceb *float64 (_eaf )*float64 (_bge )));if (_geg >=_agf )!=(_ceb >=_agf ){return _e .Errorf (_ffa ,"\u0064\u0065\u0062\u0075\u0067\u0020\u0043\u006f\u0072r\u0065\u006c\u0061\u0074\u0069\u006f\u006e\u0020\u0073\u0063\u006f\u0072\u0065\u0020\u006d\u0069\u0073\u006d\u0061\u0074\u0063\u0068\u0020-\u0020\u0025d\u0028\u00250\u002e\u0034\u0066\u002c\u0020\u0025\u0076\u0029\u0020\u0076\u0073\u0020\u0025d(\u0025\u0030\u002e\u0034\u0066\u002c\u0020\u0025\u0076)\u0020\u0025\u0030\u002e\u0034\u0066",_gce ,_geg ,_geg >=_agf ,_fcef ,_ceb ,_ceb >=_agf ,_geg -_ceb );};if _geg >=_agf !=_dbdf {return _e .Errorf (_ffa ,"\u0064\u0065\u0062\u0075\u0067\u0020\u0043o\u0072\u0072\u0065\u006c\u0061\u0074\u0069\u006f\u006e \u0073\u0063\u006f\u0072\u0065 \u004d\u0069\u0073\u006d\u0061t\u0063\u0068 \u0062\u0065\u0074w\u0065\u0065\u006e\u0020\u0063\u006frr\u0065\u006c\u0061\u0074\u0069\u006f\u006e\u0020/\u0020\u0074\u0068\u0072\u0065s\u0068\u006f\u006c\u0064\u002e\u0020\u0043\u006f\u006dpa\u0072\u0069\u0073\u006f\u006e:\u0020\u0025\u0030\u002e\u0034\u0066\u0028\u0025\u0030\u002e\u0034\u0066\u002c\u0020\u0025\u0064\u0029\u0020\u003e\u003d\u0020\u00250\u002e\u0034\u0066\u0028\u0025\u0030\u002e\u0034\u0066\u0029\u0020\u0076\u0073\u0020\u0025\u0076",_geg ,_geg *float64 (_eaf )*float64 (_bge ),_gce ,_agf ,float32 (_agf )*float32 (_eaf )*float32 (_bge ),_dbdf );};};if _dbdf {_aff =true ;if _bd =_bgd .ClassIDs .Add (_cgg );_bd !=nil {return _e .Wrap (_bd ,_ffa ,"\u006f\u0076\u0065\u0072\u0054\u0068\u0072\u0065\u0073\u0068\u006f\u006c\u0064");};if _bd =_bgd .ComponentPageNumbers .Add (_cda );_bd !=nil {return _e .Wrap (_bd ,_ffa ,"\u006f\u0076\u0065\u0072\u0054\u0068\u0072\u0065\u0073\u0068\u006f\u006c\u0064");};if _bgd .Settings .KeepClassInstances {if _cag ,_bd =_ebg .GetBitmap (_fg );_bd !=nil {return _e .Wrap (_bd ,_ffa ,"\u004b\u0065\u0065\u0070Cl\u0061\u0073\u0073\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0073\u0020\u002d \u0069");};if _bgg ,_bd =_bgd .ClassInstances .GetBitmaps (_cgg );_bd !=nil {return _e .Wrap (_bd ,_ffa ,"K\u0065\u0065\u0070\u0043\u006c\u0061s\u0073\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065s\u0020\u002d\u0020i\u0043l\u0061\u0073\u0073");};_bgg .AddBitmap (_cag );if _bbf ,_bd =_eg .Get (_fg );_bd !=nil {return _e .Wrap (_bd ,_ffa ,"\u004be\u0065p\u0043\u006c\u0061\u0073\u0073I\u006e\u0073t\u0061\u006e\u0063\u0065\u0073");};_bgg .AddBox (_bbf );};break ;};};if !_aff {if _aa =_bgd .ClassIDs .Add (_ebeb );_aa !=nil {return _e .Wrap (_aa ,_ffa ,"\u0021\u0066\u006f\u0075\u006e\u0064");};if _aa =_bgd .ComponentPageNumbers .Add (_cda );_aa !=nil {return _e .Wrap (_aa ,_ffa ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_bgg =&_f .Bitmaps {};if _cag ,_aa =_ebg .GetBitmap (_fg );_aa !=nil {return _e .Wrap (_aa ,_ffa ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_bgg .AddBitmap (_cag );_ega ,_ebfg :=_cag .Width ,_cag .Height ;_fge :=uint64 (_ebfg )*uint64 (_ega );_bgd .TemplatesSize .Add (_fge ,_ebeb );if _bbf ,_aa =_eg .Get (_fg );_aa !=nil {return _e .Wrap (_aa ,_ffa ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_bgg .AddBox (_bbf );_bgd .ClassInstances .AddBitmaps (_bgg );_bgd .CentroidPointsTemplates .AddPoint (_ebbe ,_bebd );_bgd .FgTemplates .AddInt (_eaf );_bgd .UndilatedTemplates .AddBitmap (_cag );_ebb =(_bed .Width -2*JbAddedPixels )*(_bed .Height -2*JbAddedPixels );if _aa =_bgd .TemplateAreas .Add (_ebb );_aa !=nil {return _e .Wrap (_aa ,_ffa ,"\u0021\u0066\u006f\u0075\u006e\u0064");};};};_bgd .NumberOfClasses =len (_bgd .UndilatedTemplates .Values );return nil ;};func (_acg *Classer )classifyRankHaus (_gec *_f .Boxes ,_fae *_f .Bitmaps ,_abf int )error {const _eabg ="\u0063\u006ca\u0073\u0073\u0069f\u0079\u0052\u0061\u006e\u006b\u0048\u0061\u0075\u0073";if _gec ==nil {return _e .Error (_eabg ,"\u0062\u006fx\u0061\u0020\u006eo\u0074\u0020\u0064\u0065\u0066\u0069\u006e\u0065\u0064");};if _fae ==nil {return _e .Error (_eabg ,"\u0070\u0069x\u0061\u0020\u006eo\u0074\u0020\u0064\u0065\u0066\u0069\u006e\u0065\u0064");};_ebd :=len (_fae .Values );if _ebd ==0{return _e .Error (_eabg ,"e\u006dp\u0074\u0079\u0020\u006e\u0065\u0077\u0020\u0063o\u006d\u0070\u006f\u006een\u0074\u0073");};_defa :=_fae .CountPixels ();_aca :=_acg .Settings .SizeHaus ;_gcae :=_f .SelCreateBrick (_aca ,_aca ,_aca /2,_aca /2,_f .SelHit );_efa :=&_f .Bitmaps {Values :make ([]*_f .Bitmap ,_ebd )};_gbd :=&_f .Bitmaps {Values :make ([]*_f .Bitmap ,_ebd )};var (_ccg ,_cdb ,_beed *_f .Bitmap ;_eda error ;);for _bbdb :=0;_bbdb < _ebd ;_bbdb ++{_ccg ,_eda =_fae .GetBitmap (_bbdb );if _eda !=nil {return _e .Wrap (_eda ,_eabg ,"");};_cdb ,_eda =_ccg .AddBorderGeneral (JbAddedPixels ,JbAddedPixels ,JbAddedPixels ,JbAddedPixels ,0);if _eda !=nil {return _e .Wrap (_eda ,_eabg ,"");};_beed ,_eda =_f .Dilate (nil ,_cdb ,_gcae );if _eda !=nil {return _e .Wrap (_eda ,_eabg ,"");};_efa .Values [_ebd ]=_cdb ;_gbd .Values [_ebd ]=_beed ;};_cec ,_eda :=_f .Centroids (_efa .Values );if _eda !=nil {return _e .Wrap (_eda ,_eabg ,"");};if _eda =_cec .Add (_acg .CentroidPoints );_eda !=nil {_dd .Log .Trace ("\u004e\u006f\u0020\u0063en\u0074\u0072\u006f\u0069\u0064\u0073\u0020\u0074\u006f\u0020\u0061\u0064\u0064");};if _acg .Settings .RankHaus ==1.0{_eda =_acg .classifyRankHouseOne (_gec ,_fae ,_efa ,_gbd ,_cec ,_abf );}else {_eda =_acg .classifyRankHouseNonOne (_gec ,_fae ,_efa ,_gbd ,_cec ,_defa ,_abf );};if _eda !=nil {return _e .Wrap (_eda ,_eabg ,"");};return nil ;};func (_abc *Settings )SetDefault (){if _abc .MaxCompWidth ==0{switch _abc .Components {case _f .ComponentConn :_abc .MaxCompWidth =MaxConnCompWidth ;case _f .ComponentCharacters :_abc .MaxCompWidth =MaxCharCompWidth ;case _f .ComponentWords :_abc .MaxCompWidth =MaxWordCompWidth ;};};if _abc .MaxCompHeight ==0{_abc .MaxCompHeight =MaxCompHeight ;};if _abc .Thresh ==0.0{_abc .Thresh =0.9;};if _abc .WeightFactor ==0.0{_abc .WeightFactor =0.75;};if _abc .RankHaus ==0.0{_abc .RankHaus =0.97;};if _abc .SizeHaus ==0{_abc .SizeHaus =2;};};func _ded (_dc *_f .Bitmap ,_dda ,_gca ,_aee ,_acf int ,_bf *_f .Bitmap )(_bc _g .Point ,_cca error ){const _efb ="\u0066i\u006e\u0061\u006c\u0041l\u0069\u0067\u006e\u006d\u0065n\u0074P\u006fs\u0069\u0074\u0069\u006f\u006e\u0069\u006eg";if _dc ==nil {return _bc ,_e .Error (_efb ,"\u0073\u006f\u0075\u0072ce\u0020\u006e\u006f\u0074\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");};if _bf ==nil {return _bc ,_e .Error (_efb ,"t\u0065\u006d\u0070\u006cat\u0065 \u006e\u006f\u0074\u0020\u0070r\u006f\u0076\u0069\u0064\u0065\u0064");};_cb ,_fac :=_bf .Width ,_bf .Height ;_dfc ,_db :=_dda -_aee -JbAddedPixels ,_gca -_acf -JbAddedPixels ;_dd .Log .Trace ("\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u002c\u0020\u0079\u003a\u0020\u0027\u0025\u0064'\u002c\u0020\u0077\u003a\u0020\u0027\u0025\u0064\u0027\u002c\u0020\u0068\u003a \u0027\u0025\u0064\u0027\u002c\u0020\u0062\u0078\u003a\u0020\u0027\u0025d'\u002c\u0020\u0062\u0079\u003a\u0020\u0027\u0025\u0064\u0027",_dda ,_gca ,_cb ,_fac ,_dfc ,_db );_ce ,_cca :=_f .Rect (_dfc ,_db ,_cb ,_fac );if _cca !=nil {return _bc ,_e .Wrap (_cca ,_efb ,"");};_ab ,_ ,_cca :=_dc .ClipRectangle (_ce );if _cca !=nil {_dd .Log .Error ("\u0043a\u006e\u0027\u0074\u0020\u0063\u006c\u0069\u0070\u0020\u0072\u0065c\u0074\u0061\u006e\u0067\u006c\u0065\u003a\u0020\u0025\u0076",_ce );return _bc ,_e .Wrap (_cca ,_efb ,"");};_beb :=_f .New (_ab .Width ,_ab .Height );_dfcg :=_d .MaxInt32 ;var _edde ,_ece ,_dbd ,_gbf ,_efe int ;for _edde =-1;_edde <=1;_edde ++{for _ece =-1;_ece <=1;_ece ++{if _ ,_cca =_f .Copy (_beb ,_ab );_cca !=nil {return _bc ,_e .Wrap (_cca ,_efb ,"");};if _cca =_beb .RasterOperation (_ece ,_edde ,_cb ,_fac ,_f .PixSrcXorDst ,_bf ,0,0);_cca !=nil {return _bc ,_e .Wrap (_cca ,_efb ,"");};_dbd =_beb .CountPixels ();if _dbd < _dfcg {_gbf =_ece ;_efe =_edde ;_dfcg =_dbd ;};};};_bc .X =_gbf ;_bc .Y =_efe ;return _bc ,nil ;};const (MaxDiffWidth =2;MaxDiffHeight =2;);func DefaultSettings ()Settings {_ceg :=&Settings {};_ceg .SetDefault ();return *_ceg };var TwoByTwoWalk =[]int {0,0,0,1,-1,0,0,-1,1,0,-1,1,1,1,-1,-1,1,-1,0,-2,2,0,0,2,-2,0,-1,-2,1,-2,2,-1,2,1,1,2,-1,2,-2,1,-2,-1,-2,-2,2,-2,2,2,-2,2};var _eee bool ;const (MaxConnCompWidth =350;MaxCharCompWidth =350;MaxWordCompWidth =1000;MaxCompHeight =120;);type similarTemplatesFinder struct{Classer *Classer ;Width int ;Height int ;Index int ;CurrentNumbers []int ;N int ;};type Settings struct{MaxCompWidth int ;MaxCompHeight int ;SizeHaus int ;RankHaus float64 ;Thresh float64 ;WeightFactor float64 ;KeepClassInstances bool ;Components _f .Component ;Method Method ;};func _eeb (_gd *Classer ,_dedd *_f .Bitmap )*similarTemplatesFinder {return &similarTemplatesFinder {Width :_dedd .Width ,Height :_dedd .Height ,Classer :_gd };};func (_ecfg Settings )Validate ()error {const _ecb ="\u0053\u0065\u0074\u0074\u0069\u006e\u0067\u0073\u002e\u0056\u0061\u006ci\u0064\u0061\u0074\u0065";if _ecfg .Thresh < 0.4||_ecfg .Thresh > 0.98{return _e .Error (_ecb ,"\u006a\u0062i\u0067\u0032\u0020\u0065\u006e\u0063\u006f\u0064\u0065\u0072\u0020\u0074\u0068\u0072\u0065\u0073\u0068\u0020\u006e\u006f\u0074\u0020\u0069\u006e\u0020\u0072\u0061\u006e\u0067\u0065\u0020\u005b\u0030\u002e\u0034\u0020\u002d\u0020\u0030\u002e\u0039\u0038\u005d");};if _ecfg .WeightFactor < 0.0||_ecfg .WeightFactor > 1.0{return _e .Error (_ecb ,"\u006a\u0062i\u0067\u0032\u0020\u0065\u006ec\u006f\u0064\u0065\u0072\u0020w\u0065\u0069\u0067\u0068\u0074\u0020\u0066\u0061\u0063\u0074\u006f\u0072\u0020\u006e\u006f\u0074\u0020\u0069\u006e\u0020\u0072\u0061\u006e\u0067\u0065\u0020\u005b\u0030\u002e\u0030\u0020\u002d\u0020\u0031\u002e\u0030\u005d");};if _ecfg .RankHaus < 0.5||_ecfg .RankHaus > 1.0{return _e .Error (_ecb ,"\u006a\u0062\u0069\u0067\u0032\u0020\u0065\u006e\u0063\u006f\u0064\u0065\u0072\u0020\u0072a\u006e\u006b\u0020\u0068\u0061\u0075\u0073\u0020\u0076\u0061\u006c\u0075\u0065 \u006e\u006f\u0074\u0020\u0069\u006e\u0020\u0072\u0061\u006e\u0067\u0065 [\u0030\u002e\u0035\u0020\u002d\u0020\u0031\u002e\u0030\u005d");};if _ecfg .SizeHaus < 1||_ecfg .SizeHaus > 10{return _e .Error (_ecb ,"\u006a\u0062\u0069\u0067\u0032 \u0065\u006e\u0063\u006f\u0064\u0065\u0072\u0020\u0073\u0069\u007a\u0065\u0020h\u0061\u0075\u0073\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u006e\u006f\u0074\u0020\u0069\u006e\u0020\u0072\u0061\u006e\u0067\u0065\u0020\u005b\u0031\u0020\u002d\u0020\u0031\u0030]");};switch _ecfg .Components {case _f .ComponentConn ,_f .ComponentCharacters ,_f .ComponentWords :default:return _e .Error (_ecb ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0063\u006c\u0061\u0073s\u0065r\u0020c\u006f\u006d\u0070\u006f\u006e\u0065\u006et");};return nil ;};func Init (settings Settings )(*Classer ,error ){const _ee ="\u0063\u006c\u0061s\u0073\u0065\u0072\u002e\u0049\u006e\u0069\u0074";_gc :=&Classer {Settings :settings ,Widths :map[int ]int {},Heights :map[int ]int {},TemplatesSize :_b .IntsMap {},TemplateAreas :&_b .IntSlice {},ComponentPageNumbers :&_b .IntSlice {},ClassIDs :&_b .IntSlice {},ComponentsNumber :&_b .IntSlice {},CentroidPoints :&_f .Points {},CentroidPointsTemplates :&_f .Points {},UndilatedTemplates :&_f .Bitmaps {},DilatedTemplates :&_f .Bitmaps {},ClassInstances :&_f .BitmapsArray {},FgTemplates :&_b .NumSlice {}};if _ed :=_gc .Settings .Validate ();_ed !=nil {return nil ,_e .Wrap (_ed ,_ee ,"");};return _gc ,nil ;};func (_c *Classer )AddPage (inputPage *_f .Bitmap ,pageNumber int ,method Method )(_cd error ){const _ca ="\u0043l\u0061s\u0073\u0065\u0072\u002e\u0041\u0064\u0064\u0050\u0061\u0067\u0065";_c .Widths [pageNumber ]=inputPage .Width ;_c .Heights [pageNumber ]=inputPage .Height ;if _cd =_c .verifyMethod (method );_cd !=nil {return _e .Wrap (_cd ,_ca ,"");};_de ,_ea ,_cd :=inputPage .GetComponents (_c .Settings .Components ,_c .Settings .MaxCompWidth ,_c .Settings .MaxCompHeight );if _cd !=nil {return _e .Wrap (_cd ,_ca ,"");};_dd .Log .Debug ("\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074s\u003a\u0020\u0025\u0076",_de );if _cd =_c .addPageComponents (inputPage ,_ea ,_de ,pageNumber ,method );_cd !=nil {return _e .Wrap (_cd ,_ca ,"");};return nil ;};func (_gab *similarTemplatesFinder )Next ()int {var (_dfce ,_edb ,_ddf ,_fga int ;_cad bool ;_dga *_f .Bitmap ;_agc error ;);for {if _gab .Index >=25{return -1;};_edb =_gab .Width +TwoByTwoWalk [2*_gab .Index ];_dfce =_gab .Height +TwoByTwoWalk [2*_gab .Index +1];if _dfce < 1||_edb < 1{_gab .Index ++;continue ;};if len (_gab .CurrentNumbers )==0{_gab .CurrentNumbers ,_cad =_gab .Classer .TemplatesSize .GetSlice (uint64 (_edb )*uint64 (_dfce ));if !_cad {_gab .Index ++;continue ;};_gab .N =0;};_ddf =len (_gab .CurrentNumbers );for ;_gab .N < _ddf ;_gab .N ++{_fga =_gab .CurrentNumbers [_gab .N ];_dga ,_agc =_gab .Classer .DilatedTemplates .GetBitmap (_fga );if _agc !=nil {_dd .Log .Debug ("\u0046\u0069\u006e\u0064\u004e\u0065\u0078\u0074\u0054\u0065\u006d\u0070\u006c\u0061\u0074\u0065\u003a\u0020\u0074\u0065\u006d\u0070\u006c\u0061t\u0065\u0020\u006e\u006f\u0074 \u0066\u006fu\u006e\u0064\u003a\u0020");return 0;};if _dga .Width -2*JbAddedPixels ==_edb &&_dga .Height -2*JbAddedPixels ==_dfce {return _fga ;};};_gab .Index ++;_gab .CurrentNumbers =nil ;};};const JbAddedPixels =6;func (_bgb *Classer )classifyRankHouseOne (_ccac *_f .Boxes ,_dddf ,_daa ,_dec *_f .Bitmaps ,_abd *_f .Points ,_edc int )(_aeb error ){const _dce ="\u0043\u006c\u0061\u0073s\u0065\u0072\u002e\u0063\u006c\u0061\u0073\u0073\u0069\u0066y\u0052a\u006e\u006b\u0048\u006f\u0075\u0073\u0065O\u006e\u0065";var (_ba ,_bda ,_bcd ,_egf float32 ;_abdf int ;_ced ,_ace ,_efd ,_dbb ,_gaf *_f .Bitmap ;_acgb ,_bde bool ;);for _efc :=0;_efc < len (_dddf .Values );_efc ++{_ace =_daa .Values [_efc ];_efd =_dec .Values [_efc ];_ba ,_bda ,_aeb =_abd .GetGeometry (_efc );if _aeb !=nil {return _e .Wrapf (_aeb ,_dce ,"\u0066\u0069\u0072\u0073\u0074\u0020\u0067\u0065\u006fm\u0065\u0074\u0072\u0079");};_gfa :=len (_bgb .UndilatedTemplates .Values );_acgb =false ;_ffb :=_eeb (_bgb ,_ace );for _abdf =_ffb .Next ();_abdf > -1;{_dbb ,_aeb =_bgb .UndilatedTemplates .GetBitmap (_abdf );if _aeb !=nil {return _e .Wrap (_aeb ,_dce ,"\u0062\u006d\u0033");};_gaf ,_aeb =_bgb .DilatedTemplates .GetBitmap (_abdf );if _aeb !=nil {return _e .Wrap (_aeb ,_dce ,"\u0062\u006d\u0034");};_bcd ,_egf ,_aeb =_bgb .CentroidPointsTemplates .GetGeometry (_abdf );if _aeb !=nil {return _e .Wrap (_aeb ,_dce ,"\u0043\u0065\u006e\u0074\u0072\u006f\u0069\u0064\u0054\u0065\u006d\u0070l\u0061\u0074\u0065\u0073");};_bde ,_aeb =_f .HausTest (_ace ,_efd ,_dbb ,_gaf ,_ba -_bcd ,_bda -_egf ,MaxDiffWidth ,MaxDiffHeight );if _aeb !=nil {return _e .Wrap (_aeb ,_dce ,"");};if _bde {_acgb =true ;if _aeb =_bgb .ClassIDs .Add (_abdf );_aeb !=nil {return _e .Wrap (_aeb ,_dce ,"");};if _aeb =_bgb .ComponentPageNumbers .Add (_edc );_aeb !=nil {return _e .Wrap (_aeb ,_dce ,"");};if _bgb .Settings .KeepClassInstances {_eafd ,_ebdc :=_bgb .ClassInstances .GetBitmaps (_abdf );if _ebdc !=nil {return _e .Wrap (_ebdc ,_dce ,"\u004be\u0065\u0070\u0050\u0069\u0078\u0061a");};_ced ,_ebdc =_dddf .GetBitmap (_efc );if _ebdc !=nil {return _e .Wrap (_ebdc ,_dce ,"\u004be\u0065\u0070\u0050\u0069\u0078\u0061a");};_eafd .AddBitmap (_ced );_gaa ,_ebdc :=_ccac .Get (_efc );if _ebdc !=nil {return _e .Wrap (_ebdc ,_dce ,"\u004be\u0065\u0070\u0050\u0069\u0078\u0061a");};_eafd .AddBox (_gaa );};break ;};};if !_acgb {if _aeb =_bgb .ClassIDs .Add (_gfa );_aeb !=nil {return _e .Wrap (_aeb ,_dce ,"");};if _aeb =_bgb .ComponentPageNumbers .Add (_edc );_aeb !=nil {return _e .Wrap (_aeb ,_dce ,"");};_ffbc :=&_f .Bitmaps {};_ced ,_aeb =_dddf .GetBitmap (_efc );if _aeb !=nil {return _e .Wrap (_aeb ,_dce ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_ffbc .Values =append (_ffbc .Values ,_ced );_ebdb ,_ffag :=_ced .Width ,_ced .Height ;_bgb .TemplatesSize .Add (uint64 (_ffag )*uint64 (_ebdb ),_gfa );_edac ,_beg :=_ccac .Get (_efc );if _beg !=nil {return _e .Wrap (_beg ,_dce ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_ffbc .AddBox (_edac );_bgb .ClassInstances .AddBitmaps (_ffbc );_bgb .CentroidPointsTemplates .AddPoint (_ba ,_bda );_bgb .UndilatedTemplates .AddBitmap (_ace );_bgb .DilatedTemplates .AddBitmap (_efd );};};return nil ;};func (_gb *Classer )addPageComponents (_ge *_f .Bitmap ,_cdd *_f .Boxes ,_fa *_f .Bitmaps ,_fbf int ,_bg Method )error {const _bb ="\u0043l\u0061\u0073\u0073\u0065r\u002e\u0041\u0064\u0064\u0050a\u0067e\u0043o\u006d\u0070\u006f\u006e\u0065\u006e\u0074s";if _ge ==nil {return _e .Error (_bb ,"\u006e\u0069\u006c\u0020\u0069\u006e\u0070\u0075\u0074 \u0070\u0061\u0067\u0065");};if _cdd ==nil ||_fa ==nil ||len (*_cdd )==0{_dd .Log .Trace ("\u0041\u0064\u0064P\u0061\u0067\u0065\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074\u0073\u003a\u0020\u0025\u0073\u002e\u0020\u004e\u006f\u0020\u0063\u006f\u006d\u0070\u006f\u006e\u0065n\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064",_ge );return nil ;};var _fca error ;switch _bg {case RankHaus :_fca =_gb .classifyRankHaus (_cdd ,_fa ,_fbf );case Correlation :_fca =_gb .classifyCorrelation (_cdd ,_fa ,_fbf );default:_dd .Log .Debug ("\u0055\u006ek\u006e\u006f\u0077\u006e\u0020\u0063\u006c\u0061\u0073\u0073\u0069\u0066\u0079\u0020\u006d\u0065\u0074\u0068\u006f\u0064\u003a\u0020'%\u0076\u0027",_bg );return _e .Error (_bb ,"\u0075\u006e\u006bno\u0077\u006e\u0020\u0063\u006c\u0061\u0073\u0073\u0069\u0066\u0079\u0020\u006d\u0065\u0074\u0068\u006f\u0064");};if _fca !=nil {return _e .Wrap (_fca ,_bb ,"");};if _fca =_gb .getULCorners (_ge ,_cdd );_fca !=nil {return _e .Wrap (_fca ,_bb ,"");};_eb :=len (*_cdd );_gb .BaseIndex +=_eb ;if _fca =_gb .ComponentsNumber .Add (_eb );_fca !=nil {return _e .Wrap (_fca ,_bb ,"");};return nil ;};func (_fbb *Classer )classifyRankHouseNonOne (_egac *_f .Boxes ,_ffbb ,_eeed ,_ebfb *_f .Bitmaps ,_cfa *_f .Points ,_fff *_b .NumSlice ,_fbg int )(_dedg error ){const _deff ="\u0043\u006c\u0061\u0073s\u0065\u0072\u002e\u0063\u006c\u0061\u0073\u0073\u0069\u0066y\u0052a\u006e\u006b\u0048\u006f\u0075\u0073\u0065O\u006e\u0065";var (_bfe ,_ebgg ,_aadg ,_ecd float32 ;_ddg ,_ecf ,_ggd int ;_cagf ,_afd ,_aeed ,_gee ,_baa *_f .Bitmap ;_bbg ,_afb bool ;);_ddda :=_f .MakePixelSumTab8 ();for _fde :=0;_fde < len (_ffbb .Values );_fde ++{if _afd ,_dedg =_eeed .GetBitmap (_fde );_dedg !=nil {return _e .Wrap (_dedg ,_deff ,"b\u006d\u0073\u0031\u002e\u0047\u0065\u0074\u0028\u0069\u0029");};if _ddg ,_dedg =_fff .GetInt (_fde );_dedg !=nil {_dd .Log .Trace ("\u0047\u0065t\u0074\u0069\u006e\u0067 \u0046\u0047T\u0065\u006d\u0070\u006c\u0061\u0074\u0065\u0073 \u0061\u0074\u003a\u0020\u0025\u0064\u0020\u0066\u0061\u0069\u006c\u0065d\u003a\u0020\u0025\u0076",_fde ,_dedg );};if _aeed ,_dedg =_ebfb .GetBitmap (_fde );_dedg !=nil {return _e .Wrap (_dedg ,_deff ,"b\u006d\u0073\u0032\u002e\u0047\u0065\u0074\u0028\u0069\u0029");};if _bfe ,_ebgg ,_dedg =_cfa .GetGeometry (_fde );_dedg !=nil {return _e .Wrapf (_dedg ,_deff ,"\u0070t\u0061[\u0069\u005d\u002e\u0047\u0065\u006f\u006d\u0065\u0074\u0072\u0079");};_cdaf :=len (_fbb .UndilatedTemplates .Values );_bbg =false ;_bad :=_eeb (_fbb ,_afd );for _ggd =_bad .Next ();_ggd > -1;{if _gee ,_dedg =_fbb .UndilatedTemplates .GetBitmap (_ggd );_dedg !=nil {return _e .Wrap (_dedg ,_deff ,"\u0070\u0069\u0078\u0061\u0074\u002e\u005b\u0069\u0043l\u0061\u0073\u0073\u005d");};if _ecf ,_dedg =_fbb .FgTemplates .GetInt (_ggd );_dedg !=nil {_dd .Log .Trace ("\u0047\u0065\u0074\u0074\u0069\u006eg\u0020\u0046\u0047\u0054\u0065\u006d\u0070\u006c\u0061\u0074\u0065\u005b\u0025d\u005d\u0020\u0066\u0061\u0069\u006c\u0065d\u003a\u0020\u0025\u0076",_ggd ,_dedg );};if _baa ,_dedg =_fbb .DilatedTemplates .GetBitmap (_ggd );_dedg !=nil {return _e .Wrap (_dedg ,_deff ,"\u0070\u0069\u0078\u0061\u0074\u0064\u005b\u0069\u0043l\u0061\u0073\u0073\u005d");};if _aadg ,_ecd ,_dedg =_fbb .CentroidPointsTemplates .GetGeometry (_ggd );_dedg !=nil {return _e .Wrap (_dedg ,_deff ,"\u0043\u0065\u006et\u0072\u006f\u0069\u0064P\u006f\u0069\u006e\u0074\u0073\u0054\u0065m\u0070\u006c\u0061\u0074\u0065\u0073\u005b\u0069\u0043\u006c\u0061\u0073\u0073\u005d");};_afb ,_dedg =_f .RankHausTest (_afd ,_aeed ,_gee ,_baa ,_bfe -_aadg ,_ebgg -_ecd ,MaxDiffWidth ,MaxDiffHeight ,_ddg ,_ecf ,float32 (_fbb .Settings .RankHaus ),_ddda );if _dedg !=nil {return _e .Wrap (_dedg ,_deff ,"");};if _afb {_bbg =true ;if _dedg =_fbb .ClassIDs .Add (_ggd );_dedg !=nil {return _e .Wrap (_dedg ,_deff ,"");};if _dedg =_fbb .ComponentPageNumbers .Add (_fbg );_dedg !=nil {return _e .Wrap (_dedg ,_deff ,"");};if _fbb .Settings .KeepClassInstances {_gafg ,_cbc :=_fbb .ClassInstances .GetBitmaps (_ggd );if _cbc !=nil {return _e .Wrap (_cbc ,_deff ,"\u0063\u002e\u0050\u0069\u0078\u0061\u0061\u002e\u0047\u0065\u0074B\u0069\u0074\u006d\u0061\u0070\u0073\u0028\u0069\u0043\u006ca\u0073\u0073\u0029");};if _cagf ,_cbc =_ffbb .GetBitmap (_fde );_cbc !=nil {return _e .Wrap (_cbc ,_deff ,"\u0070i\u0078\u0061\u005b\u0069\u005d");};_gafg .Values =append (_gafg .Values ,_cagf );_fcge ,_cbc :=_egac .Get (_fde );if _cbc !=nil {return _e .Wrap (_cbc ,_deff ,"b\u006f\u0078\u0061\u002e\u0047\u0065\u0074\u0028\u0069\u0029");};_gafg .Boxes =append (_gafg .Boxes ,_fcge );};break ;};};if !_bbg {if _dedg =_fbb .ClassIDs .Add (_cdaf );_dedg !=nil {return _e .Wrap (_dedg ,_deff ,"\u0021\u0066\u006f\u0075\u006e\u0064");};if _dedg =_fbb .ComponentPageNumbers .Add (_fbg );_dedg !=nil {return _e .Wrap (_dedg ,_deff ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_fcbc :=&_f .Bitmaps {};_cagf =_ffbb .Values [_fde ];_fcbc .AddBitmap (_cagf );_fgc ,_eba :=_cagf .Width ,_cagf .Height ;_fbb .TemplatesSize .Add (uint64 (_fgc )*uint64 (_eba ),_cdaf );_aceg ,_effa :=_egac .Get (_fde );if _effa !=nil {return _e .Wrap (_effa ,_deff ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_fcbc .AddBox (_aceg );_fbb .ClassInstances .AddBitmaps (_fcbc );_fbb .CentroidPointsTemplates .AddPoint (_bfe ,_ebgg );_fbb .UndilatedTemplates .AddBitmap (_afd );_fbb .DilatedTemplates .AddBitmap (_aeed );_fbb .FgTemplates .AddInt (_ddg );};};_fbb .NumberOfClasses =len (_fbb .UndilatedTemplates .Values );return nil ;};