mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-20 04:25:42 +08:00

1D Barcode support * init barcode interface. * barcode: update readme. * now it is just interface, do not need CMakeLists to compiler it. Signed-off-by: Killer_Quinn <51754303+Certseeds@users.noreply.github.com> * fix-trailing whitespace of docs-build. Signed-off-by: Killer_Quinn <51754303+Certseeds@users.noreply.github.com> * Branch: Barcode-Support,replace vector<RotateRect> to vector<vector<Point2f>>, barcodeDirectly now just output one string, this commit is still only contain interface, barcode module will not be compile. Signed-off-by: Killer_Quinn <51754303+Certseeds@users.noreply.github.com> * add implementation details * fix doc bug * not generate python bindings temporarily * add barcode group for doxygen * generate python bindings and improve performance * remove win10 build warnings in detect stage * remove win10 build warnings on decode stage * add samples and accuracy tests * Update README.md * add tutorial, part of content is to be done. * add decode and EAN part in tutorial * refactor imports * delete decodeDirectly api for simplicity * add super resolution and optimize code format * Use @snippet / @include doxygen statements for embedding code from .cpp files * improve decoding performance * optimize code and slightly improve the performance * add ean8 support * add references and use uint type for some non-negative variables * support java bindings * optimize wording in source code and documentation * refine code * whitespace * bugfix: forget to clear list Co-authored-by: darkliang <11710911@mail.sustech.edu.cn> Co-authored-by: WangberlinT <11711613@mail.sustech.edu.cn> Co-authored-by: Junhao Liang <43094337+darkliang@users.noreply.github.com>
102 lines
3.7 KiB
C++
102 lines
3.7 KiB
C++
// This file is part of OpenCV project.
|
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
// of this distribution and at http://opencv.org/license.html.
|
|
// Copyright (c) 2020-2021 darkliang wangberlinT Certseeds
|
|
|
|
#ifndef __OPENCV_BARCODE_HPP__
|
|
#define __OPENCV_BARCODE_HPP__
|
|
|
|
#include <opencv2/core.hpp>
|
|
#include <ostream>
|
|
|
|
/** @defgroup barcode Barcode detecting and decoding methods
|
|
*/
|
|
|
|
namespace cv {
|
|
namespace barcode {
|
|
|
|
//! @addtogroup barcode
|
|
//! @{
|
|
|
|
enum BarcodeType
|
|
{
|
|
NONE, EAN_8, EAN_13, UPC_A, UPC_E, UPC_EAN_EXTENSION
|
|
};
|
|
|
|
static inline std::ostream &operator<<(std::ostream &out, const BarcodeType &barcode_type)
|
|
{
|
|
switch (barcode_type)
|
|
{
|
|
case BarcodeType::EAN_8:
|
|
out << "EAN_8";
|
|
break;
|
|
case BarcodeType::EAN_13:
|
|
out << "EAN_13";
|
|
break;
|
|
case BarcodeType::UPC_E:
|
|
out << "UPC_E";
|
|
break;
|
|
case BarcodeType::UPC_A:
|
|
out << "UPC_A";
|
|
break;
|
|
case BarcodeType::UPC_EAN_EXTENSION:
|
|
out << "UPC_EAN_EXTENSION";
|
|
break;
|
|
default:
|
|
out << "NONE";
|
|
}
|
|
return out;
|
|
}
|
|
|
|
class CV_EXPORTS_W BarcodeDetector
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Initialize the BarcodeDetector.
|
|
* @param prototxt_path prototxt file path for the super resolution model
|
|
* @param model_path model file path for the super resolution model
|
|
*/
|
|
CV_WRAP BarcodeDetector(const std::string &prototxt_path = "", const std::string &model_path = "");
|
|
|
|
~BarcodeDetector();
|
|
|
|
/** @brief Detects Barcode in image and returns the rectangle(s) containing the code.
|
|
*
|
|
* @param img grayscale or color (BGR) image containing (or not) Barcode.
|
|
* @param points Output vector of vector of vertices of the minimum-area rotated rectangle containing the codes.
|
|
* For N detected barcodes, the dimensions of this array should be [N][4].
|
|
* Order of four points in vector< Point2f> is bottomLeft, topLeft, topRight, bottomRight.
|
|
*/
|
|
CV_WRAP bool detect(InputArray img, OutputArray points) const;
|
|
|
|
/** @brief Decodes barcode in image once it's found by the detect() method.
|
|
*
|
|
* @param img grayscale or color (BGR) image containing bar code.
|
|
* @param points vector of rotated rectangle vertices found by detect() method (or some other algorithm).
|
|
* For N detected barcodes, the dimensions of this array should be [N][4].
|
|
* Order of four points in vector<Point2f> is bottomLeft, topLeft, topRight, bottomRight.
|
|
* @param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
|
|
* @param decoded_type vector of BarcodeType, specifies the type of these barcodes
|
|
*/
|
|
CV_WRAP bool decode(InputArray img, InputArray points, CV_OUT std::vector<std::string> &decoded_info, CV_OUT
|
|
std::vector<BarcodeType> &decoded_type) const;
|
|
|
|
/** @brief Both detects and decodes barcode
|
|
|
|
* @param img grayscale or color (BGR) image containing barcode.
|
|
* @param decoded_info UTF8-encoded output vector of string(s) or empty vector of string if the codes cannot be decoded.
|
|
* @param decoded_type vector of BarcodeType, specifies the type of these barcodes
|
|
* @param points optional output vector of vertices of the found barcode rectangle. Will be empty if not found.
|
|
*/
|
|
CV_WRAP bool detectAndDecode(InputArray img, CV_OUT std::vector<std::string> &decoded_info, CV_OUT
|
|
std::vector<BarcodeType> &decoded_type, OutputArray points = noArray()) const;
|
|
|
|
protected:
|
|
struct Impl;
|
|
Ptr<Impl> p;
|
|
};
|
|
//! @}
|
|
}
|
|
} // cv::barcode::
|
|
#endif //__OPENCV_BARCODE_HPP__
|