| 1 | package detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.17 fmt/" |
| 5 | "mathscip-go gomod github.com/golang/go/src go1.17 math/" |
| 6 | "math/bitsscip-go gomod github.com/golang/go/src go1.17 `math/bits`/" |
| 7 | |
| 8 | "github.com/makiuchi-d/gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/" |
| 9 | "github.com/makiuchi-d/gozxing/commonscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common`/" |
| 10 | "github.com/makiuchi-d/gozxing/common/detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/detector`/" |
| 11 | "github.com/makiuchi-d/gozxing/common/reedsolomonscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/reedsolomon`/" |
| 12 | "github.com/makiuchi-d/gozxing/common/utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/" |
| 13 | ) |
| 14 | |
| 15 | var ( |
| 16 | EXPECTED_CORNER_BITSscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/EXPECTED_CORNER_BITS. = []int{ |
| 17 | 0xee0, // 07340 XXX .XX X.. ... |
| 18 | 0x1dc, // 00734 ... XXX .XX X.. |
| 19 | 0x83b, // 04073 X.. ... XXX .XX |
| 20 | 0x707, // 03407 .XX X.. ... XXX |
| 21 | } |
| 22 | ) |
| 23 | |
| 24 | // Detector : Encapsulates logic that can detect an Aztec Code in an image, even if the Aztec Code |
| 25 | // is rotated or skewed, or partially obscured. |
| 26 | // |
| 27 | type Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector# struct { |
| 28 | imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#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# |
| 29 | |
| 30 | compactscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#compact. bool |
| 31 | nbLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbLayers. int |
| 32 | nbDataBlocksscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbDataBlocks. int |
| 33 | nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers. int |
| 34 | shiftscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#shift. int |
| 35 | } |
| 36 | |
| 37 | func NewDetectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/NewDetector().(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#) *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector# { |
| 38 | return &Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#{ |
| 39 | imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image.: image, |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) DetectNoMirrorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#DetectNoMirror().() (*AztecDetectorResultscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/AztecDetectorResult#, error) { |
| 44 | return this.Detectscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#Detect().(false) |
| 45 | } |
| 46 | |
| 47 | // Detect Detects an Aztec Code in an image. |
| 48 | // |
| 49 | // @param isMirror if true, image is a mirror-image of original |
| 50 | // @return {@link AztecDetectorResult} encapsulating results of detecting an Aztec Code |
| 51 | // @throws NotFoundException if no Aztec Code can be found |
| 52 | // |
| 53 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) Detectscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#Detect().(isMirror bool) (*AztecDetectorResultscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/AztecDetectorResult#, error) { |
| 54 | |
| 55 | // 1. Get the center of the aztec matrix |
| 56 | pCenter := this.getMatrixCenterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getMatrixCenter().() |
| 57 | |
| 58 | // 2. Get the center points of the four diagonal points just outside the bull's eye |
| 59 | // [topRight, bottomRight, bottomLeft, topLeft] |
| 60 | bullsEyeCorners, e := this.getBullsEyeCornersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getBullsEyeCorners().(pCenter) |
| 61 | if e != nil { |
| 62 | return nil, gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.WrapNotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/WrapNotFoundException().(e) |
| 63 | } |
| 64 | |
| 65 | if isMirror { |
| 66 | bullsEyeCorners[0], bullsEyeCorners[2] = bullsEyeCorners[2], bullsEyeCorners[0] |
| 67 | } |
| 68 | |
| 69 | // 3. Get the size of the matrix and other parameters from the bull's eye |
| 70 | e = this.extractParametersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#extractParameters().(bullsEyeCorners) |
| 71 | if e != nil { |
| 72 | return nil, gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.WrapNotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/WrapNotFoundException().(e) |
| 73 | } |
| 74 | |
| 75 | // 4. Sample the grid |
| 76 | bits, e := this.sampleGridscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#sampleGrid().(this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image., |
| 77 | bullsEyeCorners[this.shiftscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#shift.%4], |
| 78 | bullsEyeCorners[(this.shiftscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#shift.+1)%4], |
| 79 | bullsEyeCorners[(this.shiftscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#shift.+2)%4], |
| 80 | bullsEyeCorners[(this.shiftscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#shift.+3)%4]) |
| 81 | if e != nil { |
| 82 | return nil, gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.WrapNotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/WrapNotFoundException().(e) |
| 83 | } |
| 84 | |
| 85 | // 5. Get the corners of the matrix. |
| 86 | corners := this.getMatrixCornerPointsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getMatrixCornerPoints().(bullsEyeCorners) |
| 87 | |
| 88 | return NewAztecDetectorResultscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/NewAztecDetectorResult().(bits, corners, this.compactscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#compact., this.nbDataBlocksscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbDataBlocks., this.nbLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbLayers.), nil |
| 89 | } |
| 90 | |
| 91 | // extractParameters Extracts the number of data layers and data blocks from the layer around the bull's eye. |
| 92 | // |
| 93 | // @param bullsEyeCorners the array of bull's eye corners |
| 94 | // @throws NotFoundException in case of too many errors or invalid parameters |
| 95 | // |
| 96 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) extractParametersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#extractParameters().(bullsEyeCorners []gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#) (e error) { |
| 97 | if !this.isValidPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValidPoint().(bullsEyeCorners[0]) || !this.isValidPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValidPoint().(bullsEyeCorners[1]) || |
| 98 | !this.isValidPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValidPoint().(bullsEyeCorners[2]) || !this.isValidPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValidPoint().(bullsEyeCorners[3]) { |
| 99 | return 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().("invalid bulls eye enters: %v", bullsEyeCorners) |
| 100 | } |
| 101 | length := 2 * this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers. |
| 102 | // Get the bits around the bull's eye |
| 103 | sides := []int{ |
| 104 | this.sampleLinescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#sampleLine().(bullsEyeCorners[0], bullsEyeCorners[1], length), // Right side |
| 105 | this.sampleLinescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#sampleLine().(bullsEyeCorners[1], bullsEyeCorners[2], length), // Bottom |
| 106 | this.sampleLinescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#sampleLine().(bullsEyeCorners[2], bullsEyeCorners[3], length), // Left side |
| 107 | this.sampleLinescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#sampleLine().(bullsEyeCorners[3], bullsEyeCorners[0], length), // Top |
| 108 | } |
| 109 | |
| 110 | // bullsEyeCorners[shift] is the corner of the bulls'eye that has three |
| 111 | // orientation marks. |
| 112 | // sides[shift] is the row/column that goes from the corner with three |
| 113 | // orientation marks to the corner with two. |
| 114 | this.shiftscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#shift., e = getRotationscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/getRotation().(sides, length) |
| 115 | if e != nil { |
| 116 | return gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.WrapNotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/WrapNotFoundException().(e) |
| 117 | } |
| 118 | |
| 119 | // Flatten the parameter bits into a single 28- or 40-bit long |
| 120 | parameterData := int64(0) |
| 121 | for i := 0; i < 4; i++ { |
| 122 | side := int64(sides[(this.shiftscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#shift.+i)%4]) |
| 123 | if this.compactscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#compact. { |
| 124 | // Each side of the form ..XXXXXXX. where Xs are parameter data |
| 125 | parameterData <<= 7 |
| 126 | parameterData += (side >> 1) & 0x7F |
| 127 | } else { |
| 128 | // Each side of the form ..XXXXX.XXXXX. where Xs are parameter data |
| 129 | parameterData <<= 10 |
| 130 | parameterData += ((side >> 2) & (0x1f << 5)) + ((side >> 1) & 0x1F) |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // Corrects parameter data using RS. Returns just the data portion |
| 135 | // without the error correction. |
| 136 | correctedData, err := this.getCorrectedParameterDatascip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getCorrectedParameterData().(parameterData, this.compactscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#compact.) |
| 137 | if err != nil { |
| 138 | return err |
| 139 | } |
| 140 | |
| 141 | if this.compactscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#compact. { |
| 142 | // 8 bits: 2 bits layers and 6 bits data blocks |
| 143 | this.nbLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbLayers. = (correctedData >> 6) + 1 |
| 144 | this.nbDataBlocksscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbDataBlocks. = (correctedData & 0x3F) + 1 |
| 145 | } else { |
| 146 | // 16 bits: 5 bits layers and 11 bits data blocks |
| 147 | this.nbLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbLayers. = (correctedData >> 11) + 1 |
| 148 | this.nbDataBlocksscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbDataBlocks. = (correctedData & 0x7FF) + 1 |
| 149 | } |
| 150 | return nil |
| 151 | } |
| 152 | |
| 153 | func getRotationscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/getRotation().(sides []int, length int) (int, error) { |
| 154 | // In a normal pattern, we expect to See |
| 155 | // ** .* D A |
| 156 | // * * |
| 157 | // |
| 158 | // . * |
| 159 | // .. .. C B |
| 160 | // |
| 161 | // Grab the 3 bits from each of the sides the form the locator pattern and concatenate |
| 162 | // into a 12-bit integer. Start with the bit at A |
| 163 | cornerBits := 0 |
| 164 | for _, side := range sides { |
| 165 | // XX......X where X's are orientation marks |
| 166 | t := ((side >> (length - 2)) << 1) + (side & 1) |
| 167 | cornerBits = (cornerBits << 3) + t |
| 168 | } |
| 169 | // Mov the bottom bit to the top, so that the three bits of the locator pattern at A are |
| 170 | // together. cornerBits is now: |
| 171 | // 3 orientation bits at A || 3 orientation bits at B || ... || 3 orientation bits at D |
| 172 | cornerBits = ((cornerBits & 1) << 11) + (cornerBits >> 1) |
| 173 | // The result shift indicates which element of BullsEyeCorners[] goes into the top-left |
| 174 | // corner. Since the four rotation values have a Hamming distance of 8, we |
| 175 | // can easily tolerate two errors. |
| 176 | for shift := 0; shift < 4; shift++ { |
| 177 | if bitsscip-go gomod github.com/golang/go/src go1.17 `math/bits`/.OnesCount16scip-go gomod github.com/golang/go/src go1.17 `math/bits`/OnesCount16().(uint16(cornerBits^EXPECTED_CORNER_BITSscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/EXPECTED_CORNER_BITS.[shift])) <= 2 { |
| 178 | return shift, nil |
| 179 | } |
| 180 | } |
| 181 | return 0, 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().("rotation not found") |
| 182 | } |
| 183 | |
| 184 | // getCorrectedParameterData Corrects the parameter bits using Reed-Solomon algorithm. |
| 185 | // |
| 186 | // @param parameterData parameter bits |
| 187 | // @param compact true if this is a compact Aztec code |
| 188 | // @throws NotFoundException if the array contains too many errors |
| 189 | // |
| 190 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) getCorrectedParameterDatascip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getCorrectedParameterData().(parameterData int64, compact bool) (int, error) { |
| 191 | var numCodewords int |
| 192 | var numDataCodewords int |
| 193 | |
| 194 | if this.compactscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#compact. { |
| 195 | numCodewords = 7 |
| 196 | numDataCodewords = 2 |
| 197 | } else { |
| 198 | numCodewords = 10 |
| 199 | numDataCodewords = 4 |
| 200 | } |
| 201 | |
| 202 | numECCodewords := numCodewords - numDataCodewords |
| 203 | parameterWords := make([]int, numCodewords) |
| 204 | for i := numCodewords - 1; i >= 0; i-- { |
| 205 | parameterWords[i] = int(parameterData) & 0xF |
| 206 | parameterData >>= 4 |
| 207 | } |
| 208 | |
| 209 | rsDecoder := reedsolomonscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/reedsolomon`/.NewReedSolomonDecoderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/reedsolomon`/NewReedSolomonDecoder().(reedsolomonscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/reedsolomon`/.GenericGF_AZTEC_PARAMscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/reedsolomon`/GenericGF_AZTEC_PARAM.) |
| 210 | if err := rsDecoder.Decodescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/reedsolomon`/ReedSolomonDecoder#Decode().(parameterWords, numECCodewords); err != nil { |
| 211 | return 0, gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.WrapNotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/WrapNotFoundException().(err) |
| 212 | } |
| 213 | // Toss the error correction. Just return the data as an integer |
| 214 | result := 0 |
| 215 | for i := 0; i < numDataCodewords; i++ { |
| 216 | result = (result << 4) + parameterWords[i] |
| 217 | } |
| 218 | return result, nil |
| 219 | } |
| 220 | |
| 221 | // getBullsEyeCorners Finds the corners of a bull-eye centered on the passed point. |
| 222 | // This returns the centers of the diagonal points just outside the bull's eye |
| 223 | // Returns [topRight, bottomRight, bottomLeft, topLeft] |
| 224 | // |
| 225 | // @param pCenter Center point |
| 226 | // @return The corners of the bull-eye |
| 227 | // @throws NotFoundException If no valid bull-eye can be found |
| 228 | // |
| 229 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) getBullsEyeCornersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getBullsEyeCorners().(pCenter Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#) ([]gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#, error) { |
| 230 | |
| 231 | pina := pCenter |
| 232 | pinb := pCenter |
| 233 | pinc := pCenter |
| 234 | pind := pCenter |
| 235 | |
| 236 | color := true |
| 237 | |
| 238 | for this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers. = 1; this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers. < 9; this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers.++ { |
| 239 | pouta := this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(pina, color, 1, -1) |
| 240 | poutb := this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(pinb, color, 1, 1) |
| 241 | poutc := this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(pinc, color, -1, 1) |
| 242 | poutd := this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(pind, color, -1, -1) |
| 243 | |
| 244 | //d a |
| 245 | // |
| 246 | //c b |
| 247 | |
| 248 | if this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers. > 2 { |
| 249 | q := distancePscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/distanceP().(poutd, pouta) * float64(this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers.) / (distancePscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/distanceP().(pind, pina) * float64(this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers.+2)) |
| 250 | if q < 0.75 || q > 1.25 || !this.isWhiteOrBlackRectanglescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isWhiteOrBlackRectangle().(pouta, poutb, poutc, poutd) { |
| 251 | break |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | pina = pouta |
| 256 | pinb = poutb |
| 257 | pinc = poutc |
| 258 | pind = poutd |
| 259 | |
| 260 | color = !color |
| 261 | } |
| 262 | |
| 263 | if this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers. != 5 && this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers. != 7 { |
| 264 | 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().("nbCenterLayers = %v", this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers.) |
| 265 | } |
| 266 | |
| 267 | this.compactscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#compact. = this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers. == 5 |
| 268 | |
| 269 | // Expand the square by .5 pixel in each direction so that we're on the border |
| 270 | // between the white square and the black square |
| 271 | pinax := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(float64(pina.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().())+0.5, float64(pina.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().())-0.5) |
| 272 | pinbx := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(float64(pinb.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().())+0.5, float64(pinb.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().())+0.5) |
| 273 | pincx := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(float64(pinc.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().())-0.5, float64(pinc.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().())+0.5) |
| 274 | pindx := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(float64(pind.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().())-0.5, float64(pind.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().())-0.5) |
| 275 | |
| 276 | // Expand the square so that its corners are the centers of the points |
| 277 | // just outside the bull's eye. |
| 278 | return expandSquarescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/expandSquare().([]gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#{pinax, pinbx, pincx, pindx}, |
| 279 | 2*this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers.-3, |
| 280 | 2*this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers.), nil |
| 281 | } |
| 282 | |
| 283 | // getMatrixCenter Finds a candidate center point of an Aztec code from an image |
| 284 | // |
| 285 | // @return the center point |
| 286 | // |
| 287 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) getMatrixCenterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getMatrixCenter().() Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point# { |
| 288 | |
| 289 | var pointA gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint# |
| 290 | var pointB gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint# |
| 291 | var pointC gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint# |
| 292 | var pointD gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint# |
| 293 | |
| 294 | //Get a white rectangle that can be the border of the matrix in center bull's eye or |
| 295 | d, e := detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/detector`/.NewWhiteRectangleDetectorFromImagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/detector`/NewWhiteRectangleDetectorFromImage().(this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image.) |
| 296 | if e == nil { |
| 297 | if cornerPoints, err := d.Detectscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/detector`/WhiteRectangleDetector#Detect().(); err != nil { |
| 298 | e = err |
| 299 | } else { |
| 300 | pointA = cornerPoints[0] |
| 301 | pointB = cornerPoints[1] |
| 302 | pointC = cornerPoints[2] |
| 303 | pointD = cornerPoints[3] |
| 304 | } |
| 305 | } |
| 306 | if e != nil { |
| 307 | // This exception can be in case the initial rectangle is white |
| 308 | // In that case, surely in the bull's eye, we try to expand the rectangle. |
| 309 | cx := this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..GetWidthscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetWidth().() / 2 |
| 310 | cy := this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..GetHeightscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetHeight().() / 2 |
| 311 | pointA = this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(cx+7, cy-7), false, 1, -1).toResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#toResultPoint().() |
| 312 | pointB = this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(cx+7, cy+7), false, 1, 1).toResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#toResultPoint().() |
| 313 | pointC = this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(cx-7, cy+7), false, -1, 1).toResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#toResultPoint().() |
| 314 | pointD = this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(cx-7, cy-7), false, -1, -1).toResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#toResultPoint().() |
| 315 | } |
| 316 | |
| 317 | //Compute the center of the rectangle |
| 318 | cx := utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().((pointA.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() + pointD.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() + pointB.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() + pointC.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.()) / 4.0) |
| 319 | cy := utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().((pointA.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() + pointD.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() + pointB.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() + pointC.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.()) / 4.0) |
| 320 | |
| 321 | // Redetermine the white rectangle starting from previously computed center. |
| 322 | // This will ensure that we end up with a white rectangle in center bull's eye |
| 323 | // in order to compute a more accurate center. |
| 324 | d, e = detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/detector`/.NewWhiteRectangleDetectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/detector`/NewWhiteRectangleDetector().(this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image., 15, cx, cy) |
| 325 | if e == nil { |
| 326 | if cornerPoints, err := d.Detectscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/detector`/WhiteRectangleDetector#Detect().(); err != nil { |
| 327 | e = err |
| 328 | } else { |
| 329 | pointA = cornerPoints[0] |
| 330 | pointB = cornerPoints[1] |
| 331 | pointC = cornerPoints[2] |
| 332 | pointD = cornerPoints[3] |
| 333 | } |
| 334 | } |
| 335 | if e != nil { |
| 336 | // This exception can be in case the initial rectangle is white |
| 337 | // In that case we try to expand the rectangle. |
| 338 | pointA = this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(cx+7, cy-7), false, 1, -1).toResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#toResultPoint().() |
| 339 | pointB = this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(cx+7, cy+7), false, 1, 1).toResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#toResultPoint().() |
| 340 | pointC = this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(cx-7, cy+7), false, -1, 1).toResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#toResultPoint().() |
| 341 | pointD = this.getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(cx-7, cy-7), false, -1, -1).toResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#toResultPoint().() |
| 342 | } |
| 343 | |
| 344 | // Recompute the center of the rectangle |
| 345 | cx = utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().((pointA.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() + pointD.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() + pointB.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() + pointC.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.()) / 4.0) |
| 346 | cy = utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().((pointA.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() + pointD.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() + pointB.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() + pointC.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.()) / 4.0) |
| 347 | |
| 348 | return newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(cx, cy) |
| 349 | } |
| 350 | |
| 351 | // getMatrixCornerPoints Gets the Aztec code corners from the bull's eye corners and the parameters. |
| 352 | // |
| 353 | // @param bullsEyeCorners the array of bull's eye corners |
| 354 | // @return the array of aztec code corners |
| 355 | // |
| 356 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) getMatrixCornerPointsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getMatrixCornerPoints().(bullsEyeCorners []gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#) []gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint# { |
| 357 | return expandSquarescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/expandSquare().(bullsEyeCorners, 2*this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers., this.getDimensionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getDimension().()) |
| 358 | } |
| 359 | |
| 360 | // sampleGrid Creates a BitMatrix by sampling the provided image. |
| 361 | // topLeft, topRight, bottomRight, and bottomLeft are the centers of the squares on the |
| 362 | // diagonal just outside the bull's eye. |
| 363 | // |
| 364 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) sampleGridscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#sampleGrid().( |
| 365 | 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#, |
| 366 | topLeft, topRight, bottomRight, bottomLeft gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#) (*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#, error) { |
| 367 | |
| 368 | sampler := commonscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common`/.GridSampler_GetInstancescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common`/GridSampler_GetInstance().() |
| 369 | dimension := this.getDimensionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getDimension().() |
| 370 | |
| 371 | low := float64(dimension)/2.0 - float64(this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers.) |
| 372 | high := float64(dimension)/2.0 + float64(this.nbCenterLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbCenterLayers.) |
| 373 | |
| 374 | return sampler.SampleGridscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common`/GridSampler#SampleGrid.( |
| 375 | image, |
| 376 | dimension, |
| 377 | dimension, |
| 378 | low, low, // topleft |
| 379 | high, low, // topright |
| 380 | high, high, // bottomright |
| 381 | low, high, // bottomleft |
| 382 | topLeft.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.(), topLeft.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.(), |
| 383 | topRight.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.(), topRight.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.(), |
| 384 | bottomRight.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.(), bottomRight.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.(), |
| 385 | bottomLeft.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.(), bottomLeft.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.()) |
| 386 | } |
| 387 | |
| 388 | // sampleLine Samples a line. |
| 389 | // |
| 390 | // @param p1 start point (inclusive) |
| 391 | // @param p2 end point (exclusive) |
| 392 | // @param size number of bits |
| 393 | // @return the array of bits as an int (first bit is high-order bit of result) |
| 394 | // |
| 395 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) sampleLinescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#sampleLine().(p1, p2 gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#, size int) int { |
| 396 | result := 0 |
| 397 | |
| 398 | d := distanceRPscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/distanceRP().(p1, p2) |
| 399 | moduleSize := d / float64(size) |
| 400 | |
| 401 | px := p1.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() |
| 402 | py := p1.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() |
| 403 | dx := moduleSize * (p2.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() - p1.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.()) / d |
| 404 | dy := moduleSize * (p2.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() - p1.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.()) / d |
| 405 | for i := 0; i < size; i++ { |
| 406 | if this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().(px+float64(i)*dx), utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().(py+float64(i)*dy)) { |
| 407 | result |= 1 << (size - i - 1) |
| 408 | } |
| 409 | } |
| 410 | return result |
| 411 | } |
| 412 | |
| 413 | // isWhiteOrBlackRectangle @return true if the border of the rectangle passed in parameter is compound of white points only or black points only |
| 414 | // |
| 415 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) isWhiteOrBlackRectanglescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isWhiteOrBlackRectangle().(p1, p2, p3, p4 Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#) bool { |
| 416 | |
| 417 | corr := 3 |
| 418 | |
| 419 | p1 = newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(maxscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/max().(0, p1.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().()-corr), minscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/min().(this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..GetHeightscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetHeight().()-1, p1.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().()+corr)) |
| 420 | p2 = newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(maxscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/max().(0, p2.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().()-corr), maxscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/max().(0, p2.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().()-corr)) |
| 421 | p3 = newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(minscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/min().(this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..GetWidthscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetWidth().()-1, p3.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().()+corr), |
| 422 | maxscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/max().(0, minscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/min().(this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..GetHeightscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetHeight().()-1, p3.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().()-corr))) |
| 423 | p4 = newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(minscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/min().(this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..GetWidthscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetWidth().()-1, p4.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().()+corr), |
| 424 | minscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/min().(this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..GetHeightscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetHeight().()-1, p4.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().()+corr)) |
| 425 | |
| 426 | cInit := this.getColorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getColor().(p4, p1) |
| 427 | |
| 428 | if cInit == 0 { |
| 429 | return false |
| 430 | } |
| 431 | |
| 432 | c := this.getColorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getColor().(p1, p2) |
| 433 | |
| 434 | if c != cInit { |
| 435 | return false |
| 436 | } |
| 437 | |
| 438 | c = this.getColorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getColor().(p2, p3) |
| 439 | |
| 440 | if c != cInit { |
| 441 | return false |
| 442 | } |
| 443 | |
| 444 | c = this.getColorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getColor().(p3, p4) |
| 445 | |
| 446 | return c == cInit |
| 447 | } |
| 448 | |
| 449 | func maxscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/max().(a, b int) int { |
| 450 | if a > b { |
| 451 | return a |
| 452 | } |
| 453 | return b |
| 454 | } |
| 455 | |
| 456 | func minscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/min().(a, b int) int { |
| 457 | if a < b { |
| 458 | return a |
| 459 | } |
| 460 | return b |
| 461 | } |
| 462 | |
| 463 | // getColor Gets the color of a segment |
| 464 | // |
| 465 | // @return 1 if segment more than 90% black, -1 if segment is more than 90% white, 0 else |
| 466 | // |
| 467 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) getColorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getColor().(p1, p2 Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#) int { |
| 468 | d := distancePscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/distanceP().(p1, p2) |
| 469 | if d == 0.0 { |
| 470 | return 0 |
| 471 | } |
| 472 | dx := float64(p2.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().()-p1.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().()) / d |
| 473 | dy := float64(p2.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().()-p1.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().()) / d |
| 474 | err := 0 |
| 475 | |
| 476 | px := float64(p1.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().()) |
| 477 | py := float64(p1.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().()) |
| 478 | |
| 479 | colorModel := this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(p1.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().(), p1.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().()) |
| 480 | |
| 481 | iMax := int(mathscip-go gomod github.com/golang/go/src go1.17 math/.Floorscip-go gomod github.com/golang/go/src go1.17 math/Floor().(d)) |
| 482 | for i := 0; i < iMax; i++ { |
| 483 | if this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().(px), utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().(py)) != colorModel { |
| 484 | err++ |
| 485 | } |
| 486 | px += dx |
| 487 | py += dy |
| 488 | } |
| 489 | |
| 490 | errRatio := float64(err) / d |
| 491 | |
| 492 | if errRatio > 0.1 && errRatio < 0.9 { |
| 493 | return 0 |
| 494 | } |
| 495 | |
| 496 | if errRatio <= 0.1 == colorModel { |
| 497 | return 1 |
| 498 | } |
| 499 | return -1 |
| 500 | } |
| 501 | |
| 502 | // getFirstDifferent Gets the coordinate of the first point with a different color in the given direction |
| 503 | // |
| 504 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) getFirstDifferentscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getFirstDifferent().(init Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#, color bool, dx, dy int) Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point# { |
| 505 | x := init.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().() + dx |
| 506 | y := init.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().() + dy |
| 507 | |
| 508 | for this.isValidscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValid().(x, y) && this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(x, y) == color { |
| 509 | x += dx |
| 510 | y += dy |
| 511 | } |
| 512 | |
| 513 | x -= dx |
| 514 | y -= dy |
| 515 | |
| 516 | for this.isValidscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValid().(x, y) && this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(x, y) == color { |
| 517 | x += dx |
| 518 | } |
| 519 | x -= dx |
| 520 | |
| 521 | for this.isValidscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValid().(x, y) && this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..Getscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#Get().(x, y) == color { |
| 522 | y += dy |
| 523 | } |
| 524 | y -= dy |
| 525 | |
| 526 | return newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(x, y) |
| 527 | } |
| 528 | |
| 529 | // expandSquare Expand the square represented by the corner points by pushing out equally in all directions |
| 530 | // |
| 531 | // @param cornerPoints the corners of the square, which has the bull's eye at its center |
| 532 | // @param oldSide the original length of the side of the square in the target bit matrix |
| 533 | // @param newSide the new length of the size of the square in the target bit matrix |
| 534 | // @return the corners of the expanded square |
| 535 | // |
| 536 | func expandSquarescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/expandSquare().(cornerPoints []gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#, oldSide, newSide int) []gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint# { |
| 537 | ratio := float64(newSide) / float64(2*oldSide) |
| 538 | dx := cornerPoints[0].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() - cornerPoints[2].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() |
| 539 | dy := cornerPoints[0].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() - cornerPoints[2].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() |
| 540 | centerx := (cornerPoints[0].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() + cornerPoints[2].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.()) / 2.0 |
| 541 | centery := (cornerPoints[0].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() + cornerPoints[2].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.()) / 2.0 |
| 542 | |
| 543 | result0 := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(centerx+ratio*dx, centery+ratio*dy) |
| 544 | result2 := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(centerx-ratio*dx, centery-ratio*dy) |
| 545 | |
| 546 | dx = cornerPoints[1].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() - cornerPoints[3].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() |
| 547 | dy = cornerPoints[1].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() - cornerPoints[3].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() |
| 548 | centerx = (cornerPoints[1].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() + cornerPoints[3].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.()) / 2.0 |
| 549 | centery = (cornerPoints[1].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() + cornerPoints[3].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.()) / 2.0 |
| 550 | result1 := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(centerx+ratio*dx, centery+ratio*dy) |
| 551 | result3 := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(centerx-ratio*dx, centery-ratio*dy) |
| 552 | |
| 553 | return []gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#{result0, result1, result2, result3} |
| 554 | } |
| 555 | |
| 556 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) isValidscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValid().(x, y int) bool { |
| 557 | return x >= 0 && x < this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..GetWidthscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetWidth().() && y >= 0 && y < this.imagescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#image..GetHeightscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitMatrix#GetHeight().() |
| 558 | } |
| 559 | |
| 560 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) isValidPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValidPoint().(point gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#) bool { |
| 561 | x := utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().(point.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.()) |
| 562 | y := utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_Roundscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_Round().(point.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.()) |
| 563 | return this.isValidscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#isValid().(x, y) |
| 564 | } |
| 565 | |
| 566 | func distancePscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/distanceP().(a, b Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#) float64 { |
| 567 | return utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_DistanceIntscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_DistanceInt().(a.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().(), a.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().(), b.getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().(), b.getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().()) |
| 568 | } |
| 569 | |
| 570 | func distanceRPscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/distanceRP().(a, b gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#) float64 { |
| 571 | return utilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/.MathUtils_DistanceFloatscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/common/util`/MathUtils_DistanceFloat().(a.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.(), a.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.(), b.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.(), b.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.()) |
| 572 | } |
| 573 | |
| 574 | func (this *Detectorscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#) getDimensionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#getDimension().() int { |
| 575 | if this.compactscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#compact. { |
| 576 | return 4*this.nbLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbLayers. + 11 |
| 577 | } |
| 578 | return 4*this.nbLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbLayers. + 2*((2*this.nbLayersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Detector#nbLayers.+6)/15) + 15 |
| 579 | } |
| 580 | |
| 581 | type Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point# struct { |
| 582 | xscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#x., yscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#y. int |
| 583 | } |
| 584 | |
| 585 | func (p Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#) toResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#toResultPoint().() gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint# { |
| 586 | return gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(float64(p.xscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#x.), float64(p.yscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#y.)) |
| 587 | } |
| 588 | |
| 589 | func newPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/newPoint().(x, y int) Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point# { |
| 590 | return Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#{xscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#x.: x, yscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#y.: y} |
| 591 | } |
| 592 | |
| 593 | func (p Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#) getXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getX().() int { |
| 594 | return p.xscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#x. |
| 595 | } |
| 596 | |
| 597 | func (p Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#) getYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#getY().() int { |
| 598 | return p.yscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#y. |
| 599 | } |
| 600 | |
| 601 | func (p Pointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#) Stringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#String().() string { |
| 602 | return fmtscip-go gomod github.com/golang/go/src go1.17 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.17 fmt/Sprintf().("<%d %d>", p.xscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#x., p.yscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/aztec/detector`/Point#y.) |
| 603 | } |