forked from makiuchi-d/gozxing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi_detector.go
41 lines (35 loc) · 1.11 KB
/
multi_detector.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package detector
import (
"github.com/kaxap/gozxing"
"github.com/kaxap/gozxing/common"
"github.com/kaxap/gozxing/qrcode/detector"
)
// MultiDetector Encapsulates logic that can detect one or more QR Codes in an image,
// even if the QR Code is rotated or skewed, or partially obscured.
type MultiDetector struct {
*detector.Detector
}
func NewMultiDetector(image *gozxing.BitMatrix) *MultiDetector {
return &MultiDetector{
detector.NewDetector(image),
}
}
func (this *MultiDetector) DetectMulti(hints map[gozxing.DecodeHintType]interface{}) ([]*common.DetectorResult, error) {
image := this.GetImage()
resultPointCallback, _ := hints[gozxing.DecodeHintType_NEED_RESULT_POINT_CALLBACK].(gozxing.ResultPointCallback)
finder := NewMultiFinderPatternFinder(image, resultPointCallback)
infos, e := finder.FindMulti(hints)
if e != nil || len(infos) == 0 {
return nil, gozxing.WrapNotFoundException(e)
}
result := make([]*common.DetectorResult, 0)
for _, info := range infos {
r, e := this.ProcessFinderPatternInfo(info)
if e != nil {
// ignore
continue
}
result = append(result, r)
}
return result, nil
}