1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2024-11-13 09:02:39 +03:00
51 changed files with 861 additions and 303 deletions
+3 -5
View File
@@ -336,16 +336,14 @@ std::vector<FileSystemPath_t> getPluginCandidates(const std::string& baseName)
std::vector<FileSystemPath_t> results;
#ifdef _WIN32
FileSystemPath_t moduleName = toFileSystemPath(libraryPrefix() + "opencv_videoio_" + baseName_l + librarySuffix());
#ifndef WINRT
if (baseName_u == "FFMPEG") // backward compatibility
{
const wchar_t* ffmpeg_env_path = _wgetenv(L"OPENCV_FFMPEG_DLL_DIR");
if (ffmpeg_env_path)
const std::string ffmpeg_env_path = cv::utils::getConfigurationParameterString("OPENCV_FFMPEG_DLL_DIR");
if (!ffmpeg_env_path.empty())
{
results.push_back(FileSystemPath_t(ffmpeg_env_path) + L"\\" + moduleName);
results.push_back(toFileSystemPath(ffmpeg_env_path + "\\" + toPrintablePath(moduleName)));
}
}
#endif
if (plugin_expr != default_expr)
{
moduleName = toFileSystemPath(plugin_expr);
+7 -15
View File
@@ -303,15 +303,7 @@ interface ISampleGrabber : public IUnknown
static void DebugPrintOut(const char *format, ...)
{
static int gs_verbose = -1;
if (gs_verbose < 0)
{
// Fetch initial debug state from environment - defaults to disabled
const char* s = getenv("OPENCV_DSHOW_DEBUG");
gs_verbose = s != NULL && atoi(s) != 0;
}
static const bool gs_verbose = utils::getConfigurationParameterBool("OPENCV_DSHOW_DEBUG");
if (gs_verbose)
{
va_list args;
@@ -2982,18 +2974,18 @@ int videoInput::start(int deviceID, videoDevice *VD){
VD->readyToCapture = true;
// check for optional saving the direct show graph to a file
const char* graph_filename = getenv("OPENCV_DSHOW_SAVEGRAPH_FILENAME");
if (graph_filename) {
size_t filename_len = strlen(graph_filename);
std::string graph_filename = utils::getConfigurationParameterString("OPENCV_DSHOW_SAVEGRAPH_FILENAME");
if (!graph_filename.empty()) {
size_t filename_len = graph_filename.size();
std::vector<WCHAR> wfilename(filename_len + 1);
size_t len = mbstowcs(&wfilename[0], graph_filename, filename_len + 1);
size_t len = mbstowcs(&wfilename[0], &graph_filename[0], filename_len + 1);
CV_Assert(len == filename_len);
HRESULT res = SaveGraphFile(VD->pGraph, &wfilename[0]);
if (SUCCEEDED(res)) {
DebugPrintOut("Saved DSHOW graph to %s\n", graph_filename);
DebugPrintOut("Saved DSHOW graph to %s\n", graph_filename.c_str());
} else {
DebugPrintOut("Failed to save DSHOW graph to %s\n", graph_filename);
DebugPrintOut("Failed to save DSHOW graph to %s\n", graph_filename.c_str());
}
}
+15 -21
View File
@@ -928,21 +928,19 @@ public:
}
static void initLogger_()
{
#ifndef NO_GETENV
char* debug_option = getenv("OPENCV_FFMPEG_DEBUG");
char* level_option = getenv("OPENCV_FFMPEG_LOGLEVEL");
const bool debug_option = utils::getConfigurationParameterBool("OPENCV_FFMPEG_DEBUG");
std::string level_option = utils::getConfigurationParameterString("OPENCV_FFMPEG_LOGLEVEL");
int level = AV_LOG_VERBOSE;
if (level_option != NULL)
if (!level_option.empty())
{
level = atoi(level_option);
level = atoi(level_option.c_str());
}
if ( (debug_option != NULL) || (level_option != NULL) )
if ( debug_option || (!level_option.empty()) )
{
av_log_set_level(level);
av_log_set_callback(ffmpeg_log_callback);
}
else
#endif
{
av_log_set_level(AV_LOG_ERROR);
}
@@ -979,10 +977,10 @@ inline void fill_codec_context(AVCodecContext * enc, AVDictionary * dict)
{
int nCpus = cv::getNumberOfCPUs();
int requestedThreads = std::min(nCpus, 16); // [OPENCV:FFMPEG:24] Application has requested XX threads. Using a thread count greater than 16 is not recommended.
char* threads_option = getenv("OPENCV_FFMPEG_THREADS");
if (threads_option != NULL)
std::string threads_option = utils::getConfigurationParameterString("OPENCV_FFMPEG_THREADS");
if (!threads_option.empty())
{
requestedThreads = atoi(threads_option);
requestedThreads = atoi(threads_option.c_str());
}
enc->thread_count = requestedThreads;
}
@@ -1122,9 +1120,8 @@ bool CvCapture_FFMPEG::open(const char* _filename, const VideoCaptureParameters&
ic->interrupt_callback.opaque = &interrupt_metadata;
#endif
#ifndef NO_GETENV
char* options = getenv("OPENCV_FFMPEG_CAPTURE_OPTIONS");
if(options == NULL)
std::string options = utils::getConfigurationParameterString("OPENCV_FFMPEG_CAPTURE_OPTIONS");
if(!options.empty())
{
#if LIBAVFORMAT_VERSION_MICRO >= 100 && LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 48, 100)
av_dict_set(&dict, "rtsp_flags", "prefer_tcp", 0);
@@ -1136,14 +1133,11 @@ bool CvCapture_FFMPEG::open(const char* _filename, const VideoCaptureParameters&
{
CV_LOG_DEBUG(NULL, "VIDEOIO/FFMPEG: using capture options from environment: " << options);
#if LIBAVUTIL_BUILD >= (LIBAVUTIL_VERSION_MICRO >= 100 ? CALC_FFMPEG_VERSION(52, 17, 100) : CALC_FFMPEG_VERSION(52, 7, 0))
av_dict_parse_string(&dict, options, ";", "|", 0);
av_dict_parse_string(&dict, options.c_str(), ";", "|", 0);
#else
av_dict_set(&dict, "rtsp_transport", "tcp", 0);
#endif
}
#else
av_dict_set(&dict, "rtsp_transport", "tcp", 0);
#endif
CV_FFMPEG_FMT_CONST AVInputFormat* input_format = NULL;
AVDictionaryEntry* entry = av_dict_get(dict, "input_format", NULL, 0);
if (entry != 0)
@@ -3095,12 +3089,12 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
}
AVDictionary *dict = NULL;
#if !defined(NO_GETENV) && (LIBAVUTIL_VERSION_MAJOR >= 53)
char* options = getenv("OPENCV_FFMPEG_WRITER_OPTIONS");
if (options)
#if (LIBAVUTIL_VERSION_MAJOR >= 53)
std::string options = utils::getConfigurationParameterString("OPENCV_FFMPEG_WRITER_OPTIONS");
if (!options.empty())
{
CV_LOG_DEBUG(NULL, "VIDEOIO/FFMPEG: using writer options from environment: " << options);
av_dict_parse_string(&dict, options, ";", "|", 0);
av_dict_parse_string(&dict, options.c_str(), ";", "|", 0);
}
#endif
+1 -1
View File
@@ -253,7 +253,7 @@ protected:
bool readPrioritySettings()
{
bool hasChanges = false;
cv::String prioritized_backends = utils::getConfigurationParameterString("OPENCV_VIDEOIO_PRIORITY_LIST", NULL);
cv::String prioritized_backends = utils::getConfigurationParameterString("OPENCV_VIDEOIO_PRIORITY_LIST");
if (prioritized_backends.empty())
return hasChanges;
CV_LOG_INFO(NULL, "VIDEOIO: Configured priority list (OPENCV_VIDEOIO_PRIORITY_LIST): " << prioritized_backends);
+1 -3
View File
@@ -11,15 +11,13 @@
static
void initTests()
{
#ifndef WINRT // missing getenv
const std::vector<cv::VideoCaptureAPIs> backends = cv::videoio_registry::getStreamBackends();
const char* requireFFmpeg = getenv("OPENCV_TEST_VIDEOIO_BACKEND_REQUIRE_FFMPEG");
bool requireFFmpeg = cv::utils::getConfigurationParameterBool("OPENCV_TEST_VIDEOIO_BACKEND_REQUIRE_FFMPEG");
if (requireFFmpeg && !isBackendAvailable(cv::CAP_FFMPEG, backends))
{
CV_LOG_FATAL(NULL, "OpenCV-Test: required FFmpeg backend is not available (broken plugin?). STOP.");
exit(1);
}
#endif
}
CV_TEST_MAIN("highgui", initTests())
+1
View File
@@ -13,6 +13,7 @@
#include "opencv2/videoio.hpp"
#include "opencv2/videoio/registry.hpp"
#include "opencv2/core/private.hpp"
#include "opencv2/core/utils/configuration.private.hpp"
namespace cv {