Package 'ROpenCVLite'

Title: Helper Package for Installing 'OpenCV'
Description: Installs 'OpenCV' for use by other packages. 'OpenCV' <https://opencv.org/> is library of programming functions mainly aimed at real-time computer vision. This 'Lite' version installs the stable base version of 'OpenCV' and some of its experimental externally contributed modules. It does not provide R bindings directly.
Authors: Simon Garnier [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-3886-3974>), Muschelli John [ctb]
Maintainer: Simon Garnier <[email protected]>
License: GPL-3
Version: 4.130.0
Built: 2026-05-22 10:27:54 UTC
Source: https://github.com/swarm-lab/ropencvlite

Help Index


Default Install Location of OpenCV

Description

This function returns the location at which OpenCV should be installed by default.

Usage

defaultOpenCVPath()

Value

A character string.

Author(s)

Simon Garnier, [email protected]

Examples

defaultOpenCVPath()

Install OpenCV

Description

This function attempts to download, compile and install OpenCV on the system. This process will take several minutes.

Usage

installOpenCV(
  install_path = defaultOpenCVPath(),
  batch = FALSE,
  use_ccache = FALSE,
  optimize_for_host = FALSE,
  modules = c("calib3d", "core", "dnn", "features2d", "flann", "gapi", "highgui",
    "imgcodecs", "imgproc", "ml", "objdetect", "photo", "stitching", "video", "videoio",
    "ximgproc", "wechat_qrcode")
)

Arguments

install_path

A character string indicating the location at which OpenCV should be installed. By default, it is the value returned by defaultOpenCVPath.

batch

A boolean indicating whether to skip (TRUE) or not (FALSE, the default) the interactive installation dialog. This is useful when OpenCV needs to be installed in a non-interactive environment (e.g., during a batch installation on a server).

use_ccache

A boolean indicating whether to use ccache (TRUE) to speed up repeated compilations. Requires ccache to be installed and on the PATH. Defaults to FALSE.

optimize_for_host

A boolean indicating whether to let CMake detect and use the host CPU's full instruction set (TRUE) instead of the defaults (FALSE). On Windows the default is a conservative SSE4/AVX-limited build; on Unix/macOS CMake's own defaults apply. Setting this to TRUE produces a faster binary on the build machine but the result may not run on other hardware.

modules

A character vector of OpenCV modules to compile. Defaults to the full set supported by ROpenCVLite. Specify a subset to reduce compilation time when only specific functionality is needed.

Value

A boolean.

Author(s)

Simon Garnier, [email protected]

Examples

## Not run: 
installOpenCV()

## End(Not run)

Check Cmake Installation

Description

This function checks that Cmake is installed on the system.

Usage

isCmakeInstalled()

Value

A boolean.

Author(s)

Simon Garnier, [email protected]

Examples

isCmakeInstalled()

Check OpenCV Installation

Description

This function checks that OpenCV is installed and accessible.

Usage

isOpenCVInstalled()

Value

A boolean.

Author(s)

Simon Garnier, [email protected]

Examples

isOpenCVInstalled()

C/C++ configuration options

Description

This function returns the configuration options for compiling C/C++-based packages against OpenCV installed by ROpenCVLite.

Usage

opencvConfig(output = "libs", arch = NULL)

Arguments

output

Either 'libs' for library configuration options or 'cflags' for C/C++ configuration flags.

arch

architecture relevant for Windows. If NULL, then R.version$arch will be used.

Value

A concatenated character string (with cat) of the configuration options.

Author(s)

Simon Garnier, [email protected]

Examples

## Not run: 
 if (isOpenCVInstalled()) {
   opencvConfig()
   opencvConfig(output = "cflags")
   opencvConfig(arch = R.version$arch)
 }

## End(Not run)

Install Location of OpenCV

Description

This function returns the location at which OpenCV is installed.

Usage

OpenCVPath()

Value

A character string.

Author(s)

Simon Garnier, [email protected]

Examples

## Not run: 
 OpenCVPath()

## End(Not run)

OpenCV Version

Description

This function determines the version of OpenCV installed within R.

Usage

opencvVersion()

Value

A character string.

Author(s)

Simon Garnier, [email protected]

Examples

if (isOpenCVInstalled()) {
  opencvVersion()
}

Remove OpenCV

Description

This function removes OpenCV from the system.

Usage

removeOpenCV()

Value

A boolean.

Author(s)

Simon Garnier, [email protected]

Examples

## Not run: 
installOpenCV()

## End(Not run)