mirror of
https://github.com/opencv/opencv.git
synced 2025-06-13 04:52:53 +08:00
Merge pull request #20250 from alalek:highgui_fixes
This commit is contained in:
commit
15ba3e123f
@ -281,5 +281,10 @@ ocv_target_link_libraries(${the_module} LINK_PRIVATE ${tgts})
|
|||||||
set(CONFIG_STR "// Auto-generated file
|
set(CONFIG_STR "// Auto-generated file
|
||||||
#define OPENCV_HIGHGUI_BUILTIN_BACKEND_STR \"${OPENCV_HIGHGUI_BUILTIN_BACKEND}\"
|
#define OPENCV_HIGHGUI_BUILTIN_BACKEND_STR \"${OPENCV_HIGHGUI_BUILTIN_BACKEND}\"
|
||||||
")
|
")
|
||||||
|
if(OPENCV_HIGHGUI_BUILTIN_BACKEND STREQUAL "NONE")
|
||||||
|
set(CONFIG_STR "${CONFIG_STR}
|
||||||
|
#define OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND 1
|
||||||
|
")
|
||||||
|
endif()
|
||||||
|
|
||||||
ocv_update_file("${CMAKE_CURRENT_BINARY_DIR}/opencv_highgui_config.hpp" "${CONFIG_STR}")
|
ocv_update_file("${CMAKE_CURRENT_BINARY_DIR}/opencv_highgui_config.hpp" "${CONFIG_STR}")
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
// 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.
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
#include "opencv_highgui_config.hpp" // generated by CMake
|
|
||||||
#include "backend.hpp"
|
#include "backend.hpp"
|
||||||
|
|
||||||
#include <opencv2/core/utils/configuration.private.hpp>
|
#include <opencv2/core/utils/configuration.private.hpp>
|
||||||
|
@ -232,8 +232,12 @@ std::vector<FileSystemPath_t> getPluginCandidates(const std::string& baseName)
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NB: require loading of imgcodecs module
|
||||||
|
static void* g_imwrite = (void*)imwrite;
|
||||||
|
|
||||||
void PluginUIBackendFactory::loadPlugin()
|
void PluginUIBackendFactory::loadPlugin()
|
||||||
{
|
{
|
||||||
|
CV_Assert(g_imwrite);
|
||||||
for (const FileSystemPath_t& plugin : getPluginCandidates(baseName_))
|
for (const FileSystemPath_t& plugin : getPluginCandidates(baseName_))
|
||||||
{
|
{
|
||||||
auto lib = std::make_shared<cv::plugin::impl::DynamicLib>(plugin);
|
auto lib = std::make_shared<cv::plugin::impl::DynamicLib>(plugin);
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "opencv2/highgui.hpp"
|
#include "opencv2/highgui.hpp"
|
||||||
|
#if !defined(BUILD_PLUGIN)
|
||||||
|
#include "opencv_highgui_config.hpp" // generated by CMake
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "opencv2/core/utility.hpp"
|
#include "opencv2/core/utility.hpp"
|
||||||
#if defined(__OPENCV_BUILD)
|
#if defined(__OPENCV_BUILD)
|
||||||
|
@ -162,7 +162,9 @@ public:
|
|||||||
const BackendInfo& info = enabledBackends[i];
|
const BackendInfo& info = enabledBackends[i];
|
||||||
os << info.name << '(' << info.priority << ')';
|
os << info.name << '(' << info.priority << ')';
|
||||||
}
|
}
|
||||||
|
#if !defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND)
|
||||||
os << " + BUILTIN(" OPENCV_HIGHGUI_BUILTIN_BACKEND_STR ")";
|
os << " + BUILTIN(" OPENCV_HIGHGUI_BUILTIN_BACKEND_STR ")";
|
||||||
|
#endif
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +179,14 @@ static void cleanupTrackbarCallbacksWithData_()
|
|||||||
|
|
||||||
using namespace cv::impl;
|
using namespace cv::impl;
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
static void deprecateNotFoundNoOpBehavior()
|
||||||
|
{
|
||||||
|
CV_LOG_ONCE_WARNING(NULL, "This no-op behavior is deprecated. Future versions of OpenCV will trigger exception in this case");
|
||||||
|
}
|
||||||
|
#define CV_NOT_FOUND_DEPRECATION deprecateNotFoundNoOpBehavior()
|
||||||
|
#endif
|
||||||
|
|
||||||
CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_value)
|
CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_value)
|
||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
@ -193,6 +201,19 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << name << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#else
|
||||||
switch(prop_id)
|
switch(prop_id)
|
||||||
{
|
{
|
||||||
//change between fullscreen or not.
|
//change between fullscreen or not.
|
||||||
@ -249,6 +270,7 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
|
|||||||
|
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return -1 if error */
|
/* return -1 if error */
|
||||||
@ -268,6 +290,19 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << name << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
switch(prop_id)
|
switch(prop_id)
|
||||||
{
|
{
|
||||||
case CV_WND_PROP_FULLSCREEN:
|
case CV_WND_PROP_FULLSCREEN:
|
||||||
@ -361,13 +396,13 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
|
|||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::Rect cvGetWindowImageRect(const char* name)
|
cv::Rect cvGetWindowImageRect(const char* name)
|
||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
if (!name)
|
CV_Assert(name);
|
||||||
return cv::Rect(-1, -1, -1, -1);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto window = findWindow_(name);
|
auto window = findWindow_(name);
|
||||||
@ -377,6 +412,20 @@ cv::Rect cvGetWindowImageRect(const char* name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << name << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return Rect(-1, -1, -1, -1);
|
||||||
|
#else
|
||||||
|
|
||||||
#if defined (HAVE_QT)
|
#if defined (HAVE_QT)
|
||||||
return cvGetWindowRect_QT(name);
|
return cvGetWindowRect_QT(name);
|
||||||
#elif defined(HAVE_WIN32UI)
|
#elif defined(HAVE_WIN32UI)
|
||||||
@ -386,8 +435,10 @@ cv::Rect cvGetWindowImageRect(const char* name)
|
|||||||
#elif defined (HAVE_COCOA)
|
#elif defined (HAVE_COCOA)
|
||||||
return cvGetWindowRect_COCOA(name);
|
return cvGetWindowRect_COCOA(name);
|
||||||
#else
|
#else
|
||||||
return cv::Rect(-1, -1, -1, -1);
|
return Rect(-1, -1, -1, -1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::Rect cv::getWindowImageRect(const String& winname)
|
cv::Rect cv::getWindowImageRect(const String& winname)
|
||||||
@ -483,7 +534,21 @@ void cv::resizeWindow( const String& winname, int width, int height )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << winname << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#else
|
||||||
cvResizeWindow( winname.c_str(), width, height );
|
cvResizeWindow( winname.c_str(), width, height );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::resizeWindow(const String& winname, const cv::Size& size)
|
void cv::resizeWindow(const String& winname, const cv::Size& size)
|
||||||
@ -504,7 +569,21 @@ void cv::moveWindow( const String& winname, int x, int y )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << winname << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#else
|
||||||
cvMoveWindow( winname.c_str(), x, y );
|
cvMoveWindow( winname.c_str(), x, y );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::setWindowProperty(const String& winname, int prop_id, double prop_value)
|
void cv::setWindowProperty(const String& winname, int prop_id, double prop_value)
|
||||||
@ -616,8 +695,22 @@ int cv::createTrackbar(const String& trackbarName, const String& winName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << winName << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
return cvCreateTrackbar2(trackbarName.c_str(), winName.c_str(),
|
return cvCreateTrackbar2(trackbarName.c_str(), winName.c_str(),
|
||||||
value, count, callback, userdata);
|
value, count, callback, userdata);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::setTrackbarPos( const String& trackbarName, const String& winName, int value )
|
void cv::setTrackbarPos( const String& trackbarName, const String& winName, int value )
|
||||||
@ -635,7 +728,21 @@ void cv::setTrackbarPos( const String& trackbarName, const String& winName, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << winName << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#else
|
||||||
cvSetTrackbarPos(trackbarName.c_str(), winName.c_str(), value );
|
cvSetTrackbarPos(trackbarName.c_str(), winName.c_str(), value );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::setTrackbarMax(const String& trackbarName, const String& winName, int maxval)
|
void cv::setTrackbarMax(const String& trackbarName, const String& winName, int maxval)
|
||||||
@ -655,7 +762,21 @@ void cv::setTrackbarMax(const String& trackbarName, const String& winName, int m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << winName << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#else
|
||||||
cvSetTrackbarMax(trackbarName.c_str(), winName.c_str(), maxval);
|
cvSetTrackbarMax(trackbarName.c_str(), winName.c_str(), maxval);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::setTrackbarMin(const String& trackbarName, const String& winName, int minval)
|
void cv::setTrackbarMin(const String& trackbarName, const String& winName, int minval)
|
||||||
@ -675,7 +796,21 @@ void cv::setTrackbarMin(const String& trackbarName, const String& winName, int m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << winName << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#else
|
||||||
cvSetTrackbarMin(trackbarName.c_str(), winName.c_str(), minval);
|
cvSetTrackbarMin(trackbarName.c_str(), winName.c_str(), minval);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int cv::getTrackbarPos( const String& trackbarName, const String& winName )
|
int cv::getTrackbarPos( const String& trackbarName, const String& winName )
|
||||||
@ -693,7 +828,21 @@ int cv::getTrackbarPos( const String& trackbarName, const String& winName )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << winName << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str());
|
return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::setMouseCallback( const String& windowName, MouseCallback onMouse, void* param)
|
void cv::setMouseCallback( const String& windowName, MouseCallback onMouse, void* param)
|
||||||
@ -709,7 +858,21 @@ void cv::setMouseCallback( const String& windowName, MouseCallback onMouse, void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << windowName << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#else
|
||||||
cvSetMouseCallback(windowName.c_str(), onMouse, param);
|
cvSetMouseCallback(windowName.c_str(), onMouse, param);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int cv::getMouseWheelDelta( int flags )
|
int cv::getMouseWheelDelta( int flags )
|
||||||
|
@ -2331,6 +2331,11 @@ public:
|
|||||||
class GTKBackendUI : public UIBackend
|
class GTKBackendUI : public UIBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
GTKBackendUI()
|
||||||
|
{
|
||||||
|
// NB: avoid static initialization order fiasco
|
||||||
|
(void)getGTKWindows();
|
||||||
|
}
|
||||||
~GTKBackendUI() CV_OVERRIDE
|
~GTKBackendUI() CV_OVERRIDE
|
||||||
{
|
{
|
||||||
destroyAllWindows();
|
destroyAllWindows();
|
||||||
|
Loading…
Reference in New Issue
Block a user