opencv/modules/objdetect/src/barcode_detector/bardetect.hpp
Cristian Dobre e05ad56f6e
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
2024-05-20 09:53:22 +03:00

63 lines
1.5 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_BARDETECT_HPP
#define OPENCV_BARCODE_BARDETECT_HPP
#include <opencv2/core.hpp>
namespace cv {
namespace barcode {
using std::vector;
class Detect
{
private:
vector<RotatedRect> localization_rects;
vector<RotatedRect> localization_bbox;
vector<float> bbox_scores;
vector<int> bbox_indices;
vector<vector<Point2f>> transformation_points;
public:
void init(const Mat &src, double detectorThreshDownSamplingLimit);
void localization(const vector<float>& detectorWindowSizes, double detectorGradientMagnitudeThresh);
vector<vector<Point2f>> getTransformationPoints()
{ return transformation_points; }
bool computeTransformationPoints();
protected:
enum resize_direction
{
ZOOMING, SHRINKING, UNCHANGED
} purpose = UNCHANGED;
double coeff_expansion = 1.0;
int height, width;
Mat resized_barcode, gradient_magnitude, coherence, orientation, edge_nums, integral_x_sq, integral_y_sq, integral_xy, integral_edges;
void preprocess(double detectorThreshGradientMagnitude);
void calCoherence(int window_size);
static inline bool isValidCoord(const Point &coord, const Size &limit);
void regionGrowing(int window_size);
void barcodeErode();
};
}
}
#endif // OPENCV_BARCODE_BARDETECT_HPP