cv::barcode::BarcodeDetector Class ReferenceObject Detection » Barcode detection and decoding
#include <opencv2/objdetect/barcode.hpp>
Public Member Functions | |
| () | |
#include <opencv2/objdetect/barcode.hpp>
Public Member Functions | |
| () | |
| Initialize the BarcodeDetector. |
| BarcodeDetector (CV_WRAP_FILE_PATH const std::string &prototxt_path, CV_WRAP_FILE_PATH const std::string &model_path) |
| Initialize the BarcodeDetector. |
| ~BarcodeDetector () |
| bool | decodeWithType (InputArray img, InputArray points, std::vector< std::string > &decoded_info, std::vector< std::string > &decoded_type) const |
| Decodes barcode in image once it's found by the detect() method. |
| bool | detectAndDecodeWithType (InputArray img, std::vector< std::string > &decoded_info, std::vector< std::string > &decoded_type, OutputArray points=noArray()) const |
| Both detects and decodes barcode. |
| void | getDetectorScales (std::vector< float > &sizes) const |
| Returns detector box filter sizes. |
| double | getDownsamplingThreshold () const |
| Get detector downsampling threshold. |
| double | getGradientThreshold () const |
| Get detector gradient magnitude threshold. |
| BarcodeDetector & | setDetectorScales (const std::vector< float > &sizes) |
| Set detector box filter sizes. |
| BarcodeDetector & | setDownsamplingThreshold (double thresh) |
| Set detector downsampling threshold. |
| BarcodeDetector & | setGradientThreshold (double thresh) |
| Set detector gradient magnitude threshold. |
Public Member Functions inherited from cv::GraphicalCodeDetector |
| GraphicalCodeDetector () |
| GraphicalCodeDetector (const GraphicalCodeDetector &)=default |
| GraphicalCodeDetector (GraphicalCodeDetector &&)=default |
| std::string | decode (InputArray img, InputArray points, OutputArray straight_code=noArray()) const |
| Decodes graphical code in image once it's found by the detect() method. |
| bool | decodeMulti (InputArray img, InputArray points, std::vector< std::string > &decoded_info, OutputArrayOfArrays straight_code=noArray()) const |
| Decodes graphical codes in image once it's found by the detect() method. |
| bool | detect (InputArray img, OutputArray points) const |
| Detects graphical code in image and returns the quadrangle containing the code. |
| std::string | detectAndDecode (InputArray img, OutputArray points=noArray(), OutputArray straight_code=noArray()) const |
| Both detects and decodes graphical code. |
| bool | detectAndDecodeMulti (InputArray img, std::vector< std::string > &decoded_info, OutputArray points=noArray(), OutputArrayOfArrays straight_code=noArray()) const |
| Both detects and decodes graphical codes. |
| bool | detectMulti (InputArray img, OutputArray points) const |
| Detects graphical codes in image and returns the vector of the quadrangles containing the codes. |
| GraphicalCodeDetector & | operator= (const GraphicalCodeDetector &)=default |
| GraphicalCodeDetector & | operator= (GraphicalCodeDetector &&)=default |
Additional Inherited Members | |
Protected Attributes inherited from cv::GraphicalCodeDetector | |
| Ptr< Impl > | p |
| cv::barcode::BarcodeDetector::BarcodeDetector | ( | ) |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector( | ) -> | <barcode_BarcodeDetector object> | ||
| cv.barcode.BarcodeDetector( | prototxt_path, model_path | ) -> | <barcode_BarcodeDetector object> |
Initialize the BarcodeDetector.
| cv::barcode::BarcodeDetector::BarcodeDetector | ( | CV_WRAP_FILE_PATH const std::string & | prototxt_path, |
| CV_WRAP_FILE_PATH const std::string & | model_path ) |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector( | ) -> | <barcode_BarcodeDetector object> | ||
| cv.barcode.BarcodeDetector( | prototxt_path, model_path | ) -> | <barcode_BarcodeDetector object> |
Initialize the BarcodeDetector.
Parameters allow to load optional Super Resolution DNN model for better quality.
| prototxt_path | prototxt file path for the super resolution model |
| model_path | model file path for the super resolution model |
| cv::barcode::BarcodeDetector::~BarcodeDetector | ( | ) |
| bool cv::barcode::BarcodeDetector::decodeWithType | ( | InputArray | img, |
| InputArray | points, | ||
| std::vector< std::string > & | decoded_info, | ||
| std::vector< std::string > & | decoded_type ) const |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector.decodeWithType( | img, points | ) -> | retval, decoded_info, decoded_type |
Decodes barcode in image once it's found by the detect() method.
| img | grayscale or color (BGR) image containing bar code. |
| 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. |
| decoded_info | UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded. |
| decoded_type | vector strings, specifies the type of these barcodes |
| bool cv::barcode::BarcodeDetector::detectAndDecodeWithType | ( | InputArray | img, |
| std::vector< std::string > & | decoded_info, | ||
| std::vector< std::string > & | decoded_type, | ||
| OutputArray | points = noArray() ) const |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector.detectAndDecodeWithType( | img[, points] | ) -> | retval, decoded_info, decoded_type, points |
Both detects and decodes barcode.
| img | grayscale or color (BGR) image containing barcode. |
| decoded_info | UTF8-encoded output vector of string(s) or empty vector of string if the codes cannot be decoded. |
| decoded_type | vector of strings, specifies the type of these barcodes |
| points | optional output vector of vertices of the found barcode rectangle. Will be empty if not found. |
| void cv::barcode::BarcodeDetector::getDetectorScales | ( | std::vector< float > & | sizes | ) | const |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector.getDetectorScales( | ) -> | sizes |
Returns detector box filter sizes.
| sizes | output parameter for returning the sizes. |
| double cv::barcode::BarcodeDetector::getDownsamplingThreshold | ( | ) | const |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector.getDownsamplingThreshold( | ) -> | retval |
Get detector downsampling threshold.
| double cv::barcode::BarcodeDetector::getGradientThreshold | ( | ) | const |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector.getGradientThreshold( | ) -> | retval |
Get detector gradient magnitude threshold.
| BarcodeDetector & cv::barcode::BarcodeDetector::setDetectorScales | ( | const std::vector< float > & | sizes | ) |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector.setDetectorScales( | sizes | ) -> | retval |
Set detector box filter sizes.
Adjusts the value and the number of box filters used in the detect step. The filter sizes directly correlate with the expected line widths for a barcode. Corresponds to expected barcode distance. If the downsampling limit is increased, filter sizes need to be adjusted in an inversely proportional way.
| sizes | box filter sizes, relative to minimum dimension of the image (default [0.01, 0.03, 0.06, 0.08]) |
| BarcodeDetector & cv::barcode::BarcodeDetector::setDownsamplingThreshold | ( | double | thresh | ) |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector.setDownsamplingThreshold( | thresh | ) -> | retval |
Set detector downsampling threshold.
By default, the detect method resizes the input image to this limit if the smallest image size is is greater than the threshold. Increasing this value can improve detection accuracy and the number of results at the expense of performance. Correlates with detector scales. Setting this to a large value will disable downsampling.
| thresh | downsampling limit to apply (default 512) |
| BarcodeDetector & cv::barcode::BarcodeDetector::setGradientThreshold | ( | double | thresh | ) |
| Python: | ||||
|---|---|---|---|---|
| cv.barcode.BarcodeDetector.setGradientThreshold( | thresh | ) -> | retval |
Set detector gradient magnitude threshold.
Sets the coherence threshold for detected bounding boxes. Increasing this value will generate a closer fitted bounding box width and can reduce false-positives. Values between 16 and 1024 generally work, while too high of a value will remove valid detections.
| thresh | gradient magnitude threshold (default 64). |