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

Merge pull request #28678 from omrope79:caffe-importer-cleanup

Caffe importer cleanup #28678

Merge with: https://github.com/opencv/opencv_extra/pull/1324

### 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
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
omrope79
2026-06-02 19:58:10 +05:30
committed by GitHub
parent 42fc6939f8
commit b67ad9a422
34 changed files with 327 additions and 5674 deletions
+5 -3
View File
@@ -348,11 +348,13 @@ BarcodeDetector::BarcodeDetector(const string &prototxt_path, const string &mode
Ptr<BarcodeImpl> p_ = new BarcodeImpl();
p = p_;
p_->sr = make_shared<SuperScale>();
if (!prototxt_path.empty() && !model_path.empty())
// The Super Resolution model is now a single-file ONNX network; the legacy Caffe
// prototxt argument is retained for API compatibility but is no longer used.
CV_UNUSED(prototxt_path);
if (!model_path.empty())
{
CV_Assert(utils::fs::exists(prototxt_path));
CV_Assert(utils::fs::exists(model_path));
int res = p_->sr->init(prototxt_path, model_path);
int res = p_->sr->init(model_path);
CV_Assert(res == 0);
p_->use_nn_sr = true;
}
@@ -18,9 +18,10 @@ namespace barcode {
constexpr static float MAX_SCALE = 4.0f;
int SuperScale::init(const std::string &proto_path, const std::string &model_path)
int SuperScale::init(const std::string &model_path)
{
srnet_ = dnn::readNetFromCaffe(proto_path, model_path);
// Super Resolution is loaded from a single-file ONNX model (e.g. dnn/wechat_2021-01/sr.onnx).
srnet_ = dnn::readNetFromONNX(model_path);
net_loaded_ = true;
return 0;
}
@@ -77,9 +78,8 @@ int SuperScale::superResolutionScale(const Mat &src, Mat &dst)
#else // HAVE_OPENCV_DNN
int SuperScale::init(const std::string &proto_path, const std::string &model_path)
int SuperScale::init(const std::string &model_path)
{
CV_UNUSED(proto_path);
CV_UNUSED(model_path);
return 0;
}
@@ -22,7 +22,7 @@ public:
~SuperScale() = default;
int init(const std::string &proto_path, const std::string &model_path);
int init(const std::string &model_path);
void processImageScale(const Mat &src, Mat &dst, float scale, const bool &use_sr, int sr_max_size = 160);