OpenCV  3.4.14
Open Source Computer Vision
Functions
Utility functions for OpenCV samples

Functions

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

Detailed Description

Function Documentation

◆ addSamplesDataSearchPath()

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

#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:
None=cv.samples.addSamplesDataSearchSubDirectory(subdir)

#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:
retval=cv.samples.findFile(relative_path[, required[, silentMode]])

#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
Examples:
samples/cpp/connected_components.cpp, samples/cpp/create_mask.cpp, samples/cpp/demhist.cpp, samples/cpp/distrans.cpp, samples/cpp/edge.cpp, samples/cpp/facedetect.cpp, samples/cpp/falsecolor.cpp, samples/cpp/ffilldemo.cpp, samples/cpp/fitellipse.cpp, samples/cpp/grabcut.cpp, samples/cpp/image_alignment.cpp, samples/cpp/squares.cpp, samples/cpp/stitching.cpp, samples/cpp/stitching_detailed.cpp, samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp, samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp, samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp, samples/cpp/tutorial_code/HighGUI/AddingImagesTrackbar.cpp, samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp, samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp, samples/cpp/tutorial_code/ImgProc/Pyramids/Pyramids.cpp, samples/cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp, samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp, samples/cpp/tutorial_code/ImgTrans/houghcircles.cpp, samples/cpp/tutorial_code/ImgTrans/houghlines.cpp, samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp, samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp, samples/cpp/tutorial_code/photo/non_photorealistic_rendering/npr_demo.cpp, samples/cpp/warpPerspective_demo.cpp, samples/cpp/watershed.cpp, samples/dnn/classification.cpp, samples/dnn/colorization.cpp, samples/dnn/object_detection.cpp, samples/dnn/openpose.cpp, samples/dnn/segmentation.cpp, and samples/tapi/squares.cpp.

◆ findFileOrKeep()

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