未验证 提交 c0d4e168 编写于 作者: A Alexander Smorkalov 提交者: GitHub

Merge pull request #23819 from asmorkalov:as/objdetect_no_dnn

Fixed barcode to be built without DNN
......@@ -8,11 +8,14 @@
#include "../../precomp.hpp"
#include "super_scale.hpp"
#ifdef HAVE_OPENCV_DNN
#include "opencv2/core.hpp"
#include "opencv2/core/utils/logger.hpp"
namespace cv {
namespace barcode {
#ifdef HAVE_OPENCV_DNN
constexpr static float MAX_SCALE = 4.0f;
int SuperScale::init(const std::string &proto_path, const std::string &model_path)
......@@ -71,7 +74,26 @@ int SuperScale::superResolutionScale(const Mat &src, Mat &dst)
}
return 0;
}
} // namespace barcode
} // namespace cv
#else // HAVE_OPENCV_DNN
int SuperScale::init(const std::string &proto_path, const std::string &model_path)
{
CV_UNUSED(proto_path);
CV_UNUSED(model_path);
return 0;
}
void SuperScale::processImageScale(const Mat &src, Mat &dst, float scale, const bool & isEnabled, int sr_max_size)
{
CV_UNUSED(sr_max_size);
if (isEnabled)
{
CV_LOG_WARNING(NULL, "objdetect/barcode: SuperScaling disabled - OpenCV has been built without DNN support");
}
resize(src, dst, Size(), scale, scale, INTER_CUBIC);
}
#endif // HAVE_OPENCV_DNN
} // namespace barcode
} // namespace cv
......@@ -9,8 +9,8 @@
#define OPENCV_BARCODE_SUPER_SCALE_HPP
#ifdef HAVE_OPENCV_DNN
#include "opencv2/dnn.hpp"
# include "opencv2/dnn.hpp"
#endif
namespace cv {
namespace barcode {
......@@ -26,44 +26,16 @@ public:
void processImageScale(const Mat &src, Mat &dst, float scale, const bool &use_sr, int sr_max_size = 160);
#ifdef HAVE_OPENCV_DNN
private:
dnn::Net srnet_;
bool net_loaded_ = false;
int superResolutionScale(const cv::Mat &src, cv::Mat &dst);
#endif
};
} // namespace barcode
} // namespace cv
#else // HAVE_OPENCV_DNN
#include "opencv2/core.hpp"
#include "opencv2/core/utils/logger.hpp"
namespace cv {
namespace barcode {
class SuperScale
{
public:
int init(const std::string &, const std::string &)
{
return 0;
}
void processImageScale(const Mat &src, Mat &dst, float scale, const bool & isEnabled, int)
{
if (isEnabled)
{
CV_LOG_WARNING(NULL, "objdetect/barcode: SuperScaling disabled - OpenCV has been built without DNN support");
}
resize(src, dst, Size(), scale, scale, INTER_CUBIC);
}
};
} // namespace barcode
} // namespace cv
#endif // !HAVE_OPENCV_DNN
} // namespace barcode
} // namespace cv
#endif // OPENCV_BARCODE_SUPER_SCALE_HPP
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册