Skip to content

samples_findFile

Core and matricesfunctionOpenCV 5.0.0
import { samples_findFile } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSrelative_path, required, silentMode
FUNCTIONsamples_findFile
RETURN TYPEstring
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

This section describes utility functions for OpenCV samples.

Note: Implementation of these utilities is not thread-safe.

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: cv::utils::findDataFile

samples_findFile(relative_path: EmbindString, required: boolean, silentMode: boolean): string;
3 available overloads
samples_findFile(relative_path: EmbindString): string;
samples_findFile(relative_path: EmbindString, required: boolean): string;
samples_findFile(relative_path: EmbindString, required: boolean, silentMode: boolean): string;
relative_path

Relative path to data file

required

Specify "file not found" handling. If true, function prints information message and raises cv::Exception. If false, function returns empty result

silentMode

Disables messages

Returns

Returns path (absolute or relative to the current directory) or empty string if file is not found

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.