1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #29227 from omrope79:object_detect_changes

Update BarcodeDetector super-resolution API to use single-file ONNX #29227

### Pull Request Readiness Checklist

This PR updates the `BarcodeDetector` super-resolution API to support and utilize a single-file ONNX model format. 

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.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
omrope79
2026-06-05 10:30:41 +05:30
committed by GitHub
parent 35ac66291f
commit ada32973b4
5 changed files with 48 additions and 22 deletions
+23
View File
@@ -227,4 +227,27 @@ TEST(BarcodeDetector_parameters, invalid)
EXPECT_ANY_THROW(bardet.setGradientThreshold(-0.1));
}
TEST(BarcodeDetector_super_resolution, accuracy)
{
// Reuse the existing WeChat Super Resolution ONNX model shipped in opencv_extra.
const string sr_path = findDataFile("dnn/wechat_2021-01/sr.onnx", false);
if (sr_path.empty())
throw SkipTestException("Missing super resolution model (dnn/wechat_2021-01/sr.onnx)");
const string fname = "single/book.jpg";
const string image_path = findDataFile("barcode/" + fname);
Mat img = imread(image_path);
ASSERT_FALSE(img.empty()) << "Can't read image: " << image_path;
// Construct with the ONNX super resolution model enabled.
barcode::BarcodeDetector det(sr_path);
vector<string> lines, types;
vector<Point2f> points;
bool res = det.detectAndDecodeWithType(img, lines, types, points);
ASSERT_TRUE(res);
EXPECT_EQ(toSet(testResults[fname].type), toSet(types));
EXPECT_EQ(toSet(testResults[fname].data), toSet(lines));
}
}} // opencv_test::<anonymous>::