mirror of
https://github.com/opencv/opencv.git
synced 2026-12-05 22:45:01 -06:00
Merge pull request #19934 from alalek:videoio_plugin_query_api
This commit is contained in:
@@ -210,6 +210,24 @@ public:
|
||||
Ptr<IVideoCapture> createCapture(const std::string &filename, const VideoCaptureParameters& params) const CV_OVERRIDE;
|
||||
Ptr<IVideoWriter> createWriter(const std::string& filename, int fourcc, double fps,
|
||||
const cv::Size& sz, const VideoWriterParameters& params) const CV_OVERRIDE;
|
||||
|
||||
std::string getCapturePluginVersion(CV_OUT int& version_ABI, CV_OUT int& version_API)
|
||||
{
|
||||
CV_Assert(capture_api_ || plugin_api_);
|
||||
const OpenCV_API_Header& api_header = capture_api_ ? capture_api_->api_header : plugin_api_->api_header;
|
||||
version_ABI = api_header.min_api_version;
|
||||
version_API = api_header.api_version;
|
||||
return api_header.api_description;
|
||||
}
|
||||
|
||||
std::string getWriterPluginVersion(CV_OUT int& version_ABI, CV_OUT int& version_API)
|
||||
{
|
||||
CV_Assert(writer_api_ || plugin_api_);
|
||||
const OpenCV_API_Header& api_header = writer_api_ ? writer_api_->api_header : plugin_api_->api_header;
|
||||
version_ABI = api_header.min_api_version;
|
||||
version_API = api_header.api_version;
|
||||
return api_header.api_description;
|
||||
}
|
||||
};
|
||||
|
||||
class PluginBackendFactory : public IBackendFactory
|
||||
@@ -229,14 +247,41 @@ public:
|
||||
|
||||
Ptr<IBackend> getBackend() const CV_OVERRIDE
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
const_cast<PluginBackendFactory*>(this)->initBackend();
|
||||
}
|
||||
initBackend();
|
||||
return backend.staticCast<IBackend>();
|
||||
}
|
||||
|
||||
bool isBuiltIn() const CV_OVERRIDE { return false; }
|
||||
|
||||
std::string getCapturePluginVersion(
|
||||
CV_OUT int& version_ABI,
|
||||
CV_OUT int& version_API) const
|
||||
{
|
||||
initBackend();
|
||||
if (!backend)
|
||||
CV_Error_(Error::StsNotImplemented, ("Backend '%s' is not available", baseName_));
|
||||
return backend->getCapturePluginVersion(version_ABI, version_API);
|
||||
}
|
||||
|
||||
std::string getWriterPluginVersion(
|
||||
CV_OUT int& version_ABI,
|
||||
CV_OUT int& version_API) const
|
||||
{
|
||||
initBackend();
|
||||
if (!backend)
|
||||
CV_Error_(Error::StsNotImplemented, ("Backend '%s' is not available", baseName_));
|
||||
return backend->getWriterPluginVersion(version_ABI, version_API);
|
||||
}
|
||||
|
||||
protected:
|
||||
void initBackend()
|
||||
inline void initBackend() const
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
const_cast<PluginBackendFactory*>(this)->initBackend_();
|
||||
}
|
||||
}
|
||||
void initBackend_()
|
||||
{
|
||||
AutoLock lock(getInitializationMutex());
|
||||
try {
|
||||
@@ -690,4 +735,43 @@ Ptr<IBackendFactory> createPluginBackendFactory(VideoCaptureAPIs id, const char*
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
std::string getCapturePluginVersion(
|
||||
const Ptr<IBackendFactory>& backend_factory,
|
||||
CV_OUT int& version_ABI,
|
||||
CV_OUT int& version_API
|
||||
)
|
||||
{
|
||||
#if OPENCV_HAVE_FILESYSTEM_SUPPORT && defined(ENABLE_PLUGINS)
|
||||
using namespace impl;
|
||||
CV_Assert(backend_factory);
|
||||
PluginBackendFactory* plugin_backend_factory = dynamic_cast<PluginBackendFactory*>(backend_factory.get());
|
||||
CV_Assert(plugin_backend_factory);
|
||||
return plugin_backend_factory->getCapturePluginVersion(version_ABI, version_API);
|
||||
#else
|
||||
CV_UNUSED(version_ABI);
|
||||
CV_UNUSED(version_API);
|
||||
CV_Error(Error::StsBadFunc, "Plugins are not available in this build");
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string getWriterPluginVersion(
|
||||
const Ptr<IBackendFactory>& backend_factory,
|
||||
CV_OUT int& version_ABI,
|
||||
CV_OUT int& version_API
|
||||
)
|
||||
{
|
||||
#if OPENCV_HAVE_FILESYSTEM_SUPPORT && defined(ENABLE_PLUGINS)
|
||||
using namespace impl;
|
||||
CV_Assert(backend_factory);
|
||||
PluginBackendFactory* plugin_backend_factory = dynamic_cast<PluginBackendFactory*>(backend_factory.get());
|
||||
CV_Assert(plugin_backend_factory);
|
||||
return plugin_backend_factory->getWriterPluginVersion(version_ABI, version_API);
|
||||
#else
|
||||
CV_UNUSED(version_ABI);
|
||||
CV_UNUSED(version_API);
|
||||
CV_Error(Error::StsBadFunc, "Plugins are not available in this build");
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user