未验证 提交 4ed07411 编写于 作者: A Alexander Smorkalov 提交者: GitHub

Merge pull request #23290 from vovka643:4.x_depricated_backends

4.x deprecated VideoCapture backends
......@@ -212,6 +212,19 @@ bool VideoCapture::open(const String& filename, int apiPreference, const std::ve
CV_Error_(Error::StsError, ("could not open '%s'", filename.c_str()));
}
if (cv::videoio_registry::checkDeprecatedBackend(apiPreference))
{
CV_LOG_DEBUG(NULL,
cv::format("VIDEOIO(%s): backend is removed from OpenCV",
cv::videoio_registry::getBackendName((VideoCaptureAPIs) apiPreference).c_str()));
}
else
{
CV_LOG_DEBUG(NULL, "VIDEOIO: choosen backend does not work or wrong. "
"Please make sure that your computer support chosen backend and OpenCV built "
"with right flags.");
}
return false;
}
......@@ -337,6 +350,19 @@ bool VideoCapture::open(int cameraNum, int apiPreference, const std::vector<int>
CV_Error_(Error::StsError, ("could not open camera %d", cameraNum));
}
if (cv::videoio_registry::checkDeprecatedBackend(apiPreference))
{
CV_LOG_DEBUG(NULL,
cv::format("VIDEOIO(%s): backend is removed from OpenCV",
cv::videoio_registry::getBackendName((VideoCaptureAPIs) apiPreference).c_str()));
}
else
{
CV_LOG_DEBUG(NULL, "VIDEOIO: choosen backend does not work or wrong."
"Please make sure that your computer support chosen backend and OpenCV built "
"with right flags.");
}
return false;
}
......@@ -640,6 +666,20 @@ bool VideoWriter::open(const String& filename, int apiPreference, int fourcc, do
}
}
}
if (cv::videoio_registry::checkDeprecatedBackend(apiPreference))
{
CV_LOG_DEBUG(NULL,
cv::format("VIDEOIO(%s): backend is removed from OpenCV",
cv::videoio_registry::getBackendName((VideoCaptureAPIs) apiPreference).c_str()));
}
else
{
CV_LOG_DEBUG(NULL, "VIDEOIO: choosen backend does not work or wrong."
"Please make sure that your computer support chosen backend and OpenCV built "
"with right flags.");
}
return false;
}
......
......@@ -183,6 +183,18 @@ static const struct VideoBackendInfo builtin_backends[] =
// dropped backends: MIL, TYZX
};
static const struct VideoDeprecatedBackendInfo deprecated_backends[] =
{
#ifdef _WIN32
{CAP_VFW, "Video for Windows"},
#endif
{CAP_QT, "QuickTime"},
{CAP_UNICAP, "Unicap"},
{CAP_OPENNI, "OpenNI"},
{CAP_OPENNI_ASUS, "OpenNI"},
{CAP_GIGANETIX, "GigEVisionSDK"}
};
bool sortByPriority(const VideoBackendInfo &lhs, const VideoBackendInfo &rhs)
{
return lhs.priority > rhs.priority;
......@@ -351,6 +363,16 @@ std::vector<VideoBackendInfo> getAvailableBackends_Writer()
return result;
}
bool checkDeprecatedBackend(int api) {
const int M = sizeof(deprecated_backends) / sizeof(deprecated_backends[0]);
for (size_t i = 0; i < M; i++)
{
if (deprecated_backends[i].id == api)
return true;
}
return false;
}
cv::String getBackendName(VideoCaptureAPIs api)
{
if (api == CAP_ANY)
......@@ -362,6 +384,14 @@ cv::String getBackendName(VideoCaptureAPIs api)
if (backend.id == api)
return backend.name;
}
const int M = sizeof(deprecated_backends) / sizeof(deprecated_backends[0]);
for (size_t i = 0; i < M; i++)
{
if (deprecated_backends[i].id == api)
return deprecated_backends[i].name;
}
return cv::format("UnknownVideoAPI(%d)", (int)api);
}
......
......@@ -29,11 +29,17 @@ struct VideoBackendInfo {
Ptr<IBackendFactory> backendFactory;
};
struct VideoDeprecatedBackendInfo {
VideoCaptureAPIs id;
const char* name;
};
namespace videoio_registry {
std::vector<VideoBackendInfo> getAvailableBackends_CaptureByIndex();
std::vector<VideoBackendInfo> getAvailableBackends_CaptureByFilename();
std::vector<VideoBackendInfo> getAvailableBackends_Writer();
bool checkDeprecatedBackend(int api);
} // namespace
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册