return;
}
#ifdef HAVE_FFMPEG_WRAPPER
- if (plugin_api_->captureAPI == CAP_FFMPEG)
+ if (plugin_api_->v0.captureAPI == CAP_FFMPEG)
{
// no checks for OpenCV minor version
}
Ptr<PluginBackend> pluginBackend = makePtr<PluginBackend>(lib);
if (pluginBackend && pluginBackend->plugin_api_)
{
- if (pluginBackend->plugin_api_->captureAPI != id_)
+ if (pluginBackend->plugin_api_->v0.captureAPI != id_)
{
CV_LOG_ERROR(NULL, "Video I/O: plugin '" << pluginBackend->plugin_api_->api_header.api_description <<
"': unexpected backend ID: " <<
- pluginBackend->plugin_api_->captureAPI << " vs " << (int)id_ << " (expected)");
+ pluginBackend->plugin_api_->v0.captureAPI << " vs " << (int)id_ << " (expected)");
}
else
{
{
CV_Assert(plugin_api);
CvPluginCapture capture = NULL;
- if (plugin_api->Capture_open)
+ if (plugin_api->v0.Capture_open)
{
- CV_Assert(plugin_api->Capture_release);
- if (CV_ERROR_OK == plugin_api->Capture_open(filename.empty() ? 0 : filename.c_str(), camera, &capture))
+ CV_Assert(plugin_api->v0.Capture_release);
+ if (CV_ERROR_OK == plugin_api->v0.Capture_open(filename.empty() ? 0 : filename.c_str(), camera, &capture))
{
CV_Assert(capture);
return makePtr<PluginCapture>(plugin_api, capture);
~PluginCapture()
{
- CV_DbgAssert(plugin_api_->Capture_release);
- if (CV_ERROR_OK != plugin_api_->Capture_release(capture_))
+ CV_DbgAssert(plugin_api_->v0.Capture_release);
+ if (CV_ERROR_OK != plugin_api_->v0.Capture_release(capture_))
CV_LOG_ERROR(NULL, "Video I/O: Can't release capture by plugin '" << plugin_api_->api_header.api_description << "'");
capture_ = NULL;
}
double getProperty(int prop) const CV_OVERRIDE
{
double val = -1;
- if (plugin_api_->Capture_getProperty)
- if (CV_ERROR_OK != plugin_api_->Capture_getProperty(capture_, prop, &val))
+ if (plugin_api_->v0.Capture_getProperty)
+ if (CV_ERROR_OK != plugin_api_->v0.Capture_getProperty(capture_, prop, &val))
val = -1;
return val;
}
bool setProperty(int prop, double val) CV_OVERRIDE
{
- if (plugin_api_->Capture_setProperty)
- if (CV_ERROR_OK == plugin_api_->Capture_setProperty(capture_, prop, val))
+ if (plugin_api_->v0.Capture_setProperty)
+ if (CV_ERROR_OK == plugin_api_->v0.Capture_setProperty(capture_, prop, val))
return true;
return false;
}
bool grabFrame() CV_OVERRIDE
{
- if (plugin_api_->Capture_grab)
- if (CV_ERROR_OK == plugin_api_->Capture_grab(capture_))
+ if (plugin_api_->v0.Capture_grab)
+ if (CV_ERROR_OK == plugin_api_->v0.Capture_grab(capture_))
return true;
return false;
}
bool retrieveFrame(int idx, cv::OutputArray img) CV_OVERRIDE
{
bool res = false;
- if (plugin_api_->Capture_retreive)
- if (CV_ERROR_OK == plugin_api_->Capture_retreive(capture_, idx, retrieve_callback, (cv::_OutputArray*)&img))
+ if (plugin_api_->v0.Capture_retreive)
+ if (CV_ERROR_OK == plugin_api_->v0.Capture_retreive(capture_, idx, retrieve_callback, (cv::_OutputArray*)&img))
res = true;
return res;
}
}
int getCaptureDomain() CV_OVERRIDE
{
- return plugin_api_->captureAPI;
+ return plugin_api_->v0.captureAPI;
}
};
{
CV_Assert(plugin_api);
CvPluginWriter writer = NULL;
- if (plugin_api->api_header.api_version >= 1 && plugin_api->Writer_open_with_params)
+ if (plugin_api->api_header.api_version >= 1 && plugin_api->v1.Writer_open_with_params)
{
- CV_Assert(plugin_api->Writer_release);
+ CV_Assert(plugin_api->v0.Writer_release);
CV_Assert(!filename.empty());
std::vector<int> vint_params = params.getIntVector();
int* c_params = &vint_params[0];
unsigned n_params = (unsigned)(vint_params.size() / 2);
- if (CV_ERROR_OK == plugin_api->Writer_open_with_params(filename.c_str(), fourcc, fps, sz.width, sz.height, c_params, n_params, &writer))
+ if (CV_ERROR_OK == plugin_api->v1.Writer_open_with_params(filename.c_str(), fourcc, fps, sz.width, sz.height, c_params, n_params, &writer))
{
CV_Assert(writer);
return makePtr<PluginWriter>(plugin_api, writer);
}
}
- else if (plugin_api->Writer_open)
+ else if (plugin_api->v0.Writer_open)
{
- CV_Assert(plugin_api->Writer_release);
+ CV_Assert(plugin_api->v0.Writer_release);
CV_Assert(!filename.empty());
const bool isColor = params.get(VIDEOWRITER_PROP_IS_COLOR, true);
const int depth = params.get(VIDEOWRITER_PROP_DEPTH, CV_8U);
CV_LOG_WARNING(NULL, "Video I/O plugin doesn't support (due to lower API level) creation of VideoWriter with depth != CV_8U");
return Ptr<PluginWriter>();
}
- if (CV_ERROR_OK == plugin_api->Writer_open(filename.c_str(), fourcc, fps, sz.width, sz.height, isColor, &writer))
+ if (CV_ERROR_OK == plugin_api->v0.Writer_open(filename.c_str(), fourcc, fps, sz.width, sz.height, isColor, &writer))
{
CV_Assert(writer);
return makePtr<PluginWriter>(plugin_api, writer);
~PluginWriter()
{
- CV_DbgAssert(plugin_api_->Writer_release);
- if (CV_ERROR_OK != plugin_api_->Writer_release(writer_))
+ CV_DbgAssert(plugin_api_->v0.Writer_release);
+ if (CV_ERROR_OK != plugin_api_->v0.Writer_release(writer_))
CV_LOG_ERROR(NULL, "Video I/O: Can't release writer by plugin '" << plugin_api_->api_header.api_description << "'");
writer_ = NULL;
}
double getProperty(int prop) const CV_OVERRIDE
{
double val = -1;
- if (plugin_api_->Writer_getProperty)
- if (CV_ERROR_OK != plugin_api_->Writer_getProperty(writer_, prop, &val))
+ if (plugin_api_->v0.Writer_getProperty)
+ if (CV_ERROR_OK != plugin_api_->v0.Writer_getProperty(writer_, prop, &val))
val = -1;
return val;
}
bool setProperty(int prop, double val) CV_OVERRIDE
{
- if (plugin_api_->Writer_setProperty)
- if (CV_ERROR_OK == plugin_api_->Writer_setProperty(writer_, prop, val))
+ if (plugin_api_->v0.Writer_setProperty)
+ if (CV_ERROR_OK == plugin_api_->v0.Writer_setProperty(writer_, prop, val))
return true;
return false;
}
{
cv::Mat img = arr.getMat();
CV_DbgAssert(writer_);
- CV_Assert(plugin_api_->Writer_write);
- if (CV_ERROR_OK != plugin_api_->Writer_write(writer_, img.data, (int)img.step[0], img.cols, img.rows, img.channels()))
+ CV_Assert(plugin_api_->v0.Writer_write);
+ if (CV_ERROR_OK != plugin_api_->v0.Writer_write(writer_, img.data, (int)img.step[0], img.cols, img.rows, img.channels()))
{
CV_LOG_DEBUG(NULL, "Video I/O: Can't write frame by plugin '" << plugin_api_->api_header.api_description << "'");
}
}
int getCaptureDomain() const CV_OVERRIDE
{
- return plugin_api_->captureAPI;
+ return plugin_api_->v0.captureAPI;
}
};
#if defined(BUILD_PLUGIN)
+#define ABI_VERSION 0
+#define API_VERSION 0
#include "plugin_api.hpp"
namespace cv {
}
}
-static const OpenCV_VideoIO_Plugin_API_preview plugin_api_v0 =
+static const OpenCV_VideoIO_Plugin_API_preview plugin_api =
{
{
- sizeof(OpenCV_VideoIO_Plugin_API_preview), ABI_VERSION, 0/*API_VERSION*/,
+ sizeof(OpenCV_VideoIO_Plugin_API_preview), ABI_VERSION, API_VERSION,
CV_VERSION_MAJOR, CV_VERSION_MINOR, CV_VERSION_REVISION, CV_VERSION_STATUS,
"FFmpeg OpenCV Video I/O plugin"
},
- /* 1*/CAP_FFMPEG,
- /* 2*/cv_capture_open,
- /* 3*/cv_capture_release,
- /* 4*/cv_capture_get_prop,
- /* 5*/cv_capture_set_prop,
- /* 6*/cv_capture_grab,
- /* 7*/cv_capture_retrieve,
- /* 8*/cv_writer_open,
- /* 9*/cv_writer_release,
- /* 10*/cv_writer_get_prop,
- /* 11*/cv_writer_set_prop,
- /* 12*/cv_writer_write,
- /* 13 Writer_open_with_params*/NULL
+ {
+ /* 1*/CAP_FFMPEG,
+ /* 2*/cv_capture_open,
+ /* 3*/cv_capture_release,
+ /* 4*/cv_capture_get_prop,
+ /* 5*/cv_capture_set_prop,
+ /* 6*/cv_capture_grab,
+ /* 7*/cv_capture_retrieve,
+ /* 8*/cv_writer_open,
+ /* 9*/cv_writer_release,
+ /* 10*/cv_writer_get_prop,
+ /* 11*/cv_writer_set_prop,
+ /* 12*/cv_writer_write
+ }
};
} // namespace
const OpenCV_VideoIO_Plugin_API_preview* opencv_videoio_plugin_init_v0(int requested_abi_version, int requested_api_version, void* /*reserved=NULL*/) CV_NOEXCEPT
{
- if (requested_abi_version != 0)
- return NULL;
- if (requested_api_version != 0)
- return NULL;
- return &cv::plugin_api_v0;
+ if (requested_abi_version == ABI_VERSION && requested_api_version <= API_VERSION)
+ return &cv::plugin_api;
+ return NULL;
}
#endif // BUILD_PLUGIN
#if defined(BUILD_PLUGIN)
+#define ABI_VERSION 0
+#define API_VERSION 1
#include "plugin_api.hpp"
namespace cv {
}
}
-static const OpenCV_VideoIO_Plugin_API_preview plugin_api_v0 =
+static const OpenCV_VideoIO_Plugin_API_preview plugin_api =
{
{
sizeof(OpenCV_VideoIO_Plugin_API_preview), ABI_VERSION, API_VERSION,
CV_VERSION_MAJOR, CV_VERSION_MINOR, CV_VERSION_REVISION, CV_VERSION_STATUS,
"GStreamer OpenCV Video I/O plugin"
},
- /* 1*/CAP_GSTREAMER,
- /* 2*/cv_capture_open,
- /* 3*/cv_capture_release,
- /* 4*/cv_capture_get_prop,
- /* 5*/cv_capture_set_prop,
- /* 6*/cv_capture_grab,
- /* 7*/cv_capture_retrieve,
- /* 8*/cv_writer_open,
- /* 9*/cv_writer_release,
- /* 10*/cv_writer_get_prop,
- /* 11*/cv_writer_set_prop,
- /* 12*/cv_writer_write,
- /* 13*/cv_writer_open_with_params
+ {
+ /* 1*/CAP_GSTREAMER,
+ /* 2*/cv_capture_open,
+ /* 3*/cv_capture_release,
+ /* 4*/cv_capture_get_prop,
+ /* 5*/cv_capture_set_prop,
+ /* 6*/cv_capture_grab,
+ /* 7*/cv_capture_retrieve,
+ /* 8*/cv_writer_open,
+ /* 9*/cv_writer_release,
+ /* 10*/cv_writer_get_prop,
+ /* 11*/cv_writer_set_prop,
+ /* 12*/cv_writer_write
+ },
+ {
+ /* 13*/cv_writer_open_with_params
+ }
};
} // namespace
const OpenCV_VideoIO_Plugin_API_preview* opencv_videoio_plugin_init_v0(int requested_abi_version, int requested_api_version, void* /*reserved=NULL*/) CV_NOEXCEPT
{
- if (requested_abi_version != 0)
- return NULL;
- if (requested_api_version != 0 && requested_api_version != 1)
- return NULL;
- return &cv::plugin_api_v0;
+ if (requested_abi_version == ABI_VERSION && requested_api_version <= API_VERSION)
+ return &cv::plugin_api;
+ return NULL;
}
#endif // BUILD_PLUGIN
}
}
-static const OpenCV_VideoIO_Plugin_API_preview plugin_api_v0 =
+static const OpenCV_VideoIO_Plugin_API_preview plugin_api =
{
{
- sizeof(OpenCV_VideoIO_Plugin_API_preview), ABI_VERSION, 0/*API_VERSION*/,
+ sizeof(OpenCV_VideoIO_Plugin_API_preview), ABI_VERSION, API_VERSION,
CV_VERSION_MAJOR, CV_VERSION_MINOR, CV_VERSION_REVISION, CV_VERSION_STATUS,
"MediaSDK OpenCV Video I/O plugin"
},
- /* 1*/CAP_INTEL_MFX,
- /* 2*/cv_capture_open,
- /* 3*/cv_capture_release,
- /* 4*/cv_capture_get_prop,
- /* 5*/cv_capture_set_prop,
- /* 6*/cv_capture_grab,
- /* 7*/cv_capture_retrieve,
- /* 8*/cv_writer_open,
- /* 9*/cv_writer_release,
- /* 10*/cv_writer_get_prop,
- /* 11*/cv_writer_set_prop,
- /* 12*/cv_writer_write,
- /* 13 Writer_open_with_params*/NULL
+ {
+ /* 1*/CAP_INTEL_MFX,
+ /* 2*/cv_capture_open,
+ /* 3*/cv_capture_release,
+ /* 4*/cv_capture_get_prop,
+ /* 5*/cv_capture_set_prop,
+ /* 6*/cv_capture_grab,
+ /* 7*/cv_capture_retrieve,
+ /* 8*/cv_writer_open,
+ /* 9*/cv_writer_release,
+ /* 10*/cv_writer_get_prop,
+ /* 11*/cv_writer_set_prop,
+ /* 12*/cv_writer_write
+ }
};
} // namespace
const OpenCV_VideoIO_Plugin_API_preview* opencv_videoio_plugin_init_v0(int requested_abi_version, int requested_api_version, void* /*reserved=NULL*/) CV_NOEXCEPT
{
- if (requested_abi_version != 0)
- return NULL;
- if (requested_api_version != 0)
- return NULL;
- return &cv::plugin_api_v0;
+ if (requested_abi_version == ABI_VERSION && requested_api_version <= API_VERSION)
+ return &cv::plugin_api;
+ return NULL;
}
#endif // BUILD_PLUGIN
#if defined(BUILD_PLUGIN)
+#define ABI_VERSION 0
+#define API_VERSION 0
#include "plugin_api.hpp"
namespace cv {
}
}
-static const OpenCV_VideoIO_Plugin_API_preview plugin_api_v0 =
+static const OpenCV_VideoIO_Plugin_API_preview plugin_api =
{
{
- sizeof(OpenCV_VideoIO_Plugin_API_preview), ABI_VERSION, 0/*API_VERSION*/,
+ sizeof(OpenCV_VideoIO_Plugin_API_preview), ABI_VERSION, API_VERSION,
CV_VERSION_MAJOR, CV_VERSION_MINOR, CV_VERSION_REVISION, CV_VERSION_STATUS,
"Microsoft Media Foundation OpenCV Video I/O plugin"
},
- /* 1*/CAP_MSMF,
- /* 2*/cv_capture_open,
- /* 3*/cv_capture_release,
- /* 4*/cv_capture_get_prop,
- /* 5*/cv_capture_set_prop,
- /* 6*/cv_capture_grab,
- /* 7*/cv_capture_retrieve,
- /* 8*/cv_writer_open,
- /* 9*/cv_writer_release,
- /* 10*/cv_writer_get_prop,
- /* 11*/cv_writer_set_prop,
- /* 12*/cv_writer_write
+ {
+ /* 1*/CAP_MSMF,
+ /* 2*/cv_capture_open,
+ /* 3*/cv_capture_release,
+ /* 4*/cv_capture_get_prop,
+ /* 5*/cv_capture_set_prop,
+ /* 6*/cv_capture_grab,
+ /* 7*/cv_capture_retrieve,
+ /* 8*/cv_writer_open,
+ /* 9*/cv_writer_release,
+ /* 10*/cv_writer_get_prop,
+ /* 11*/cv_writer_set_prop,
+ /* 12*/cv_writer_write
+ }
};
} // namespace
const OpenCV_VideoIO_Plugin_API_preview* opencv_videoio_plugin_init_v0(int requested_abi_version, int requested_api_version, void* /*reserved=NULL*/) CV_NOEXCEPT
{
- if (requested_abi_version != 0)
- return NULL;
- if (requested_api_version != 0)
- return NULL;
- return &cv::plugin_api_v0;
+ if (requested_abi_version == ABI_VERSION && requested_api_version <= API_VERSION)
+ return &cv::plugin_api;
+ return NULL;
}
#endif // BUILD_PLUGIN
// plugin glue
#if defined(BUILD_PLUGIN)
+#define ABI_VERSION 0
+#define API_VERSION 0
#include "plugin_api.hpp"
namespace cv
return CV_ERROR_FAIL;
}
-const OpenCV_VideoIO_Plugin_API_preview plugin_api_v0 =
+const OpenCV_VideoIO_Plugin_API_preview plugin_api =
{
{
- sizeof(OpenCV_VideoIO_Plugin_API_preview), ABI_VERSION, 0/*API_VERSION*/,
+ sizeof(OpenCV_VideoIO_Plugin_API_preview), ABI_VERSION, API_VERSION,
CV_VERSION_MAJOR, CV_VERSION_MINOR, CV_VERSION_REVISION, CV_VERSION_STATUS,
"uEye OpenCV Video I/O plugin"
},
- /* 1*/CAP_UEYE,
- /* 2*/cv_capture_open,
- /* 3*/cv_capture_release,
- /* 4*/cv_capture_get_prop,
- /* 5*/cv_capture_set_prop,
- /* 6*/cv_capture_grab,
- /* 7*/cv_capture_retrieve,
- /* 8*/cv_writer_open,
- /* 9*/cv_writer_release,
- /* 10*/cv_writer_get_prop,
- /* 11*/cv_writer_set_prop,
- /* 12*/cv_writer_write,
- /* 13 Writer_open_with_params*/NULL
+ {
+ /* 1*/CAP_UEYE,
+ /* 2*/cv_capture_open,
+ /* 3*/cv_capture_release,
+ /* 4*/cv_capture_get_prop,
+ /* 5*/cv_capture_set_prop,
+ /* 6*/cv_capture_grab,
+ /* 7*/cv_capture_retrieve,
+ /* 8*/cv_writer_open,
+ /* 9*/cv_writer_release,
+ /* 10*/cv_writer_get_prop,
+ /* 11*/cv_writer_set_prop,
+ /* 12*/cv_writer_write
+ }
};
} // namespace
} // namespace cv
const OpenCV_VideoIO_Plugin_API_preview* opencv_videoio_plugin_init_v0(int requested_abi_version, int requested_api_version, void* /*reserved=NULL*/) CV_NOEXCEPT
{
- if (requested_abi_version != 0)
- return NULL;
- if (requested_api_version != 0)
- return NULL;
- return &cv::plugin_api_v0;
+ if (requested_abi_version == ABI_VERSION && requested_api_version <= API_VERSION)
+ return &cv::plugin_api;
+ return NULL;
}
#endif // BUILD_PLUGIN
#include <opencv2/core/cvdef.h>
#include <opencv2/core/llapi/llapi.h>
-// increase for backward-compatible changes, e.g. add new function
-// Main API <= Plugin API -> plugin is fully compatible
-// Main API > Plugin API -> plugin is not compatible, caller should use shim code to use plugins with old API
+#if !defined(BUILD_PLUGIN)
+
+/// increased for backward-compatible changes, e.g. add new function
+/// Caller API <= Plugin API -> plugin is fully compatible
+/// Caller API > Plugin API -> plugin is not fully compatible, caller should use extra checks to use plugins with older API
#define API_VERSION 1 // preview
-// increase for incompatible changes, e.g. remove function argument
-// Main ABI == Plugin ABI -> plugin is compatible
-// Main ABI > Plugin ABI -> plugin is not compatible, caller should use shim code to use old ABI plugins
+
+/// increased for incompatible changes, e.g. remove function argument
+/// Caller ABI == Plugin ABI -> plugin is compatible
+/// Caller ABI > Plugin ABI -> plugin is not compatible, caller should use shim code to use old ABI plugins (caller may know how lower ABI works, so it is possible)
+/// Caller ABI < Plugin ABI -> plugin can't be used (plugin should provide interface with lower ABI to handle that)
#define ABI_VERSION 0 // preview
+#else // !defined(BUILD_PLUGIN)
+
+#if !defined(ABI_VERSION) || !defined(API_VERSION)
+#error "Plugin must define ABI_VERSION and API_VERSION before including plugin_api.hpp"
+#endif
+
+#endif // !defined(BUILD_PLUGIN)
+
+
#ifdef __cplusplus
extern "C" {
#endif
typedef struct CvPluginCapture_t* CvPluginCapture;
typedef struct CvPluginWriter_t* CvPluginWriter;
-typedef struct OpenCV_VideoIO_Plugin_API_preview
+struct OpenCV_VideoIO_Plugin_API_v0_0_api_entries
{
- OpenCV_API_Header api_header;
-
/** OpenCV capture ID (VideoCaptureAPIs)
@note API-ENTRY 1, API-Version == 0
*/
@note API-CALL 12, API-Version == 0
*/
CvResult (CV_API_CALL *Writer_write)(CvPluginWriter handle, const unsigned char *data, int step, int width, int height, int cn);
+}; // OpenCV_VideoIO_Plugin_API_v0_0_api_entries
-
+struct OpenCV_VideoIO_Plugin_API_v0_1_api_entries
+{
/** @brief Try to open video writer
@param filename Destination location
int* params, unsigned n_params,
CV_OUT CvPluginWriter* handle
);
+}; // OpenCV_VideoIO_Plugin_API_v0_1_api_entries
-} OpenCV_VideoIO_Plugin_API_preview;
+typedef struct OpenCV_VideoIO_Plugin_API_preview_v0
+{
+ OpenCV_API_Header api_header;
+ struct OpenCV_VideoIO_Plugin_API_v0_0_api_entries v0;
+} OpenCV_VideoIO_Plugin_API_preview_v0;
+
+typedef struct OpenCV_VideoIO_Plugin_API_preview_v1
+{
+ OpenCV_API_Header api_header;
+ struct OpenCV_VideoIO_Plugin_API_v0_0_api_entries v0;
+ struct OpenCV_VideoIO_Plugin_API_v0_1_api_entries v1;
+} OpenCV_VideoIO_Plugin_API_preview_v1;
+
+
+#if ABI_VERSION == 0 && API_VERSION == 1
+typedef struct OpenCV_VideoIO_Plugin_API_preview_v1 OpenCV_VideoIO_Plugin_API_preview;
+#elif ABI_VERSION == 0 && API_VERSION == 0
+typedef struct OpenCV_VideoIO_Plugin_API_preview_v0 OpenCV_VideoIO_Plugin_API_preview;
+#else
+#error "Not supported configuration: check ABI_VERSION/API_VERSION"
+#endif
#ifdef BUILD_PLUGIN