1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +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
+5 -7
View File
@@ -175,8 +175,7 @@ int main(int argc, char **argv)
"{i in | | input image path (also switches to image detection mode) }"
"{detect | false | detect 1D barcode only (skip decoding) }"
"{o out | | path to result file (only for single image decode) }"
"{sr_prototxt| | super resolution prototxt path }"
"{sr_model | | super resolution model path }";
"{sr_model | | optional super resolution ONNX model path (e.g. sr.onnx) }";
CommandLineParser cmd_parser(argc, argv, keys);
cmd_parser.about("This program detects the 1D barcodes from camera or images using the OpenCV library.");
if (cmd_parser.has("help"))
@@ -186,7 +185,6 @@ int main(int argc, char **argv)
}
const string in_file = cmd_parser.get<string>("in");
const string out_file = cmd_parser.get<string>("out");
const string sr_prototxt = cmd_parser.get<string>("sr_prototxt");
const string sr_model = cmd_parser.get<string>("sr_model");
if (!cmd_parser.check())
{
@@ -199,17 +197,17 @@ int main(int argc, char **argv)
//! [initialize]
try
{
app.bardet = makePtr<barcode::BarcodeDetector>(sr_prototxt, sr_model);
app.bardet = makePtr<barcode::BarcodeDetector>(sr_model);
}
catch (const std::exception& e)
{
cout <<
"\n---------------------------------------------------------------\n"
"Failed to initialize super resolution.\n"
"Please, download 'sr.*' from\n"
"Please, download 'sr.onnx' from\n"
"https://github.com/WeChatCV/opencv_3rdparty/tree/wechat_qrcode\n"
"and put them into the current directory.\n"
"Or you can leave sr_prototxt and sr_model unspecified.\n"
"and put it into the current directory.\n"
"Or you can leave sr_model unspecified.\n"
"---------------------------------------------------------------\n";
cout << e.what() << endl;
return -1;