1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4 //
5 // Tencent is pleased to support the open source community by making WeChat QRCode available.
6 // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
7 
8 #ifndef __OPENCV_WECHAT_QRCODE_DECODERMGR_HPP__
9 #define __OPENCV_WECHAT_QRCODE_DECODERMGR_HPP__
10 
11 // zxing
12 #include "zxing/binarizer.hpp"
13 #include "zxing/binarybitmap.hpp"
14 #include "zxing/decodehints.hpp"
15 #include "zxing/qrcode/qrcode_reader.hpp"
16 #include "zxing/result.hpp"
17 
18 // qbar
19 #include "binarizermgr.hpp"
20 #include "imgsource.hpp"
21 namespace cv {
22 namespace wechat_qrcode {
23 
24 class DecoderMgr {
25 public:
DecoderMgr()26     DecoderMgr() { reader_ = new zxing::qrcode::QRCodeReader(); };
~DecoderMgr()27     ~DecoderMgr(){};
28 
29     int decodeImage(cv::Mat src, bool use_nn_detector, string& result);
30 
31 private:
32     zxing::Ref<zxing::UnicomBlock> qbarUicomBlock_;
33     zxing::DecodeHints decode_hints_;
34 
35     zxing::Ref<zxing::qrcode::QRCodeReader> reader_;
36     BinarizerMgr binarizer_mgr_;
37 
38     zxing::Ref<zxing::Result> Decode(zxing::Ref<zxing::BinaryBitmap> image,
39                                      zxing::DecodeHints hints);
40 
41     int TryDecode(zxing::Ref<zxing::LuminanceSource> source, zxing::Ref<zxing::Result>& result);
42 };
43 
44 }  // namespace wechat_qrcode
45 }  // namespace cv
46 #endif  // __OPENCV_WECHAT_QRCODE_DECODERMGR_HPP__
47