OpenCV  4.10.0-dev
Open Source Computer Vision
Loading...
Searching...
No Matches
Functions
Utility functions for OpenCV samples

Detailed Description

Functions

void cv::samples::addSamplesDataSearchPath (const cv::String &path)
 Override search data path by adding new search location.
 
void cv::samples::addSamplesDataSearchSubDirectory (const cv::String &subdir)
 Append samples search data sub directory.
 
cv::String cv::samples::findFile (const cv::String &relative_path, bool required=true, bool silentMode=false)
 Try to find requested data file.
 
cv::String cv::samples::findFileOrKeep (const cv::String &relative_path, bool silentMode=false)
 

Function Documentation

◆ addSamplesDataSearchPath()

void cv::samples::addSamplesDataSearchPath ( const cv::String path)
Python:
cv.samples.addSamplesDataSearchPath(path) -> None

#include <opencv2/core/utility.hpp>

Override search data path by adding new search location.

Use this only to override default behavior Passed paths are used in LIFO order.

Parameters
pathPath to used samples data

◆ addSamplesDataSearchSubDirectory()

void cv::samples::addSamplesDataSearchSubDirectory ( const cv::String subdir)
Python:
cv.samples.addSamplesDataSearchSubDirectory(subdir) -> None

#include <opencv2/core/utility.hpp>

Append samples search data sub directory.

General usage is to add OpenCV modules name (<opencv_contrib>/modules/<name>/samples/data -> <name>/samples/data + modules/<name>/samples/data). Passed subdirectories are used in LIFO order.

Parameters
subdirsamples data sub directory

◆ findFile()

cv::String cv::samples::findFile ( const cv::String relative_path,
bool  required = true,
bool  silentMode = false 
)
Python:
cv.samples.findFile(relative_path[, required[, silentMode]]) -> retval

#include <opencv2/core/utility.hpp>

Try to find requested data file.

Search directories:

  1. Directories passed via addSamplesDataSearchPath()
  2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable
  3. OPENCV_SAMPLES_DATA_PATH environment variable If parameter value is not empty and nothing is found then stop searching.
  4. Detects build/install path based on: a. current working directory (CWD) b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage)
  5. Scan <source>/{,data,samples/data} directories if build directory is detected or the current directory is in source tree.
  6. Scan <install>/share/OpenCV directory if install directory is detected.
See also
cv::utils::findDataFile
Parameters
relative_pathRelative path to data file
requiredSpecify "file not found" handling. If true, function prints information message and raises cv::Exception. If false, function returns empty result
silentModeDisables messages
Returns
Returns path (absolute or relative to the current directory) or empty string if file is not found

◆ findFileOrKeep()

cv::String cv::samples::findFileOrKeep ( const cv::String relative_path,
bool  silentMode = false 
)
inline
Python:
cv.samples.findFileOrKeep(relative_path[, silentMode]) -> retval

#include <opencv2/core/utility.hpp>

Here is the call graph for this function: