| 1 | package detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/ |
| 2 | |
| 3 | import ( |
| 4 | "mathscip-go gomod github.com/golang/go/src go1.17 math/" |
| 5 | "sortscip-go gomod github.com/golang/go/src go1.17 sort/" |
| 6 | |
| 7 | "github.com/makiuchi-d/gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/" |
| 8 | ) |
| 9 | |
| 10 | const ( |
| 11 | FinderPatternFinder_CENTER_QUORUMscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_CENTER_QUORUM. = 2 |
| 12 | FinderPatternFinder_MIN_SKIPscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_MIN_SKIP. = 3 |
| 13 | FinderPatternFinder_MAX_MODULESscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_MAX_MODULES. = 97 |
| 14 | ) |
| 15 | |
| 16 | type FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder# struct { |
| 17 | imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image. *gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.BitMatrixscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix# |
| 18 | possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters. []*FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern# |
| 19 | hasSkippedscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#hasSkipped. bool |
| 20 | crossCheckStateCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#crossCheckStateCount. []int |
| 21 | resultPointCallbackscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#resultPointCallback. gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointCallbackscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPointCallback# |
| 22 | } |
| 23 | |
| 24 | func NewFinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/NewFinderPatternFinder().(image *gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.BitMatrixscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#, resultPointCallback gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointCallbackscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPointCallback#) *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder# { |
| 25 | return &FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#{ |
| 26 | imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image.: image, |
| 27 | possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.: make([]*FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#, 0), |
| 28 | crossCheckStateCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#crossCheckStateCount.: make([]int, 5), |
| 29 | resultPointCallbackscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#resultPointCallback.: resultPointCallback, |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) GetImagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#GetImage().() *gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.BitMatrixscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix# { |
| 34 | return f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image. |
| 35 | } |
| 36 | |
| 37 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) GetPossibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#GetPossibleCenters().() []*FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern# { |
| 38 | return f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters. |
| 39 | } |
| 40 | |
| 41 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) Findscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#Find().(hints map[gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.DecodeHintTypescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/DecodeHintType#]interface{}) (*FinderPatternInfoscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternInfo#, gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NotFoundException#) { |
| 42 | _, tryHarder := hints[gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.DecodeHintType_TRY_HARDERscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/DecodeHintType_TRY_HARDER.] |
| 43 | maxI := f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..GetHeightscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetHeight().() |
| 44 | maxJ := f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..GetWidthscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetWidth().() |
| 45 | |
| 46 | iSkip := (3 * maxI) / (4 * FinderPatternFinder_MAX_MODULESscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_MAX_MODULES.) |
| 47 | if iSkip < FinderPatternFinder_MIN_SKIPscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_MIN_SKIP. || tryHarder { |
| 48 | iSkip = FinderPatternFinder_MIN_SKIPscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_MIN_SKIP. |
| 49 | } |
| 50 | |
| 51 | done := false |
| 52 | stateCount := make([]int, 5) |
| 53 | for i := iSkip - 1; i < maxI && !done; i += iSkip { |
| 54 | FinderPatternFinder_doClearCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_doClearCounts().(stateCount) |
| 55 | currentState := 0 |
| 56 | for j := 0; j < maxJ; j++ { |
| 57 | if f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(j, i) { |
| 58 | if (currentState & 1) == 1 { |
| 59 | currentState++ |
| 60 | } |
| 61 | stateCount[currentState]++ |
| 62 | } else { |
| 63 | if (currentState & 1) == 0 { |
| 64 | if currentState == 4 { |
| 65 | if FinderPatternFinder_foundPatternCrossscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_foundPatternCross().(stateCount) { |
| 66 | confirmed := f.HandlePossibleCenterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#HandlePossibleCenter().(stateCount, i, j) |
| 67 | if confirmed { |
| 68 | iSkip = 2 |
| 69 | if f.hasSkippedscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#hasSkipped. { |
| 70 | done = f.HaveMultiplyConfirmedCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#HaveMultiplyConfirmedCenters().() |
| 71 | } else { |
| 72 | rowSkip := f.FindRowSkipscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#FindRowSkip().() |
| 73 | if rowSkip > stateCount[2] { |
| 74 | i += rowSkip - stateCount[2] - iSkip |
| 75 | j = maxJ - 1 |
| 76 | } |
| 77 | } |
| 78 | } else { |
| 79 | FinderPatternFinder_doShiftCounts2scip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_doShiftCounts2().(stateCount) |
| 80 | currentState = 3 |
| 81 | continue |
| 82 | } |
| 83 | currentState = 0 |
| 84 | FinderPatternFinder_doClearCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_doClearCounts().(stateCount) |
| 85 | } else { |
| 86 | FinderPatternFinder_doShiftCounts2scip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_doShiftCounts2().(stateCount) |
| 87 | currentState = 3 |
| 88 | } |
| 89 | } else { |
| 90 | currentState++ |
| 91 | stateCount[currentState]++ |
| 92 | } |
| 93 | } else { |
| 94 | stateCount[currentState]++ |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | if FinderPatternFinder_foundPatternCrossscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_foundPatternCross().(stateCount) { |
| 99 | confirmed := f.HandlePossibleCenterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#HandlePossibleCenter().(stateCount, i, maxJ) |
| 100 | if confirmed { |
| 101 | iSkip = stateCount[0] |
| 102 | if f.hasSkippedscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#hasSkipped. { |
| 103 | done = f.HaveMultiplyConfirmedCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#HaveMultiplyConfirmedCenters().() |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | fps, e := f.SelectBestPatternsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#SelectBestPatterns().() |
| 110 | if e != nil { |
| 111 | return nil, e |
| 112 | } |
| 113 | |
| 114 | bl, tl, tr := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPoint_OrderBestPatternsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint_OrderBestPatterns().(fps[0], fps[1], fps[2]) |
| 115 | info := NewFinderPatternInfoscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/NewFinderPatternInfo().(bl.(*FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#), tl.(*FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#), tr.(*FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#)) |
| 116 | return info, nil |
| 117 | } |
| 118 | |
| 119 | func FinderPatternFinder_centerFromEndscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_centerFromEnd().(stateCount []int, end int) float64 { |
| 120 | return float64(end-stateCount[4]-stateCount[3]) - float64(stateCount[2])/2 |
| 121 | } |
| 122 | |
| 123 | func FinderPatternFinder_foundPatternCrossscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_foundPatternCross().(stateCount []int) bool { |
| 124 | totalModuleSize := 0 |
| 125 | for i := 0; i < 5; i++ { |
| 126 | count := stateCount[i] |
| 127 | if count == 0 { |
| 128 | return false |
| 129 | } |
| 130 | totalModuleSize += count |
| 131 | } |
| 132 | if totalModuleSize < 7 { |
| 133 | return false |
| 134 | } |
| 135 | moduleSize := float64(totalModuleSize) / 7.0 |
| 136 | maxVariance := moduleSize / 2.0 |
| 137 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(moduleSize-float64(stateCount[0])) < maxVariance && |
| 138 | mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(moduleSize-float64(stateCount[1])) < maxVariance && |
| 139 | mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(3.0*moduleSize-float64(stateCount[2])) < 3*maxVariance && |
| 140 | mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(moduleSize-float64(stateCount[3])) < maxVariance && |
| 141 | mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(moduleSize-float64(stateCount[4])) < maxVariance |
| 142 | } |
| 143 | |
| 144 | func FinderPatternFinder_foundPatternDiagonalscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_foundPatternDiagonal().(stateCount []int) bool { |
| 145 | totalModuleSize := 0 |
| 146 | for i := 0; i < 5; i++ { |
| 147 | count := stateCount[i] |
| 148 | if count == 0 { |
| 149 | return false |
| 150 | } |
| 151 | totalModuleSize += count |
| 152 | } |
| 153 | if totalModuleSize < 7 { |
| 154 | return false |
| 155 | } |
| 156 | moduleSize := float64(totalModuleSize) / 7.0 |
| 157 | maxVariance := moduleSize / 1.333 |
| 158 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(moduleSize-float64(stateCount[0])) < maxVariance && |
| 159 | mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(moduleSize-float64(stateCount[1])) < maxVariance && |
| 160 | mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(3.0*moduleSize-float64(stateCount[2])) < 3*maxVariance && |
| 161 | mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(moduleSize-float64(stateCount[3])) < maxVariance && |
| 162 | mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(moduleSize-float64(stateCount[4])) < maxVariance |
| 163 | } |
| 164 | |
| 165 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) GetCrossCheckStateCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#GetCrossCheckStateCount().() []int { |
| 166 | FinderPatternFinder_doClearCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_doClearCounts().(f.crossCheckStateCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#crossCheckStateCount.) |
| 167 | return f.crossCheckStateCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#crossCheckStateCount. |
| 168 | } |
| 169 | |
| 170 | func FinderPatternFinder_ClearCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_ClearCounts().(counts []int) { |
| 171 | FinderPatternFinder_doClearCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_doClearCounts().(counts) |
| 172 | } |
| 173 | |
| 174 | func FinderPatternFinder_ShiftCounts2scip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_ShiftCounts2().(stateCount []int) { |
| 175 | FinderPatternFinder_doShiftCounts2scip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_doShiftCounts2().(stateCount) |
| 176 | } |
| 177 | |
| 178 | func FinderPatternFinder_doClearCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_doClearCounts().(counts []int) { |
| 179 | for x := 0; x < len(counts); x++ { |
| 180 | counts[x] = 0 |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | func FinderPatternFinder_doShiftCounts2scip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_doShiftCounts2().(stateCount []int) { |
| 185 | stateCount[0] = stateCount[2] |
| 186 | stateCount[1] = stateCount[3] |
| 187 | stateCount[2] = stateCount[4] |
| 188 | stateCount[3] = 1 |
| 189 | stateCount[4] = 0 |
| 190 | } |
| 191 | |
| 192 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) crossCheckDiagonalscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#crossCheckDiagonal().(centerI, centerJ int) bool { |
| 193 | stateCount := f.GetCrossCheckStateCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#GetCrossCheckStateCount().() |
| 194 | |
| 195 | i := 0 |
| 196 | for centerI >= i && centerJ >= i && f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ-i, centerI-i) { |
| 197 | stateCount[2]++ |
| 198 | i++ |
| 199 | } |
| 200 | if stateCount[2] == 0 { |
| 201 | return false |
| 202 | } |
| 203 | |
| 204 | for centerI >= i && centerJ >= i && !f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ-i, centerI-i) { |
| 205 | stateCount[1]++ |
| 206 | i++ |
| 207 | } |
| 208 | if stateCount[1] == 0 { |
| 209 | return false |
| 210 | } |
| 211 | |
| 212 | for centerI >= i && centerJ >= i && f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ-i, centerI-i) { |
| 213 | stateCount[0]++ |
| 214 | i++ |
| 215 | } |
| 216 | if stateCount[0] == 0 { |
| 217 | return false |
| 218 | } |
| 219 | |
| 220 | maxI := f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..GetHeightscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetHeight().() |
| 221 | maxJ := f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..GetWidthscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetWidth().() |
| 222 | |
| 223 | i = 1 |
| 224 | for centerI+i < maxI && centerJ+i < maxJ && f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ+i, centerI+i) { |
| 225 | stateCount[2]++ |
| 226 | i++ |
| 227 | } |
| 228 | for centerI+i < maxI && centerJ+i < maxJ && !f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ+i, centerI+i) { |
| 229 | stateCount[3]++ |
| 230 | i++ |
| 231 | } |
| 232 | if stateCount[3] == 0 { |
| 233 | return false |
| 234 | } |
| 235 | |
| 236 | for centerI+i < maxI && centerJ+i < maxJ && f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ+i, centerI+i) { |
| 237 | stateCount[4]++ |
| 238 | i++ |
| 239 | } |
| 240 | if stateCount[4] == 0 { |
| 241 | return false |
| 242 | } |
| 243 | |
| 244 | return FinderPatternFinder_foundPatternDiagonalscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_foundPatternDiagonal().(stateCount) |
| 245 | } |
| 246 | |
| 247 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) CrossCheckVerticalscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#CrossCheckVertical().(startI, centerJ, maxCount, originalStateCountTotal int) float64 { |
| 248 | image := f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image. |
| 249 | |
| 250 | maxI := image.GetHeightscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetHeight().() |
| 251 | stateCount := f.GetCrossCheckStateCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#GetCrossCheckStateCount().() |
| 252 | |
| 253 | // Start counting up from center |
| 254 | i := startI |
| 255 | |
| 256 | for i >= 0 && image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ, i) { |
| 257 | stateCount[2]++ |
| 258 | i-- |
| 259 | } |
| 260 | if i < 0 { |
| 261 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 262 | } |
| 263 | for i >= 0 && !image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ, i) && stateCount[1] <= maxCount { |
| 264 | stateCount[1]++ |
| 265 | i-- |
| 266 | } |
| 267 | |
| 268 | if i < 0 || stateCount[1] > maxCount { |
| 269 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 270 | } |
| 271 | for i >= 0 && image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ, i) && stateCount[0] <= maxCount { |
| 272 | stateCount[0]++ |
| 273 | i-- |
| 274 | } |
| 275 | if stateCount[0] > maxCount { |
| 276 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 277 | } |
| 278 | |
| 279 | // Now also count down from center |
| 280 | i = startI + 1 |
| 281 | for i < maxI && image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ, i) { |
| 282 | stateCount[2]++ |
| 283 | i++ |
| 284 | } |
| 285 | if i == maxI { |
| 286 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 287 | } |
| 288 | for i < maxI && !image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ, i) && stateCount[3] < maxCount { |
| 289 | stateCount[3]++ |
| 290 | i++ |
| 291 | } |
| 292 | if i == maxI || stateCount[3] >= maxCount { |
| 293 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 294 | } |
| 295 | for i < maxI && image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(centerJ, i) && stateCount[4] < maxCount { |
| 296 | stateCount[4]++ |
| 297 | i++ |
| 298 | } |
| 299 | if stateCount[4] >= maxCount { |
| 300 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 301 | } |
| 302 | |
| 303 | stateCountTotal := stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4] |
| 304 | if 5*mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(float64(stateCountTotal-originalStateCountTotal)) >= float64(2*originalStateCountTotal) { |
| 305 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 306 | } |
| 307 | |
| 308 | if FinderPatternFinder_foundPatternCrossscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_foundPatternCross().(stateCount) { |
| 309 | return FinderPatternFinder_centerFromEndscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_centerFromEnd().(stateCount, i) |
| 310 | } |
| 311 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 312 | } |
| 313 | |
| 314 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) CrossCheckHorizontalscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#CrossCheckHorizontal().(startJ, centerI, maxCount, originalStateCountTotal int) float64 { |
| 315 | image := f.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#image. |
| 316 | |
| 317 | maxJ := image.GetWidthscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetWidth().() |
| 318 | stateCount := f.GetCrossCheckStateCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#GetCrossCheckStateCount().() |
| 319 | |
| 320 | j := startJ |
| 321 | for j >= 0 && image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(j, centerI) { |
| 322 | stateCount[2]++ |
| 323 | j-- |
| 324 | } |
| 325 | if j < 0 { |
| 326 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 327 | } |
| 328 | for j >= 0 && !image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(j, centerI) && stateCount[1] <= maxCount { |
| 329 | stateCount[1]++ |
| 330 | j-- |
| 331 | } |
| 332 | if j < 0 || stateCount[1] > maxCount { |
| 333 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 334 | } |
| 335 | for j >= 0 && image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(j, centerI) && stateCount[0] <= maxCount { |
| 336 | stateCount[0]++ |
| 337 | j-- |
| 338 | } |
| 339 | if stateCount[0] > maxCount { |
| 340 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 341 | } |
| 342 | |
| 343 | j = startJ + 1 |
| 344 | for j < maxJ && image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(j, centerI) { |
| 345 | stateCount[2]++ |
| 346 | j++ |
| 347 | } |
| 348 | if j == maxJ { |
| 349 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 350 | } |
| 351 | for j < maxJ && !image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(j, centerI) && stateCount[3] < maxCount { |
| 352 | stateCount[3]++ |
| 353 | j++ |
| 354 | } |
| 355 | if j == maxJ || stateCount[3] >= maxCount { |
| 356 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 357 | } |
| 358 | for j < maxJ && image.Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(j, centerI) && stateCount[4] < maxCount { |
| 359 | stateCount[4]++ |
| 360 | j++ |
| 361 | } |
| 362 | if stateCount[4] >= maxCount { |
| 363 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 364 | } |
| 365 | |
| 366 | stateCountTotal := stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4] |
| 367 | if 5*mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(float64(stateCountTotal-originalStateCountTotal)) >= float64(originalStateCountTotal) { |
| 368 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 369 | } |
| 370 | |
| 371 | if FinderPatternFinder_foundPatternCrossscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_foundPatternCross().(stateCount) { |
| 372 | return FinderPatternFinder_centerFromEndscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_centerFromEnd().(stateCount, j) |
| 373 | } |
| 374 | return mathscip-go gomod github.com/golang/go/src go1.17 math/.NaNscip-go gomod github.com/golang/go/src go1.17 math/NaN().() |
| 375 | } |
| 376 | |
| 377 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) HandlePossibleCenterWithPureBarcodescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#HandlePossibleCenterWithPureBarcode().(stateCount []int, i, j int, pureBarcode bool) bool { |
| 378 | return f.HandlePossibleCenterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#HandlePossibleCenter().(stateCount, i, j) |
| 379 | } |
| 380 | |
| 381 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) HandlePossibleCenterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#HandlePossibleCenter().(stateCount []int, i, j int) bool { |
| 382 | stateCountTotal := stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4] |
| 383 | centerJ := FinderPatternFinder_centerFromEndscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_centerFromEnd().(stateCount, j) |
| 384 | |
| 385 | centerI := f.CrossCheckVerticalscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#CrossCheckVertical().(i, int(centerJ), stateCount[2], stateCountTotal) |
| 386 | if !mathscip-go gomod github.com/golang/go/src go1.17 math/.IsNaNscip-go gomod github.com/golang/go/src go1.17 math/IsNaN().(centerI) { |
| 387 | centerJ = f.CrossCheckHorizontalscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#CrossCheckHorizontal().(int(centerJ), int(centerI), stateCount[2], stateCountTotal) |
| 388 | if !mathscip-go gomod github.com/golang/go/src go1.17 math/.IsNaNscip-go gomod github.com/golang/go/src go1.17 math/IsNaN().(centerJ) && f.crossCheckDiagonalscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#crossCheckDiagonal().(int(centerI), int(centerJ)) { |
| 389 | estimatedModuleSize := float64(stateCountTotal) / 7.0 |
| 390 | found := false |
| 391 | for index := 0; index < len(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.); index++ { |
| 392 | center := f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.[index] |
| 393 | |
| 394 | if center.AboutEqualsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#AboutEquals().(estimatedModuleSize, centerI, centerJ) { |
| 395 | f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.[index] = center.CombineEstimatescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#CombineEstimate().(centerI, centerJ, estimatedModuleSize) |
| 396 | found = true |
| 397 | break |
| 398 | } |
| 399 | } |
| 400 | if !found { |
| 401 | point := NewFinderPattern1scip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/NewFinderPattern1().(centerJ, centerI, estimatedModuleSize) |
| 402 | f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters. = append(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters., point) |
| 403 | if f.resultPointCallbackscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#resultPointCallback. != nil { |
| 404 | f.resultPointCallbackscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#resultPointCallback.(point) |
| 405 | } |
| 406 | } |
| 407 | return true |
| 408 | } |
| 409 | } |
| 410 | return false |
| 411 | } |
| 412 | |
| 413 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) FindRowSkipscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#FindRowSkip().() int { |
| 414 | if len(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.) <= 1 { |
| 415 | return 0 |
| 416 | } |
| 417 | var firstConfirmedCenter *FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern# |
| 418 | for _, center := range f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters. { |
| 419 | if center.GetCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#GetCount().() >= FinderPatternFinder_CENTER_QUORUMscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_CENTER_QUORUM. { |
| 420 | if firstConfirmedCenter == nil { |
| 421 | firstConfirmedCenter = center |
| 422 | } else { |
| 423 | f.hasSkippedscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#hasSkipped. = true |
| 424 | return int((mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(firstConfirmedCenter.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.()-center.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.()) - |
| 425 | mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(firstConfirmedCenter.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.()-center.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.())) / 2) |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | return 0 |
| 430 | } |
| 431 | |
| 432 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) HaveMultiplyConfirmedCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#HaveMultiplyConfirmedCenters().() bool { |
| 433 | confirmedCount := 0 |
| 434 | totalModuleSize := 0.0 |
| 435 | max := len(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.) |
| 436 | for _, pattern := range f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters. { |
| 437 | if pattern.GetCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#GetCount().() >= FinderPatternFinder_CENTER_QUORUMscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder_CENTER_QUORUM. { |
| 438 | confirmedCount++ |
| 439 | totalModuleSize += pattern.GetEstimatedModuleSizescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#GetEstimatedModuleSize().() |
| 440 | } |
| 441 | } |
| 442 | if confirmedCount < 3 { |
| 443 | return false |
| 444 | } |
| 445 | |
| 446 | average := totalModuleSize / float64(max) |
| 447 | totalDeviation := 0.0 |
| 448 | for _, pattern := range f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters. { |
| 449 | totalDeviation += mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(pattern.GetEstimatedModuleSizescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#GetEstimatedModuleSize().() - average) |
| 450 | } |
| 451 | return totalDeviation <= 0.05*totalModuleSize |
| 452 | } |
| 453 | |
| 454 | // squaredDistance get square of distance between a and b. |
| 455 | func squaredDistancescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/squaredDistance().(a, b *FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#) float64 { |
| 456 | x := a.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() - b.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() |
| 457 | y := a.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() - b.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() |
| 458 | return x*x + y*y |
| 459 | } |
| 460 | |
| 461 | // SelectBestPatterns return the 3 best {@link FinderPattern}s from our list of candidates. |
| 462 | // The "best" are those have similar module size and form a shape closer to a isosceles right triangle. |
| 463 | // @throws NotFoundException if 3 such finder patterns do not exist |
| 464 | func (f *FinderPatternFinderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#) SelectBestPatternsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#SelectBestPatterns().() ([]*FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#, gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NotFoundException#) { |
| 465 | startSize := float64(len(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.)) |
| 466 | if startSize < 3 { |
| 467 | return nil, gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewNotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewNotFoundException().("startSize = %v", startSize) |
| 468 | } |
| 469 | |
| 470 | sortscip-go gomod github.com/golang/go/src go1.17 sort/.Slicescip-go gomod github.com/golang/go/src go1.17 sort/Slice().(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters., estimatedModuleComparatorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/estimatedModuleComparator().(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.)) |
| 471 | |
| 472 | distortion := mathscip-go gomod github.com/golang/go/src go1.17 math/.MaxFloat64scip-go gomod github.com/golang/go/src go1.17 math/MaxFloat64. |
| 473 | bestPatterns := []*FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#{nil, nil, nil} |
| 474 | |
| 475 | for i := 0; i < len(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.)-2; i++ { |
| 476 | fpi := f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.[i] |
| 477 | minModuleSize := fpi.GetEstimatedModuleSizescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#GetEstimatedModuleSize().() |
| 478 | |
| 479 | for j := i + 1; j < len(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.)-1; j++ { |
| 480 | fpj := f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.[j] |
| 481 | square0 := squaredDistancescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/squaredDistance().(fpi, fpj) |
| 482 | |
| 483 | for k := j + 1; k < len(f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.); k++ { |
| 484 | fpk := f.possibleCentersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPatternFinder#possibleCenters.[k] |
| 485 | maxModuleSize := fpk.GetEstimatedModuleSizescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#GetEstimatedModuleSize().() |
| 486 | if maxModuleSize > minModuleSize*1.4 { |
| 487 | // module size is not similar |
| 488 | continue |
| 489 | } |
| 490 | |
| 491 | a := square0 |
| 492 | b := squaredDistancescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/squaredDistance().(fpj, fpk) |
| 493 | c := squaredDistancescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/squaredDistance().(fpi, fpk) |
| 494 | |
| 495 | // sorts ascending - inlined |
| 496 | if a < b { |
| 497 | if b > c { |
| 498 | if a < c { |
| 499 | b, c = c, b |
| 500 | } else { |
| 501 | a, b, c = c, a, b |
| 502 | } |
| 503 | } |
| 504 | } else { |
| 505 | if b < c { |
| 506 | if a < c { |
| 507 | a, b = b, a |
| 508 | } else { |
| 509 | a, b, c = b, c, a |
| 510 | } |
| 511 | } else { |
| 512 | a, c = c, a |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | // a^2 + b^2 = c^2 (Pythagorean theorem), and a = b (isosceles triangle). |
| 517 | // Since any right triangle satisfies the formula c^2 - b^2 - a^2 = 0, |
| 518 | // we need to check both two equal sides separately. |
| 519 | // The value of |c^2 - 2 * b^2| + |c^2 - 2 * a^2| increases as dissimilarity |
| 520 | // from isosceles right triangle. |
| 521 | d := mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(c-2*b) + mathscip-go gomod github.com/golang/go/src go1.17 math/.Absscip-go gomod github.com/golang/go/src go1.17 math/Abs().(c-2*a) |
| 522 | if d < distortion { |
| 523 | distortion = d |
| 524 | bestPatterns[0] = fpi |
| 525 | bestPatterns[1] = fpj |
| 526 | bestPatterns[2] = fpk |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | if distortion == mathscip-go gomod github.com/golang/go/src go1.17 math/.MaxFloat64scip-go gomod github.com/golang/go/src go1.17 math/MaxFloat64. { |
| 533 | return nil, gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewNotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewNotFoundException().("module size is too different") |
| 534 | } |
| 535 | |
| 536 | return bestPatterns, nil |
| 537 | } |
| 538 | |
| 539 | // estimatedModuleComparator Orders by FinderPatternFinder#getEstimatedModuleSize() |
| 540 | func estimatedModuleComparatorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/estimatedModuleComparator().(patterns []*FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#) func(int, int) bool { |
| 541 | return func(i, j int) bool { |
| 542 | return patterns[j].GetEstimatedModuleSizescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#GetEstimatedModuleSize().() > patterns[i].GetEstimatedModuleSizescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/qrcode/detector`/FinderPattern#GetEstimatedModuleSize().() |
| 543 | } |
| 544 | } |