1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #24903 from cristidbr-adapta:feature-barcode-detector-parameters

Feature barcode detector parameters #24903

Attempt to solve #24902 without changing the default detector behaviour. 
Megre with extra: https://github.com/opencv/opencv_extra/pull/1150

**Introduces new parameters and methods to `cv::barcode::BarcodeDetector`**.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Cristian Dobre
2024-05-20 09:53:22 +03:00
committed by GitHub
parent 6350bfbf79
commit e05ad56f6e
5 changed files with 222 additions and 18 deletions
@@ -57,6 +57,52 @@ public:
CV_OUT std::vector<std::string> &decoded_info,
CV_OUT std::vector<std::string> &decoded_type,
OutputArray points = noArray()) const;
/** @brief Get detector downsampling threshold.
*
* @return detector downsampling threshold
*/
CV_WRAP double getDownsamplingThreshold() const;
/** @brief 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.
* @param thresh downsampling limit to apply (default 512)
* @see setDetectorScales
*/
CV_WRAP BarcodeDetector& setDownsamplingThreshold(double thresh);
/** @brief Returns detector box filter sizes.
*
* @param sizes output parameter for returning the sizes.
*/
CV_WRAP void getDetectorScales(CV_OUT std::vector<float>& sizes) const;
/** @brief 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.
* @param sizes box filter sizes, relative to minimum dimension of the image (default [0.01, 0.03, 0.06, 0.08])
*/
CV_WRAP BarcodeDetector& setDetectorScales(const std::vector<float>& sizes);
/** @brief Get detector gradient magnitude threshold.
*
* @return detector gradient magnitude threshold.
*/
CV_WRAP double getGradientThreshold() const;
/** @brief 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.
* @param thresh gradient magnitude threshold (default 64).
*/
CV_WRAP BarcodeDetector& setGradientThreshold(double thresh);
};
//! @}