feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake

1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试
2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程
3.重整权利声明文件,重整代码工程,确保最小化侵权风险

Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake
Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
wangzhengyang
2022-05-10 09:54:44 +08:00
parent ecdd171c6f
commit 718c41634f
10018 changed files with 3593797 additions and 186748 deletions

View File

@ -0,0 +1,181 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "precomp.hpp"
#include "backend.hpp"
#include <opencv2/core/utils/configuration.private.hpp>
#include <opencv2/core/utils/logger.defines.hpp>
#ifdef NDEBUG
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG + 1
#else
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
#endif
#include <opencv2/core/utils/logger.hpp>
#include "registry.hpp"
#include "registry.impl.hpp"
#include "plugin_api.hpp"
#include "plugin_wrapper.impl.hpp"
namespace cv { namespace highgui_backend {
UIBackend::~UIBackend()
{
// nothing
}
UIWindowBase::~UIWindowBase()
{
// nothing
}
UIWindow::~UIWindow()
{
// nothing
}
UITrackbar::~UITrackbar()
{
// nothing
}
static
std::string& getUIBackendName()
{
static std::string g_backendName = toUpperCase(cv::utils::getConfigurationParameterString("OPENCV_UI_BACKEND", ""));
return g_backendName;
}
static bool g_initializedUIBackend = false;
static
std::shared_ptr<UIBackend> createUIBackend()
{
const std::string& name = getUIBackendName();
bool isKnown = false;
const auto& backends = getBackendsInfo();
if (!name.empty())
{
CV_LOG_INFO(NULL, "UI: requested backend name: " << name);
}
for (size_t i = 0; i < backends.size(); i++)
{
const auto& info = backends[i];
if (!name.empty())
{
if (name != info.name)
{
continue;
}
isKnown = true;
}
try
{
CV_LOG_DEBUG(NULL, "UI: trying backend: " << info.name << " (priority=" << info.priority << ")");
if (!info.backendFactory)
{
CV_LOG_DEBUG(NULL, "UI: factory is not available (plugins require filesystem support): " << info.name);
continue;
}
std::shared_ptr<UIBackend> backend = info.backendFactory->create();
if (!backend)
{
CV_LOG_VERBOSE(NULL, 0, "UI: not available: " << info.name);
continue;
}
CV_LOG_INFO(NULL, "UI: using backend: " << info.name << " (priority=" << info.priority << ")");
g_initializedUIBackend = true;
getUIBackendName() = info.name;
return backend;
}
catch (const std::exception& e)
{
CV_LOG_WARNING(NULL, "UI: can't initialize " << info.name << " backend: " << e.what());
}
catch (...)
{
CV_LOG_WARNING(NULL, "UI: can't initialize " << info.name << " backend: Unknown C++ exception");
}
}
if (name.empty())
{
CV_LOG_DEBUG(NULL, "UI: fallback on builtin code: " OPENCV_HIGHGUI_BUILTIN_BACKEND_STR);
}
else
{
if (!isKnown)
CV_LOG_INFO(NULL, "UI: unknown backend: " << name);
}
g_initializedUIBackend = true;
return std::shared_ptr<UIBackend>();
}
static inline
std::shared_ptr<UIBackend> createDefaultUIBackend()
{
CV_LOG_DEBUG(NULL, "UI: Initializing backend...");
return createUIBackend();
}
std::shared_ptr<UIBackend>& getCurrentUIBackend()
{
static std::shared_ptr<UIBackend> g_currentUIBackend = createDefaultUIBackend();
return g_currentUIBackend;
}
void setUIBackend(const std::shared_ptr<UIBackend>& api)
{
getCurrentUIBackend() = api;
}
bool setUIBackend(const std::string& backendName)
{
CV_TRACE_FUNCTION();
std::string backendName_u = toUpperCase(backendName);
if (g_initializedUIBackend)
{
// ... already initialized
if (getUIBackendName() == backendName_u)
{
CV_LOG_INFO(NULL, "UI: backend is already activated: " << (backendName.empty() ? "builtin(legacy)" : backendName));
return true;
}
else
{
// ... re-create new
CV_LOG_DEBUG(NULL, "UI: replacing backend...");
getUIBackendName() = backendName_u;
getCurrentUIBackend() = createUIBackend();
}
}
else
{
// ... no backend exists, just specify the name (initialization is triggered by getCurrentUIBackend() call)
getUIBackendName() = backendName_u;
}
std::shared_ptr<UIBackend> api = getCurrentUIBackend();
if (!api)
{
if (!backendName.empty())
{
CV_LOG_WARNING(NULL, "UI: backend is not available: " << backendName << " (using builtin legacy code)");
return false;
}
else
{
CV_LOG_WARNING(NULL, "UI: switched to builtin code (legacy)");
}
}
if (!backendName_u.empty())
{
CV_Assert(backendName_u == getUIBackendName()); // data race?
}
return true;
}
}} // namespace cv::highgui_backend

View File

@ -0,0 +1,135 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_HIGHGUI_BACKEND_HPP
#define OPENCV_HIGHGUI_BACKEND_HPP
#include <memory>
#include <map>
namespace cv { namespace highgui_backend {
class CV_EXPORTS UIWindowBase
{
public:
typedef std::shared_ptr<UIWindowBase> Ptr;
typedef std::weak_ptr<UIWindowBase> WeakPtr;
virtual ~UIWindowBase();
virtual const std::string& getID() const = 0; // internal name, used for logging
virtual bool isActive() const = 0;
virtual void destroy() = 0;
}; // UIWindowBase
class UITrackbar;
class CV_EXPORTS UIWindow : public UIWindowBase
{
public:
virtual ~UIWindow();
virtual void imshow(InputArray image) = 0;
virtual double getProperty(int prop) const = 0;
virtual bool setProperty(int prop, double value) = 0;
virtual void resize(int width, int height) = 0;
virtual void move(int x, int y) = 0;
virtual Rect getImageRect() const = 0;
virtual void setTitle(const std::string& title) = 0;
virtual void setMouseCallback(MouseCallback onMouse, void* userdata /*= 0*/) = 0;
//TODO: handle both keys and mouse events (both with mouse coordinates)
//virtual void setInputCallback(InputCallback onInputEvent, void* userdata /*= 0*/) = 0;
virtual std::shared_ptr<UITrackbar> createTrackbar(
const std::string& name,
int count,
TrackbarCallback onChange /*= 0*/,
void* userdata /*= 0*/
) = 0;
virtual std::shared_ptr<UITrackbar> findTrackbar(const std::string& name) = 0;
#if 0 // QT only
virtual void displayOverlay(const std::string& text, int delayms = 0) = 0;
virtual void displayStatusBar(const std::string& text, int delayms /*= 0*/) = 0;
virtual int createButton(
const std::string& bar_name, ButtonCallback on_change,
void* userdata = 0, int type /*= QT_PUSH_BUTTON*/,
bool initial_button_state /*= false*/
) = 0;
// addText, QtFont stuff
#endif
#if 0 // OpenGL
virtual void imshow(const ogl::Texture2D& tex) = 0;
virtual void setOpenGlDrawCallback(OpenGlDrawCallback onOpenGlDraw, void* userdata = 0) = 0;
virtual void setOpenGlContext() = 0;
virtual void updateWindow() = 0;
#endif
}; // UIWindow
class CV_EXPORTS UITrackbar : public UIWindowBase
{
public:
virtual ~UITrackbar();
virtual int getPos() const = 0;
virtual void setPos(int pos) = 0;
virtual cv::Range getRange() const = 0;
virtual void setRange(const cv::Range& range) = 0;
}; // UITrackbar
class CV_EXPORTS UIBackend
{
public:
virtual ~UIBackend();
virtual void destroyAllWindows() = 0;
// namedWindow
virtual std::shared_ptr<UIWindow> createWindow(
const std::string& winname,
int flags
) = 0;
virtual int waitKeyEx(int delay /*= 0*/) = 0;
virtual int pollKey() = 0;
};
std::shared_ptr<UIBackend>& getCurrentUIBackend();
void setUIBackend(const std::shared_ptr<UIBackend>& api);
bool setUIBackend(const std::string& backendName);
#ifndef BUILD_PLUGIN
#ifdef HAVE_WIN32UI
std::shared_ptr<UIBackend> createUIBackendWin32UI();
#endif
#ifdef HAVE_GTK
std::shared_ptr<UIBackend> createUIBackendGTK();
#endif
#if 0 // TODO: defined HAVE_QT
std::shared_ptr<UIBackend> createUIBackendQT();
#endif
#endif // BUILD_PLUGIN
} // namespace highgui_backend
} // namespace cv
#endif // OPENCV_HIGHGUI_BACKEND_HPP

View File

@ -0,0 +1,48 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_UI_FACTORY_HPP
#define OPENCV_UI_FACTORY_HPP
#include "backend.hpp"
namespace cv { namespace highgui_backend {
class IUIBackendFactory
{
public:
virtual ~IUIBackendFactory() {}
virtual std::shared_ptr<cv::highgui_backend::UIBackend> create() const = 0;
};
class StaticBackendFactory CV_FINAL: public IUIBackendFactory
{
protected:
std::function<std::shared_ptr<cv::highgui_backend::UIBackend>(void)> create_fn_;
public:
StaticBackendFactory(std::function<std::shared_ptr<cv::highgui_backend::UIBackend>(void)>&& create_fn)
: create_fn_(create_fn)
{
// nothing
}
~StaticBackendFactory() CV_OVERRIDE {}
std::shared_ptr<cv::highgui_backend::UIBackend> create() const CV_OVERRIDE
{
return create_fn_();
}
};
//
// PluginUIBackendFactory is implemented in plugin_wrapper
//
std::shared_ptr<IUIBackendFactory> createPluginUIBackendFactory(const std::string& baseName);
}} // namespace
#endif // OPENCV_UI_FACTORY_HPP

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Some files were not shown because too many files have changed in this diff Show More