diff options
| author | leshe4ka46 <alex9102naid1@ya.ru> | 2025-10-19 14:47:59 +0300 |
|---|---|---|
| committer | leshe4ka46 <alex9102naid1@ya.ru> | 2025-10-19 14:47:59 +0300 |
| commit | e17a425dfb3382310fb5863f516dacdca9f44956 (patch) | |
| tree | 7babb3048d0eb20aa1e68e9b29c2acfa794ab96f /unipdf/internal/jbig2/encoder/classer/classer.go | |
| parent | 091963a50c3bb2926f559f01c49e8f5bd03d2bfd (diff) | |
fuck the unipdf licencing
Diffstat (limited to 'unipdf/internal/jbig2/encoder/classer/classer.go')
| -rw-r--r-- | unipdf/internal/jbig2/encoder/classer/classer.go | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/unipdf/internal/jbig2/encoder/classer/classer.go b/unipdf/internal/jbig2/encoder/classer/classer.go new file mode 100644 index 0000000..a0b48db --- /dev/null +++ b/unipdf/internal/jbig2/encoder/classer/classer.go @@ -0,0 +1,110 @@ +// +// 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 (_gf "github.com/unidoc/unipdf/v4/common";_e "github.com/unidoc/unipdf/v4/internal/jbig2/basic";_gd "github.com/unidoc/unipdf/v4/internal/jbig2/bitmap";_c "github.com/unidoc/unipdf/v4/internal/jbig2/errors";_a "image";_g "math"; +);const (MaxConnCompWidth =350;MaxCharCompWidth =350;MaxWordCompWidth =1000;MaxCompHeight =120;);func (_cca *Classer )classifyRankHouseOne (_fef *_gd .Boxes ,_deeg ,_abe ,_ceeg *_gd .Bitmaps ,_abc *_gd .Points ,_fgg int )(_dcd error ){const _edb ="\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 (_cde ,_gdg ,_bee ,_fefa float32 ;_cf int ;_daf ,_fdg ,_aacc ,_ffc ,_eef *_gd .Bitmap ;_cdg ,_acad bool ;);for _baed :=0;_baed < len (_deeg .Values );_baed ++{_fdg =_abe .Values [_baed ];_aacc =_ceeg .Values [_baed ];_cde ,_gdg ,_dcd =_abc .GetGeometry (_baed ); +if _dcd !=nil {return _c .Wrapf (_dcd ,_edb ,"\u0066\u0069\u0072\u0073\u0074\u0020\u0067\u0065\u006fm\u0065\u0074\u0072\u0079");};_gaae :=len (_cca .UndilatedTemplates .Values );_cdg =false ;_def :=_acd (_cca ,_fdg );for _cf =_def .Next ();_cf > -1;{_ffc ,_dcd =_cca .UndilatedTemplates .GetBitmap (_cf ); +if _dcd !=nil {return _c .Wrap (_dcd ,_edb ,"\u0062\u006d\u0033");};_eef ,_dcd =_cca .DilatedTemplates .GetBitmap (_cf );if _dcd !=nil {return _c .Wrap (_dcd ,_edb ,"\u0062\u006d\u0034");};_bee ,_fefa ,_dcd =_cca .CentroidPointsTemplates .GetGeometry (_cf ); +if _dcd !=nil {return _c .Wrap (_dcd ,_edb ,"\u0043\u0065\u006e\u0074\u0072\u006f\u0069\u0064\u0054\u0065\u006d\u0070l\u0061\u0074\u0065\u0073");};_acad ,_dcd =_gd .HausTest (_fdg ,_aacc ,_ffc ,_eef ,_cde -_bee ,_gdg -_fefa ,MaxDiffWidth ,MaxDiffHeight ); +if _dcd !=nil {return _c .Wrap (_dcd ,_edb ,"");};if _acad {_cdg =true ;if _dcd =_cca .ClassIDs .Add (_cf );_dcd !=nil {return _c .Wrap (_dcd ,_edb ,"");};if _dcd =_cca .ComponentPageNumbers .Add (_fgg );_dcd !=nil {return _c .Wrap (_dcd ,_edb ,"");};if _cca .Settings .KeepClassInstances {_gbf ,_fea :=_cca .ClassInstances .GetBitmaps (_cf ); +if _fea !=nil {return _c .Wrap (_fea ,_edb ,"\u004be\u0065\u0070\u0050\u0069\u0078\u0061a");};_daf ,_fea =_deeg .GetBitmap (_baed );if _fea !=nil {return _c .Wrap (_fea ,_edb ,"\u004be\u0065\u0070\u0050\u0069\u0078\u0061a");};_gbf .AddBitmap (_daf );_dcf ,_fea :=_fef .Get (_baed ); +if _fea !=nil {return _c .Wrap (_fea ,_edb ,"\u004be\u0065\u0070\u0050\u0069\u0078\u0061a");};_gbf .AddBox (_dcf );};break ;};};if !_cdg {if _dcd =_cca .ClassIDs .Add (_gaae );_dcd !=nil {return _c .Wrap (_dcd ,_edb ,"");};if _dcd =_cca .ComponentPageNumbers .Add (_fgg ); +_dcd !=nil {return _c .Wrap (_dcd ,_edb ,"");};_bdea :=&_gd .Bitmaps {};_daf ,_dcd =_deeg .GetBitmap (_baed );if _dcd !=nil {return _c .Wrap (_dcd ,_edb ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_bdea .Values =append (_bdea .Values ,_daf );_fbe ,_fcgg :=_daf .Width ,_daf .Height ; +_cca .TemplatesSize .Add (uint64 (_fcgg )*uint64 (_fbe ),_gaae );_eca ,_eeb :=_fef .Get (_baed );if _eeb !=nil {return _c .Wrap (_eeb ,_edb ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_bdea .AddBox (_eca );_cca .ClassInstances .AddBitmaps (_bdea );_cca .CentroidPointsTemplates .AddPoint (_cde ,_gdg ); +_cca .UndilatedTemplates .AddBitmap (_fdg );_cca .DilatedTemplates .AddBitmap (_aacc );};};return nil ;};func (_fced *Classer )addPageComponents (_df *_gd .Bitmap ,_gcb *_gd .Boxes ,_fg *_gd .Bitmaps ,_ce int ,_cee Method )error {const _bca ="\u0043l\u0061\u0073\u0073\u0065r\u002e\u0041\u0064\u0064\u0050a\u0067e\u0043o\u006d\u0070\u006f\u006e\u0065\u006e\u0074s"; +if _df ==nil {return _c .Error (_bca ,"\u006e\u0069\u006c\u0020\u0069\u006e\u0070\u0075\u0074 \u0070\u0061\u0067\u0065");};if _gcb ==nil ||_fg ==nil ||len (*_gcb )==0{_gf .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",_df ); +return nil ;};var _ad error ;switch _cee {case RankHaus :_ad =_fced .classifyRankHaus (_gcb ,_fg ,_ce );case Correlation :_ad =_fced .classifyCorrelation (_gcb ,_fg ,_ce );default:_gf .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",_cee ); +return _c .Error (_bca ,"\u0075\u006e\u006bno\u0077\u006e\u0020\u0063\u006c\u0061\u0073\u0073\u0069\u0066\u0079\u0020\u006d\u0065\u0074\u0068\u006f\u0064");};if _ad !=nil {return _c .Wrap (_ad ,_bca ,"");};if _ad =_fced .getULCorners (_df ,_gcb );_ad !=nil {return _c .Wrap (_ad ,_bca ,""); +};_gae :=len (*_gcb );_fced .BaseIndex +=_gae ;if _ad =_fced .ComponentsNumber .Add (_gae );_ad !=nil {return _c .Wrap (_ad ,_bca ,"");};return nil ;};type Method int ;var _aee bool ;func (_bf *Classer )verifyMethod (_gaa Method )error {if _gaa !=RankHaus &&_gaa !=Correlation {return _c .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 ;};const (RankHaus Method =iota ;Correlation ;);func _fe (_aad *_gd .Bitmap ,_fdb ,_ggg ,_bag ,_dg int ,_gfe *_gd .Bitmap )(_fa _a .Point ,_bfd error ){const _ebe ="\u0066i\u006e\u0061\u006c\u0041l\u0069\u0067\u006e\u006d\u0065n\u0074P\u006fs\u0069\u0074\u0069\u006f\u006e\u0069\u006eg"; +if _aad ==nil {return _fa ,_c .Error (_ebe ,"\u0073\u006f\u0075\u0072ce\u0020\u006e\u006f\u0074\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");};if _gfe ==nil {return _fa ,_c .Error (_ebe ,"t\u0065\u006d\u0070\u006cat\u0065 \u006e\u006f\u0074\u0020\u0070r\u006f\u0076\u0069\u0064\u0065\u0064"); +};_dbe ,_ebd :=_gfe .Width ,_gfe .Height ;_efa ,_bga :=_fdb -_bag -JbAddedPixels ,_ggg -_dg -JbAddedPixels ;_gf .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",_fdb ,_ggg ,_dbe ,_ebd ,_efa ,_bga ); +_ffe ,_bfd :=_gd .Rect (_efa ,_bga ,_dbe ,_ebd );if _bfd !=nil {return _fa ,_c .Wrap (_bfd ,_ebe ,"");};_bgaf ,_ ,_bfd :=_aad .ClipRectangle (_ffe );if _bfd !=nil {_gf .Log .Error ("\u0043a\u006e\u0027\u0074\u0020\u0063\u006c\u0069\u0070\u0020\u0072\u0065c\u0074\u0061\u006e\u0067\u006c\u0065\u003a\u0020\u0025\u0076",_ffe ); +return _fa ,_c .Wrap (_bfd ,_ebe ,"");};_dbf :=_gd .New (_bgaf .Width ,_bgaf .Height );_bfg :=_g .MaxInt32 ;var _ed ,_ac ,_ae ,_bagf ,_be int ;for _ed =-1;_ed <=1;_ed ++{for _ac =-1;_ac <=1;_ac ++{if _ ,_bfd =_gd .Copy (_dbf ,_bgaf );_bfd !=nil {return _fa ,_c .Wrap (_bfd ,_ebe ,""); +};if _bfd =_dbf .RasterOperation (_ac ,_ed ,_dbe ,_ebd ,_gd .PixSrcXorDst ,_gfe ,0,0);_bfd !=nil {return _fa ,_c .Wrap (_bfd ,_ebe ,"");};_ae =_dbf .CountPixels ();if _ae < _bfg {_bagf =_ac ;_be =_ed ;_bfg =_ae ;};};};_fa .X =_bagf ;_fa .Y =_be ;return _fa ,nil ; +};func (_bbb *similarTemplatesFinder )Next ()int {var (_bgac ,_ccb ,_efda ,_cdag int ;_dccb bool ;_edf *_gd .Bitmap ;_gaf error ;);for {if _bbb .Index >=25{return -1;};_ccb =_bbb .Width +TwoByTwoWalk [2*_bbb .Index ];_bgac =_bbb .Height +TwoByTwoWalk [2*_bbb .Index +1]; +if _bgac < 1||_ccb < 1{_bbb .Index ++;continue ;};if len (_bbb .CurrentNumbers )==0{_bbb .CurrentNumbers ,_dccb =_bbb .Classer .TemplatesSize .GetSlice (uint64 (_ccb )*uint64 (_bgac ));if !_dccb {_bbb .Index ++;continue ;};_bbb .N =0;};_efda =len (_bbb .CurrentNumbers ); +for ;_bbb .N < _efda ;_bbb .N ++{_cdag =_bbb .CurrentNumbers [_bbb .N ];_edf ,_gaf =_bbb .Classer .DilatedTemplates .GetBitmap (_cdag );if _gaf !=nil {_gf .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 _edf .Width -2*JbAddedPixels ==_ccb &&_edf .Height -2*JbAddedPixels ==_bgac {return _cdag ;};};_bbb .Index ++;_bbb .CurrentNumbers =nil ;};};func DefaultSettings ()Settings {_bcd :=&Settings {};_bcd .SetDefault ();return *_bcd };const (MaxDiffWidth =2; +MaxDiffHeight =2;);type Settings struct{MaxCompWidth int ;MaxCompHeight int ;SizeHaus int ;RankHaus float64 ;Thresh float64 ;WeightFactor float64 ;KeepClassInstances bool ;Components _gd .Component ;Method Method ;};type Classer struct{BaseIndex int ;Settings Settings ; +ComponentsNumber *_e .IntSlice ;TemplateAreas *_e .IntSlice ;Widths map[int ]int ;Heights map[int ]int ;NumberOfClasses int ;ClassInstances *_gd .BitmapsArray ;UndilatedTemplates *_gd .Bitmaps ;DilatedTemplates *_gd .Bitmaps ;TemplatesSize _e .IntsMap ; +FgTemplates *_e .NumSlice ;CentroidPoints *_gd .Points ;CentroidPointsTemplates *_gd .Points ;ClassIDs *_e .IntSlice ;ComponentPageNumbers *_e .IntSlice ;PtaUL *_gd .Points ;PtaLL *_gd .Points ;};func (_aab *Classer )classifyCorrelation (_bgd *_gd .Boxes ,_efd *_gd .Bitmaps ,_gb int )error {const _ceea ="\u0063\u006c\u0061\u0073si\u0066\u0079\u0043\u006f\u0072\u0072\u0065\u006c\u0061\u0074\u0069\u006f\u006e"; +if _bgd ==nil {return _c .Error (_ceea ,"\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 _efd ==nil {return _c .Error (_ceea ,"\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");};_de :=len (_efd .Values );if _de ==0{_gf .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 (_eae ,_cg *_gd .Bitmap ;_fcg error ;);_cda :=&_gd .Bitmaps {Values :make ([]*_gd .Bitmap ,_de )};for _egg ,_cgc :=range _efd .Values {_cg ,_fcg =_cgc .AddBorderGeneral (JbAddedPixels ,JbAddedPixels ,JbAddedPixels ,JbAddedPixels ,0);if _fcg !=nil {return _c .Wrap (_fcg ,_ceea ,""); +};_cda .Values [_egg ]=_cg ;};_fae :=_aab .FgTemplates ;_dcc :=_gd .MakePixelSumTab8 ();_dd :=_gd .MakePixelCentroidTab8 ();_ead :=make ([]int ,_de );_fb :=make ([][]int ,_de );_afb :=_gd .Points (make ([]_gd .Point ,_de ));_eabc :=&_afb ;var (_bbc ,_dee int ; +_aaa ,_afbc ,_bae int ;_edd ,_ddg int ;_adg byte ;);for _adf ,_cc :=range _cda .Values {_fb [_adf ]=make ([]int ,_cc .Height );_bbc =0;_dee =0;_afbc =(_cc .Height -1)*_cc .RowStride ;_aaa =0;for _ddg =_cc .Height -1;_ddg >=0;_ddg ,_afbc =_ddg -1,_afbc -_cc .RowStride {_fb [_adf ][_ddg ]=_aaa ; +_bae =0;for _edd =0;_edd < _cc .RowStride ;_edd ++{_adg =_cc .Data [_afbc +_edd ];_bae +=_dcc [_adg ];_bbc +=_dd [_adg ]+_edd *8*_dcc [_adg ];};_aaa +=_bae ;_dee +=_bae *_ddg ;};_ead [_adf ]=_aaa ;if _aaa > 0{(*_eabc )[_adf ]=_gd .Point {X :float32 (_bbc )/float32 (_aaa ),Y :float32 (_dee )/float32 (_aaa )}; +}else {(*_eabc )[_adf ]=_gd .Point {X :float32 (_cc .Width )/float32 (2),Y :float32 (_cc .Height )/float32 (2)};};};if _fcg =_aab .CentroidPoints .Add (_eabc );_fcg !=nil {return _c .Wrap (_fcg ,_ceea ,"\u0063\u0065\u006et\u0072\u006f\u0069\u0064\u0020\u0061\u0064\u0064"); +};var (_agf ,_afg ,_aag int ;_dad float64 ;_acc ,_ecb ,_ddd ,_gbd float32 ;_dff ,_dgd _gd .Point ;_ceg bool ;_dae *similarTemplatesFinder ;_add int ;_ega *_gd .Bitmap ;_eggc *_a .Rectangle ;_bd *_gd .Bitmaps ;);for _add ,_cg =range _cda .Values {_afg =_ead [_add ]; +if _acc ,_ecb ,_fcg =_eabc .GetGeometry (_add );_fcg !=nil {return _c .Wrap (_fcg ,_ceea ,"\u0070t\u0061\u0020\u002d\u0020\u0069");};_ceg =false ;_bde :=len (_aab .UndilatedTemplates .Values );_dae =_acd (_aab ,_cg );for _fff :=_dae .Next ();_fff > -1; +{if _ega ,_fcg =_aab .UndilatedTemplates .GetBitmap (_fff );_fcg !=nil {return _c .Wrap (_fcg ,_ceea ,"\u0075\u006e\u0069dl\u0061\u0074\u0065\u0064\u005b\u0069\u0063\u006c\u0061\u0073\u0073\u005d\u0020\u003d\u0020\u0062\u006d\u0032");};if _aag ,_fcg =_fae .GetInt (_fff ); +_fcg !=nil {_gf .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",_fcg );};if _ddd ,_gbd ,_fcg =_aab .CentroidPointsTemplates .GetGeometry (_fff ); +_fcg !=nil {return _c .Wrap (_fcg ,_ceea ,"\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 _aab .Settings .WeightFactor > 0.0{if _agf ,_fcg =_aab .TemplateAreas .Get (_fff );_fcg !=nil {_gf .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",_fcg ); +};_dad =_aab .Settings .Thresh +(1.0-_aab .Settings .Thresh )*_aab .Settings .WeightFactor *float64 (_aag )/float64 (_agf );}else {_dad =_aab .Settings .Thresh ;};_ffa ,_dec :=_gd .CorrelationScoreThresholded (_cg ,_ega ,_afg ,_aag ,_dff .X -_dgd .X ,_dff .Y -_dgd .Y ,MaxDiffWidth ,MaxDiffHeight ,_dcc ,_fb [_add ],float32 (_dad )); +if _dec !=nil {return _c .Wrap (_dec ,_ceea ,"");};if _aee {var (_cgg ,_ab float64 ;_afgf ,_fgb int ;);_cgg ,_dec =_gd .CorrelationScore (_cg ,_ega ,_afg ,_aag ,_acc -_ddd ,_ecb -_gbd ,MaxDiffWidth ,MaxDiffHeight ,_dcc );if _dec !=nil {return _c .Wrap (_dec ,_ceea ,"d\u0065\u0062\u0075\u0067Co\u0072r\u0065\u006c\u0061\u0074\u0069o\u006e\u0053\u0063\u006f\u0072\u0065"); +};_ab ,_dec =_gd .CorrelationScoreSimple (_cg ,_ega ,_afg ,_aag ,_acc -_ddd ,_ecb -_gbd ,MaxDiffWidth ,MaxDiffHeight ,_dcc );if _dec !=nil {return _c .Wrap (_dec ,_ceea ,"d\u0065\u0062\u0075\u0067Co\u0072r\u0065\u006c\u0061\u0074\u0069o\u006e\u0053\u0063\u006f\u0072\u0065"); +};_afgf =int (_g .Sqrt (_cgg *float64 (_afg )*float64 (_aag )));_fgb =int (_g .Sqrt (_ab *float64 (_afg )*float64 (_aag )));if (_cgg >=_dad )!=(_ab >=_dad ){return _c .Errorf (_ceea ,"\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",_afgf ,_cgg ,_cgg >=_dad ,_fgb ,_ab ,_ab >=_dad ,_cgg -_ab ); +};if _cgg >=_dad !=_ffa {return _c .Errorf (_ceea ,"\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",_cgg ,_cgg *float64 (_afg )*float64 (_aag ),_afgf ,_dad ,float32 (_dad )*float32 (_afg )*float32 (_aag ),_ffa ); +};};if _ffa {_ceg =true ;if _dec =_aab .ClassIDs .Add (_fff );_dec !=nil {return _c .Wrap (_dec ,_ceea ,"\u006f\u0076\u0065\u0072\u0054\u0068\u0072\u0065\u0073\u0068\u006f\u006c\u0064");};if _dec =_aab .ComponentPageNumbers .Add (_gb );_dec !=nil {return _c .Wrap (_dec ,_ceea ,"\u006f\u0076\u0065\u0072\u0054\u0068\u0072\u0065\u0073\u0068\u006f\u006c\u0064"); +};if _aab .Settings .KeepClassInstances {if _eae ,_dec =_efd .GetBitmap (_add );_dec !=nil {return _c .Wrap (_dec ,_ceea ,"\u004b\u0065\u0065\u0070Cl\u0061\u0073\u0073\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0073\u0020\u002d \u0069");};if _bd ,_dec =_aab .ClassInstances .GetBitmaps (_fff ); +_dec !=nil {return _c .Wrap (_dec ,_ceea ,"K\u0065\u0065\u0070\u0043\u006c\u0061s\u0073\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065s\u0020\u002d\u0020i\u0043l\u0061\u0073\u0073");};_bd .AddBitmap (_eae );if _eggc ,_dec =_bgd .Get (_add );_dec !=nil {return _c .Wrap (_dec ,_ceea ,"\u004be\u0065p\u0043\u006c\u0061\u0073\u0073I\u006e\u0073t\u0061\u006e\u0063\u0065\u0073"); +};_bd .AddBox (_eggc );};break ;};};if !_ceg {if _fcg =_aab .ClassIDs .Add (_bde );_fcg !=nil {return _c .Wrap (_fcg ,_ceea ,"\u0021\u0066\u006f\u0075\u006e\u0064");};if _fcg =_aab .ComponentPageNumbers .Add (_gb );_fcg !=nil {return _c .Wrap (_fcg ,_ceea ,"\u0021\u0066\u006f\u0075\u006e\u0064"); +};_bd =&_gd .Bitmaps {};if _eae ,_fcg =_efd .GetBitmap (_add );_fcg !=nil {return _c .Wrap (_fcg ,_ceea ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_bd .AddBitmap (_eae );_ggd ,_egd :=_eae .Width ,_eae .Height ;_ca :=uint64 (_egd )*uint64 (_ggd );_aab .TemplatesSize .Add (_ca ,_bde ); +if _eggc ,_fcg =_bgd .Get (_add );_fcg !=nil {return _c .Wrap (_fcg ,_ceea ,"\u0021\u0066\u006f\u0075\u006e\u0064");};_bd .AddBox (_eggc );_aab .ClassInstances .AddBitmaps (_bd );_aab .CentroidPointsTemplates .AddPoint (_acc ,_ecb );_aab .FgTemplates .AddInt (_afg ); +_aab .UndilatedTemplates .AddBitmap (_eae );_agf =(_cg .Width -2*JbAddedPixels )*(_cg .Height -2*JbAddedPixels );if _fcg =_aab .TemplateAreas .Add (_agf );_fcg !=nil {return _c .Wrap (_fcg ,_ceea ,"\u0021\u0066\u006f\u0075\u006e\u0064");};};};_aab .NumberOfClasses =len (_aab .UndilatedTemplates .Values ); +return nil ;};func (_dac Settings )Validate ()error {const _fab ="\u0053\u0065\u0074\u0074\u0069\u006e\u0067\u0073\u002e\u0056\u0061\u006ci\u0064\u0061\u0074\u0065";if _dac .Thresh < 0.4||_dac .Thresh > 0.98{return _c .Error (_fab ,"\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 _dac .WeightFactor < 0.0||_dac .WeightFactor > 1.0{return _c .Error (_fab ,"\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 _dac .RankHaus < 0.5||_dac .RankHaus > 1.0{return _c .Error (_fab ,"\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 _dac .SizeHaus < 1||_dac .SizeHaus > 10{return _c .Error (_fab ,"\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 _dac .Components {case _gd .ComponentConn ,_gd .ComponentCharacters ,_gd .ComponentWords :default:return _c .Error (_fab ,"\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 _b ="\u0063\u006c\u0061s\u0073\u0065\u0072\u002e\u0049\u006e\u0069\u0074";_ef :=&Classer {Settings :settings ,Widths :map[int ]int {},Heights :map[int ]int {},TemplatesSize :_e .IntsMap {},TemplateAreas :&_e .IntSlice {},ComponentPageNumbers :&_e .IntSlice {},ClassIDs :&_e .IntSlice {},ComponentsNumber :&_e .IntSlice {},CentroidPoints :&_gd .Points {},CentroidPointsTemplates :&_gd .Points {},UndilatedTemplates :&_gd .Bitmaps {},DilatedTemplates :&_gd .Bitmaps {},ClassInstances :&_gd .BitmapsArray {},FgTemplates :&_e .NumSlice {}}; +if _efg :=_ef .Settings .Validate ();_efg !=nil {return nil ,_c .Wrap (_efg ,_b ,"");};return _ef ,nil ;};func (_ga *Classer )AddPage (inputPage *_gd .Bitmap ,pageNumber int ,method Method )(_cb error ){const _fc ="\u0043l\u0061s\u0073\u0065\u0072\u002e\u0041\u0064\u0064\u0050\u0061\u0067\u0065"; +_ga .Widths [pageNumber ]=inputPage .Width ;_ga .Heights [pageNumber ]=inputPage .Height ;if _cb =_ga .verifyMethod (method );_cb !=nil {return _c .Wrap (_cb ,_fc ,"");};_eg ,_ea ,_cb :=inputPage .GetComponents (_ga .Settings .Components ,_ga .Settings .MaxCompWidth ,_ga .Settings .MaxCompHeight ); +if _cb !=nil {return _c .Wrap (_cb ,_fc ,"");};_gf .Log .Debug ("\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074s\u003a\u0020\u0025\u0076",_eg );if _cb =_ga .addPageComponents (inputPage ,_ea ,_eg ,pageNumber ,method );_cb !=nil {return _c .Wrap (_cb ,_fc ,""); +};return nil ;};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};func _acd (_ddb *Classer ,_bbd *_gd .Bitmap )*similarTemplatesFinder {return &similarTemplatesFinder {Width :_bbd .Width ,Height :_bbd .Height ,Classer :_ddb }; +};func (_gdf *Classer )classifyRankHaus (_abb *_gd .Boxes ,_gcbe *_gd .Bitmaps ,_bgafc int )error {const _gfeb ="\u0063\u006ca\u0073\u0073\u0069f\u0079\u0052\u0061\u006e\u006b\u0048\u0061\u0075\u0073";if _abb ==nil {return _c .Error (_gfeb ,"\u0062\u006fx\u0061\u0020\u006eo\u0074\u0020\u0064\u0065\u0066\u0069\u006e\u0065\u0064"); +};if _gcbe ==nil {return _c .Error (_gfeb ,"\u0070\u0069x\u0061\u0020\u006eo\u0074\u0020\u0064\u0065\u0066\u0069\u006e\u0065\u0064");};_fec :=len (_gcbe .Values );if _fec ==0{return _c .Error (_gfeb ,"e\u006dp\u0074\u0079\u0020\u006e\u0065\u0077\u0020\u0063o\u006d\u0070\u006f\u006een\u0074\u0073"); +};_gbg :=_gcbe .CountPixels ();_ebdb :=_gdf .Settings .SizeHaus ;_gfb :=_gd .SelCreateBrick (_ebdb ,_ebdb ,_ebdb /2,_ebdb /2,_gd .SelHit );_aca :=&_gd .Bitmaps {Values :make ([]*_gd .Bitmap ,_fec )};_dcca :=&_gd .Bitmaps {Values :make ([]*_gd .Bitmap ,_fec )}; +var (_bge ,_bcb ,_bda *_gd .Bitmap ;_ffb error ;);for _afbg :=0;_afbg < _fec ;_afbg ++{_bge ,_ffb =_gcbe .GetBitmap (_afbg );if _ffb !=nil {return _c .Wrap (_ffb ,_gfeb ,"");};_bcb ,_ffb =_bge .AddBorderGeneral (JbAddedPixels ,JbAddedPixels ,JbAddedPixels ,JbAddedPixels ,0); +if _ffb !=nil {return _c .Wrap (_ffb ,_gfeb ,"");};_bda ,_ffb =_gd .Dilate (nil ,_bcb ,_gfb );if _ffb !=nil {return _c .Wrap (_ffb ,_gfeb ,"");};_aca .Values [_fec ]=_bcb ;_dcca .Values [_fec ]=_bda ;};_efac ,_ffb :=_gd .Centroids (_aca .Values );if _ffb !=nil {return _c .Wrap (_ffb ,_gfeb ,""); +};if _ffb =_efac .Add (_gdf .CentroidPoints );_ffb !=nil {_gf .Log .Trace ("\u004e\u006f\u0020\u0063en\u0074\u0072\u006f\u0069\u0064\u0073\u0020\u0074\u006f\u0020\u0061\u0064\u0064");};if _gdf .Settings .RankHaus ==1.0{_ffb =_gdf .classifyRankHouseOne (_abb ,_gcbe ,_aca ,_dcca ,_efac ,_bgafc ); +}else {_ffb =_gdf .classifyRankHouseNonOne (_abb ,_gcbe ,_aca ,_dcca ,_efac ,_gbg ,_bgafc );};if _ffb !=nil {return _c .Wrap (_ffb ,_gfeb ,"");};return nil ;};func (_ced *Classer )classifyRankHouseNonOne (_baa *_gd .Boxes ,_afgb ,_cbe ,_bgdd *_gd .Bitmaps ,_caa *_gd .Points ,_bdc *_e .NumSlice ,_bec int )(_gfg error ){const _ded ="\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 (_acb ,_eff ,_gaaf ,_fggc float32 ;_dda ,_daff ,_efc int ;_cbb ,_efb ,_ecf ,_cea ,_cge *_gd .Bitmap ;_cff ,_ebab bool ;);_addb :=_gd .MakePixelSumTab8 ();for _fda :=0;_fda < len (_afgb .Values );_fda ++{if _efb ,_gfg =_cbe .GetBitmap (_fda );_gfg !=nil {return _c .Wrap (_gfg ,_ded ,"b\u006d\u0073\u0031\u002e\u0047\u0065\u0074\u0028\u0069\u0029"); +};if _dda ,_gfg =_bdc .GetInt (_fda );_gfg !=nil {_gf .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",_fda ,_gfg ); +};if _ecf ,_gfg =_bgdd .GetBitmap (_fda );_gfg !=nil {return _c .Wrap (_gfg ,_ded ,"b\u006d\u0073\u0032\u002e\u0047\u0065\u0074\u0028\u0069\u0029");};if _acb ,_eff ,_gfg =_caa .GetGeometry (_fda );_gfg !=nil {return _c .Wrapf (_gfg ,_ded ,"\u0070t\u0061[\u0069\u005d\u002e\u0047\u0065\u006f\u006d\u0065\u0074\u0072\u0079"); +};_efcb :=len (_ced .UndilatedTemplates .Values );_cff =false ;_gbge :=_acd (_ced ,_efb );for _efc =_gbge .Next ();_efc > -1;{if _cea ,_gfg =_ced .UndilatedTemplates .GetBitmap (_efc );_gfg !=nil {return _c .Wrap (_gfg ,_ded ,"\u0070\u0069\u0078\u0061\u0074\u002e\u005b\u0069\u0043l\u0061\u0073\u0073\u005d"); +};if _daff ,_gfg =_ced .FgTemplates .GetInt (_efc );_gfg !=nil {_gf .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",_efc ,_gfg ); +};if _cge ,_gfg =_ced .DilatedTemplates .GetBitmap (_efc );_gfg !=nil {return _c .Wrap (_gfg ,_ded ,"\u0070\u0069\u0078\u0061\u0074\u0064\u005b\u0069\u0043l\u0061\u0073\u0073\u005d");};if _gaaf ,_fggc ,_gfg =_ced .CentroidPointsTemplates .GetGeometry (_efc ); +_gfg !=nil {return _c .Wrap (_gfg ,_ded ,"\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");};_ebab ,_gfg =_gd .RankHausTest (_efb ,_ecf ,_cea ,_cge ,_acb -_gaaf ,_eff -_fggc ,MaxDiffWidth ,MaxDiffHeight ,_dda ,_daff ,float32 (_ced .Settings .RankHaus ),_addb ); +if _gfg !=nil {return _c .Wrap (_gfg ,_ded ,"");};if _ebab {_cff =true ;if _gfg =_ced .ClassIDs .Add (_efc );_gfg !=nil {return _c .Wrap (_gfg ,_ded ,"");};if _gfg =_ced .ComponentPageNumbers .Add (_bec );_gfg !=nil {return _c .Wrap (_gfg ,_ded ,"");}; +if _ced .Settings .KeepClassInstances {_cag ,_ace :=_ced .ClassInstances .GetBitmaps (_efc );if _ace !=nil {return _c .Wrap (_ace ,_ded ,"\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 _cbb ,_ace =_afgb .GetBitmap (_fda );_ace !=nil {return _c .Wrap (_ace ,_ded ,"\u0070i\u0078\u0061\u005b\u0069\u005d");};_cag .Values =append (_cag .Values ,_cbb );_dfb ,_ace :=_baa .Get (_fda );if _ace !=nil {return _c .Wrap (_ace ,_ded ,"b\u006f\u0078\u0061\u002e\u0047\u0065\u0074\u0028\u0069\u0029"); +};_cag .Boxes =append (_cag .Boxes ,_dfb );};break ;};};if !_cff {if _gfg =_ced .ClassIDs .Add (_efcb );_gfg !=nil {return _c .Wrap (_gfg ,_ded ,"\u0021\u0066\u006f\u0075\u006e\u0064");};if _gfg =_ced .ComponentPageNumbers .Add (_bec );_gfg !=nil {return _c .Wrap (_gfg ,_ded ,"\u0021\u0066\u006f\u0075\u006e\u0064"); +};_cae :=&_gd .Bitmaps {};_cbb =_afgb .Values [_fda ];_cae .AddBitmap (_cbb );_ggf ,_eaeb :=_cbb .Width ,_cbb .Height ;_ced .TemplatesSize .Add (uint64 (_ggf )*uint64 (_eaeb ),_efcb );_ade ,_ddde :=_baa .Get (_fda );if _ddde !=nil {return _c .Wrap (_ddde ,_ded ,"\u0021\u0066\u006f\u0075\u006e\u0064"); +};_cae .AddBox (_ade );_ced .ClassInstances .AddBitmaps (_cae );_ced .CentroidPointsTemplates .AddPoint (_acb ,_eff );_ced .UndilatedTemplates .AddBitmap (_efb );_ced .DilatedTemplates .AddBitmap (_ecf );_ced .FgTemplates .AddInt (_dda );};};_ced .NumberOfClasses =len (_ced .UndilatedTemplates .Values ); +return nil ;};const JbAddedPixels =6;func (_ebb *Settings )SetDefault (){if _ebb .MaxCompWidth ==0{switch _ebb .Components {case _gd .ComponentConn :_ebb .MaxCompWidth =MaxConnCompWidth ;case _gd .ComponentCharacters :_ebb .MaxCompWidth =MaxCharCompWidth ; +case _gd .ComponentWords :_ebb .MaxCompWidth =MaxWordCompWidth ;};};if _ebb .MaxCompHeight ==0{_ebb .MaxCompHeight =MaxCompHeight ;};if _ebb .Thresh ==0.0{_ebb .Thresh =0.9;};if _ebb .WeightFactor ==0.0{_ebb .WeightFactor =0.75;};if _ebb .RankHaus ==0.0{_ebb .RankHaus =0.97; +};if _ebb .SizeHaus ==0{_ebb .SizeHaus =2;};};func (_bc *Classer )ComputeLLCorners ()(_cd error ){const _egb ="\u0043l\u0061\u0073\u0073\u0065\u0072\u002e\u0043\u006f\u006d\u0070\u0075t\u0065\u004c\u004c\u0043\u006f\u0072\u006e\u0065\u0072\u0073";if _bc .PtaUL ==nil {return _c .Error (_egb ,"\u0055\u004c\u0020\u0043or\u006e\u0065\u0072\u0073\u0020\u006e\u006f\u0074\u0020\u0064\u0065\u0066\u0069\u006ee\u0064"); +};_egf :=len (*_bc .PtaUL );_bc .PtaLL =&_gd .Points {};var (_gc ,_cdd float32 ;_gac ,_fce int ;_d *_gd .Bitmap ;);for _db :=0;_db < _egf ;_db ++{_gc ,_cdd ,_cd =_bc .PtaUL .GetGeometry (_db );if _cd !=nil {_gf .Log .Debug ("\u0047e\u0074\u0074\u0069\u006e\u0067\u0020\u0050\u0074\u0061\u0055\u004c \u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0076",_cd ); +return _c .Wrap (_cd ,_egb ,"\u0050\u0074\u0061\u0055\u004c\u0020\u0047\u0065\u006fm\u0065\u0074\u0072\u0079");};_gac ,_cd =_bc .ClassIDs .Get (_db );if _cd !=nil {_gf .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",_cd ); +return _c .Wrap (_cd ,_egb ,"\u0043l\u0061\u0073\u0073\u0049\u0044");};_d ,_cd =_bc .UndilatedTemplates .GetBitmap (_gac );if _cd !=nil {_gf .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",_cd ); +return _c .Wrap (_cd ,_egb ,"\u0055\u006e\u0064\u0069la\u0074\u0065\u0064\u0020\u0054\u0065\u006d\u0070\u006c\u0061\u0074\u0065\u0073");};_fce =_d .Height ;_bc .PtaLL .AddPoint (_gc ,_cdd +float32 (_fce ));};return nil ;};func (_gacb *Classer )getULCorners (_eab *_gd .Bitmap ,_ff *_gd .Boxes )error {const _af ="\u0067\u0065\u0074U\u004c\u0043\u006f\u0072\u006e\u0065\u0072\u0073"; +if _eab ==nil {return _c .Error (_af ,"\u006e\u0069l\u0020\u0069\u006da\u0067\u0065\u0020\u0062\u0069\u0074\u006d\u0061\u0070");};if _ff ==nil {return _c .Error (_af ,"\u006e\u0069\u006c\u0020\u0062\u006f\u0075\u006e\u0064\u0073");};if _gacb .PtaUL ==nil {_gacb .PtaUL =&_gd .Points {}; +};_ada :=len (*_ff );var (_ba ,_eb ,_gg ,_dc int ;_bg ,_gab ,_gcc ,_fd float32 ;_cdb error ;_aa *_a .Rectangle ;_bb *_gd .Bitmap ;_eba _a .Point ;);for _aac :=0;_aac < _ada ;_aac ++{_ba =_gacb .BaseIndex +_aac ;if _bg ,_gab ,_cdb =_gacb .CentroidPoints .GetGeometry (_ba ); +_cdb !=nil {return _c .Wrap (_cdb ,_af ,"\u0043\u0065\u006e\u0074\u0072\u006f\u0069\u0064\u0050o\u0069\u006e\u0074\u0073");};if _eb ,_cdb =_gacb .ClassIDs .Get (_ba );_cdb !=nil {return _c .Wrap (_cdb ,_af ,"\u0043\u006c\u0061s\u0073\u0049\u0044\u0073\u002e\u0047\u0065\u0074"); +};if _gcc ,_fd ,_cdb =_gacb .CentroidPointsTemplates .GetGeometry (_eb );_cdb !=nil {return _c .Wrap (_cdb ,_af ,"\u0043\u0065\u006etr\u006f\u0069\u0064\u0050\u006f\u0069\u006e\u0074\u0073\u0054\u0065\u006d\u0070\u006c\u0061\u0074\u0065\u0073");};_ee :=_gcc -_bg ; +_ec :=_fd -_gab ;if _ee >=0{_gg =int (_ee +0.5);}else {_gg =int (_ee -0.5);};if _ec >=0{_dc =int (_ec +0.5);}else {_dc =int (_ec -0.5);};if _aa ,_cdb =_ff .Get (_aac );_cdb !=nil {return _c .Wrap (_cdb ,_af ,"");};_dfc ,_eac :=_aa .Min .X ,_aa .Min .Y ; +_bb ,_cdb =_gacb .UndilatedTemplates .GetBitmap (_eb );if _cdb !=nil {return _c .Wrap (_cdb ,_af ,"\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"); +};_eba ,_cdb =_fe (_eab ,_dfc ,_eac ,_gg ,_dc ,_bb );if _cdb !=nil {return _c .Wrap (_cdb ,_af ,"");};_gacb .PtaUL .AddPoint (float32 (_dfc -_gg +_eba .X ),float32 (_eac -_dc +_eba .Y ));};return nil ;};type similarTemplatesFinder struct{Classer *Classer ; +Width int ;Height int ;Index int ;CurrentNumbers []int ;N int ;};
\ No newline at end of file |
