mirror of
https://github.com/opencv/opencv.git
synced 2025-07-25 22:57:53 +08:00
Merge pull request #23819 from asmorkalov:as/objdetect_no_dnn
Fixed barcode to be built without DNN
This commit is contained in:
commit
c0d4e16833
@ -8,11 +8,14 @@
|
|||||||
|
|
||||||
#include "../../precomp.hpp"
|
#include "../../precomp.hpp"
|
||||||
#include "super_scale.hpp"
|
#include "super_scale.hpp"
|
||||||
|
#include "opencv2/core.hpp"
|
||||||
#ifdef HAVE_OPENCV_DNN
|
#include "opencv2/core/utils/logger.hpp"
|
||||||
|
|
||||||
namespace cv {
|
namespace cv {
|
||||||
namespace barcode {
|
namespace barcode {
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_DNN
|
||||||
|
|
||||||
constexpr static float MAX_SCALE = 4.0f;
|
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 &proto_path, const std::string &model_path)
|
||||||
@ -71,7 +74,26 @@ int SuperScale::superResolutionScale(const Mat &src, Mat &dst)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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 barcode
|
||||||
} // namespace cv
|
} // namespace cv
|
||||||
|
|
||||||
#endif // HAVE_OPENCV_DNN
|
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#define OPENCV_BARCODE_SUPER_SCALE_HPP
|
#define OPENCV_BARCODE_SUPER_SCALE_HPP
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_DNN
|
#ifdef HAVE_OPENCV_DNN
|
||||||
|
# include "opencv2/dnn.hpp"
|
||||||
#include "opencv2/dnn.hpp"
|
#endif
|
||||||
|
|
||||||
namespace cv {
|
namespace cv {
|
||||||
namespace barcode {
|
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);
|
void processImageScale(const Mat &src, Mat &dst, float scale, const bool &use_sr, int sr_max_size = 160);
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCV_DNN
|
||||||
private:
|
private:
|
||||||
dnn::Net srnet_;
|
dnn::Net srnet_;
|
||||||
bool net_loaded_ = false;
|
bool net_loaded_ = false;
|
||||||
|
|
||||||
int superResolutionScale(const cv::Mat &src, cv::Mat &dst);
|
int superResolutionScale(const cv::Mat &src, cv::Mat &dst);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace barcode
|
} // namespace barcode
|
||||||
} // namespace cv
|
} // 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
|
|
||||||
|
|
||||||
#endif // OPENCV_BARCODE_SUPER_SCALE_HPP
|
#endif // OPENCV_BARCODE_SUPER_SCALE_HPP
|
||||||
|
Loading…
Reference in New Issue
Block a user