Added depricated_backends list. Added new information masseges. It needs to inform user, when he tries to use depricated or not uses backend

pull/23290/head
vovka643 2 years ago committed by Alexander Smorkalov
parent f7bee7883b
commit d6dc91b4d4
  1. 40
      modules/videoio/src/cap.cpp
  2. 30
      modules/videoio/src/videoio_registry.cpp
  3. 6
      modules/videoio/src/videoio_registry.hpp

@ -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

Loading…
Cancel
Save