highgui: force loading of imgcodecs module
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Wed, 9 Jun 2021 08:34:58 +0000 (08:34 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Wed, 9 Jun 2021 08:36:28 +0000 (08:36 +0000)
- required for plugins on Linux (they use imwrite, but there is no link dependency)

modules/highgui/src/plugin_wrapper.impl.hpp

index 3fa2cfa11a778fdbed313e92b9fca6c282aa6092..97aea69098cbc0900af659944e6a421039150be4 100644 (file)
@@ -232,8 +232,12 @@ std::vector<FileSystemPath_t> getPluginCandidates(const std::string& baseName)
     return results;
 }
 
+// NB: require loading of imgcodecs module
+static void* g_imwrite = (void*)imwrite;
+
 void PluginUIBackendFactory::loadPlugin()
 {
+    CV_Assert(g_imwrite);
     for (const FileSystemPath_t& plugin : getPluginCandidates(baseName_))
     {
         auto lib = std::make_shared<cv::plugin::impl::DynamicLib>(plugin);