wechat_qrcode.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifndef __OPENCV_WECHAT_QRCODE_HPP__
  8. #define __OPENCV_WECHAT_QRCODE_HPP__
  9. #include "opencv2/core.hpp"
  10. /** @defgroup wechat_qrcode WeChat QR code detector for detecting and parsing QR code.
  11. */
  12. namespace cv {
  13. namespace wechat_qrcode {
  14. //! @addtogroup wechat_qrcode
  15. //! @{
  16. /**
  17. * @brief WeChat QRCode includes two CNN-based models:
  18. * A object detection model and a super resolution model.
  19. * Object detection model is applied to detect QRCode with the bounding box.
  20. * super resolution model is applied to zoom in QRCode when it is small.
  21. *
  22. */
  23. class CV_EXPORTS_W WeChatQRCode {
  24. public:
  25. /**
  26. * @brief Initialize the WeChatQRCode.
  27. * It includes two models, which are packaged with caffe format.
  28. * Therefore, there are prototxt and caffe models (In total, four paramenters).
  29. *
  30. * @param detector_prototxt_path prototxt file path for the detector
  31. * @param detector_caffe_model_path caffe model file path for the detector
  32. * @param super_resolution_prototxt_path prototxt file path for the super resolution model
  33. * @param super_resolution_caffe_model_path caffe file path for the super resolution model
  34. */
  35. CV_WRAP WeChatQRCode(const std::string& detector_prototxt_path = "",
  36. const std::string& detector_caffe_model_path = "",
  37. const std::string& super_resolution_prototxt_path = "",
  38. const std::string& super_resolution_caffe_model_path = "");
  39. ~WeChatQRCode(){};
  40. /**
  41. * @brief Both detects and decodes QR code.
  42. * To simplify the usage, there is a only API: detectAndDecode
  43. *
  44. * @param img supports grayscale or color (BGR) image.
  45. * @param points optional output array of vertices of the found QR code quadrangle. Will be
  46. * empty if not found.
  47. * @return list of decoded string.
  48. */
  49. CV_WRAP std::vector<std::string> detectAndDecode(InputArray img,
  50. OutputArrayOfArrays points = noArray());
  51. protected:
  52. class Impl;
  53. Ptr<Impl> p;
  54. };
  55. //! @}
  56. } // namespace wechat_qrcode
  57. } // namespace cv
  58. #endif // __OPENCV_WECHAT_QRCODE_HPP__