mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 20:42:53 +08:00
Added depricated_backends list. Added new information masseges. It needs to inform user, when he tries to use depricated or not uses backend
This commit is contained in:
parent
f7bee7883b
commit
d6dc91b4d4
@ -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()));
|
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;
|
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));
|
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;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +183,18 @@ static const struct VideoBackendInfo builtin_backends[] =
|
|||||||
// dropped backends: MIL, TYZX
|
// 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)
|
bool sortByPriority(const VideoBackendInfo &lhs, const VideoBackendInfo &rhs)
|
||||||
{
|
{
|
||||||
return lhs.priority > rhs.priority;
|
return lhs.priority > rhs.priority;
|
||||||
@ -351,6 +363,16 @@ std::vector<VideoBackendInfo> getAvailableBackends_Writer()
|
|||||||
return result;
|
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)
|
cv::String getBackendName(VideoCaptureAPIs api)
|
||||||
{
|
{
|
||||||
if (api == CAP_ANY)
|
if (api == CAP_ANY)
|
||||||
@ -362,6 +384,14 @@ cv::String getBackendName(VideoCaptureAPIs api)
|
|||||||
if (backend.id == api)
|
if (backend.id == api)
|
||||||
return backend.name;
|
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);
|
return cv::format("UnknownVideoAPI(%d)", (int)api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +29,17 @@ struct VideoBackendInfo {
|
|||||||
Ptr<IBackendFactory> backendFactory;
|
Ptr<IBackendFactory> backendFactory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct VideoDeprecatedBackendInfo {
|
||||||
|
VideoCaptureAPIs id;
|
||||||
|
const char* name;
|
||||||
|
};
|
||||||
|
|
||||||
namespace videoio_registry {
|
namespace videoio_registry {
|
||||||
|
|
||||||
std::vector<VideoBackendInfo> getAvailableBackends_CaptureByIndex();
|
std::vector<VideoBackendInfo> getAvailableBackends_CaptureByIndex();
|
||||||
std::vector<VideoBackendInfo> getAvailableBackends_CaptureByFilename();
|
std::vector<VideoBackendInfo> getAvailableBackends_CaptureByFilename();
|
||||||
std::vector<VideoBackendInfo> getAvailableBackends_Writer();
|
std::vector<VideoBackendInfo> getAvailableBackends_Writer();
|
||||||
|
bool checkDeprecatedBackend(int api);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user