File size: 3,676 Bytes
dffe123 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | // 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;
virtual const std::string getName() const = 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
#ifdef HAVE_FRAMEBUFFER
std::shared_ptr<UIBackend> createUIBackendFramebuffer();
#endif
#endif // BUILD_PLUGIN
} // namespace highgui_backend
} // namespace cv
#endif // OPENCV_HIGHGUI_BACKEND_HPP
|