├── inst ├── path └── CITATION ├── .github ├── .gitignore ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ ├── pkgdown.yaml │ ├── R-CMD-check.yaml │ ├── test-coverage.yaml │ └── rhub.yaml ├── logo.png ├── docs ├── favicon.ico ├── favicon-16x16.png ├── favicon-32x32.png ├── apple-touch-icon.png ├── reference │ ├── Rplot001.png │ ├── figures │ │ └── logo.png │ ├── isCmakeInstalled.html │ ├── isOpenCVInstalled.html │ ├── index.html │ ├── ROpenCVLite-package.html │ ├── removeOpenCV.html │ ├── OpenCVPath.html │ ├── opencvVersion.html │ ├── defaultOpenCVPath.html │ ├── installOpenCV.html │ └── opencvConfig.html ├── apple-touch-icon-120x120.png ├── apple-touch-icon-152x152.png ├── apple-touch-icon-180x180.png ├── apple-touch-icon-60x60.png ├── apple-touch-icon-76x76.png ├── pkgdown.yml ├── link.svg ├── sitemap.xml ├── logo.svg ├── articles │ ├── index.html │ └── usage.html ├── pkgdown.js ├── 404.html ├── authors.html └── index.html ├── man ├── figures │ └── logo.png ├── removeOpenCV.Rd ├── isCmakeInstalled.Rd ├── OpenCVPath.Rd ├── isOpenCVInstalled.Rd ├── opencvVersion.Rd ├── defaultOpenCVPath.Rd ├── ROpenCVLite-package.Rd ├── opencvConfig.Rd └── installOpenCV.Rd ├── pkgdown └── favicon │ ├── favicon.ico │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon-96x96.png │ ├── apple-touch-icon.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ ├── apple-touch-icon-180x180.png │ ├── web-app-manifest-192x192.png │ ├── web-app-manifest-512x512.png │ ├── site.webmanifest │ └── favicon.svg ├── _pkgdown.yml ├── .gitignore ├── NAMESPACE ├── codecov.yml ├── .Rbuildignore ├── R ├── ROpenCVLite.R ├── zzz.R ├── utils.R └── install.R ├── ROpenCVLite.Rproj ├── configure ├── configure.win ├── cran-comments.md ├── vignettes ├── install.R ├── usage.Rmd ├── install.Rmd └── usage.html ├── DESCRIPTION ├── test_install ├── test_script.R └── test_install.R ├── logo.svg ├── README.md └── NEWS.md /inst/path: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *_bak* -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/logo.png -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/favicon.ico -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/man/figures/logo.png -------------------------------------------------------------------------------- /docs/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/favicon-16x16.png -------------------------------------------------------------------------------- /docs/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/favicon-32x32.png -------------------------------------------------------------------------------- /docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /docs/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /docs/reference/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/docs/reference/figures/logo.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/favicon-96x96.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /pkgdown/favicon/web-app-manifest-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/web-app-manifest-192x192.png -------------------------------------------------------------------------------- /pkgdown/favicon/web-app-manifest-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swarm-lab/ROpenCVLite/HEAD/pkgdown/favicon/web-app-manifest-512x512.png -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://swarm-lab.github.io/ROpenCVLite/ 2 | 3 | template: 4 | bootstrap: 5 5 | bootswatch: simplex 6 | 7 | authors: 8 | Simon Garnier: 9 | href: https://www.theswarmlab.com 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | src/*.o 6 | src/*.so 7 | src/*.dll 8 | inst/opencv 9 | inst/tmp 10 | src/opencv-*.zip 11 | src/opencv-*/ 12 | .DS_Store 13 | old 14 | *.insyncdl 15 | docs 16 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(OpenCVPath) 4 | export(defaultOpenCVPath) 5 | export(installOpenCV) 6 | export(isCmakeInstalled) 7 | export(isOpenCVInstalled) 8 | export(opencvConfig) 9 | export(opencvVersion) 10 | export(removeOpenCV) 11 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | informational: true 10 | patch: 11 | default: 12 | target: auto 13 | threshold: 1% 14 | informational: true 15 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | LICENSE 4 | docs 5 | _pkgdown.yaml 6 | index.Rmd 7 | logo.* 8 | pkgdown 9 | old 10 | cran-comments.md 11 | ^CRAN-RELEASE$ 12 | ^\.github$ 13 | revdep 14 | ^CRAN-SUBMISSION$ 15 | ^_pkgdown\.yml$ 16 | ^docs$ 17 | ^pkgdown$ 18 | ^codecov\.yml$ 19 | test_install 20 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 3.6.4 2 | pkgdown: 2.1.1 3 | pkgdown_sha: ~ 4 | articles: 5 | install: install.html 6 | usage: usage.html 7 | last_built: 2025-05-02T10:25Z 8 | urls: 9 | reference: https://swarm-lab.github.io/ROpenCVLite/reference 10 | article: https://swarm-lab.github.io/ROpenCVLite/articles 11 | -------------------------------------------------------------------------------- /R/ROpenCVLite.R: -------------------------------------------------------------------------------- 1 | #' @title ROpenCVLite: A package to install OpenCV within R 2 | #' 3 | #' @description This is a utility package that installs OpenCV within R for use 4 | #' by other packages. This Lite version does not contain any of the contributed 5 | #' modules of OpenCV. 6 | #' 7 | #' @author Simon Garnier, \email{garnier@@njit.edu} 8 | "_PACKAGE" 9 | #> [1] "_PACKAGE" -------------------------------------------------------------------------------- /man/removeOpenCV.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/install.R 3 | \name{removeOpenCV} 4 | \alias{removeOpenCV} 5 | \title{Remove OpenCV} 6 | \usage{ 7 | removeOpenCV() 8 | } 9 | \value{ 10 | A boolean. 11 | } 12 | \description{ 13 | This function removes OpenCV from the system. 14 | } 15 | \examples{ 16 | \dontrun{ 17 | installOpenCV() 18 | } 19 | 20 | } 21 | \author{ 22 | Simon Garnier, \email{garnier@njit.edu} 23 | } 24 | -------------------------------------------------------------------------------- /man/isCmakeInstalled.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{isCmakeInstalled} 4 | \alias{isCmakeInstalled} 5 | \title{Check Cmake Installation} 6 | \usage{ 7 | isCmakeInstalled() 8 | } 9 | \value{ 10 | A boolean. 11 | } 12 | \description{ 13 | This function checks that Cmake is installed on the system. 14 | } 15 | \examples{ 16 | isCmakeInstalled() 17 | 18 | } 19 | \author{ 20 | Simon Garnier, \email{garnier@njit.edu} 21 | } 22 | -------------------------------------------------------------------------------- /man/OpenCVPath.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{OpenCVPath} 4 | \alias{OpenCVPath} 5 | \title{Install Location of OpenCV} 6 | \usage{ 7 | OpenCVPath() 8 | } 9 | \value{ 10 | A character string. 11 | } 12 | \description{ 13 | This function returns the location at which OpenCV is installed. 14 | } 15 | \examples{ 16 | \dontrun{ 17 | OpenCVPath() 18 | } 19 | 20 | } 21 | \author{ 22 | Simon Garnier, \email{garnier@njit.edu} 23 | } 24 | -------------------------------------------------------------------------------- /man/isOpenCVInstalled.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{isOpenCVInstalled} 4 | \alias{isOpenCVInstalled} 5 | \title{Check OpenCV Installation} 6 | \usage{ 7 | isOpenCVInstalled() 8 | } 9 | \value{ 10 | A boolean. 11 | } 12 | \description{ 13 | This function checks that OpenCV is installed and accessible. 14 | } 15 | \examples{ 16 | isOpenCVInstalled() 17 | 18 | } 19 | \author{ 20 | Simon Garnier, \email{garnier@njit.edu} 21 | } 22 | -------------------------------------------------------------------------------- /ROpenCVLite.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | StripTrailingWhitespace: Yes 16 | 17 | BuildType: Package 18 | PackageUseDevtools: Yes 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | PackageCheckArgs: --as-cran 21 | PackageRoxygenize: rd,collate,namespace,vignette 22 | -------------------------------------------------------------------------------- /man/opencvVersion.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{opencvVersion} 4 | \alias{opencvVersion} 5 | \title{OpenCV Version} 6 | \usage{ 7 | opencvVersion() 8 | } 9 | \value{ 10 | A character string. 11 | } 12 | \description{ 13 | This function determines the version of OpenCV installed within 14 | R. 15 | } 16 | \examples{ 17 | if (isOpenCVInstalled()) { 18 | opencvVersion() 19 | } 20 | 21 | } 22 | \author{ 23 | Simon Garnier, \email{garnier@njit.edu} 24 | } 25 | -------------------------------------------------------------------------------- /pkgdown/favicon/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/web-app-manifest-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png", 9 | "purpose": "maskable" 10 | }, 11 | { 12 | "src": "/web-app-manifest-512x512.png", 13 | "sizes": "512x512", 14 | "type": "image/png", 15 | "purpose": "maskable" 16 | } 17 | ], 18 | "theme_color": "#ffffff", 19 | "background_color": "#ffffff", 20 | "display": "standalone" 21 | } -------------------------------------------------------------------------------- /man/defaultOpenCVPath.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/install.R 3 | \name{defaultOpenCVPath} 4 | \alias{defaultOpenCVPath} 5 | \title{Default Install Location of OpenCV} 6 | \usage{ 7 | defaultOpenCVPath() 8 | } 9 | \value{ 10 | A character string. 11 | } 12 | \description{ 13 | This function returns the location at which OpenCV should be 14 | installed by default. 15 | } 16 | \examples{ 17 | \dontrun{ 18 | defaultOpenCVPath() 19 | } 20 | 21 | } 22 | \author{ 23 | Simon Garnier, \email{garnier@njit.edu} 24 | } 25 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite ROpenCVLite in publications use:") 2 | 3 | year <- sub("-.*", "", meta$Date) 4 | note <- sprintf("R package version %s", meta$Version) 5 | 6 | bibentry( 7 | bibtype = "Manual", 8 | title = "{ROpenCVLite} - Helper package for installing OpenCV with R", 9 | author = "Simon Garnier and John Muschelli", 10 | journal = "", 11 | year = year, 12 | volume = "", 13 | number = "", 14 | pages = "", 15 | note = note, 16 | url = "https://swarm-lab.github.io/ROpenCVLite/", 17 | textVersion = paste0( 18 | "Simon Garnier and John Muschelli (", year, "). ROpenCVLite - Helper package for installing OpenCV with R. ", note, "." 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /man/ROpenCVLite-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ROpenCVLite.R 3 | \docType{package} 4 | \name{ROpenCVLite-package} 5 | \alias{ROpenCVLite} 6 | \alias{ROpenCVLite-package} 7 | \title{ROpenCVLite: A package to install OpenCV within R} 8 | \description{ 9 | This is a utility package that installs OpenCV within R for use 10 | by other packages. This Lite version does not contain any of the contributed 11 | modules of OpenCV. 12 | } 13 | \seealso{ 14 | Useful links: 15 | \itemize{ 16 | \item \url{https://swarm-lab.github.io/ROpenCVLite/} 17 | \item \url{https://github.com/swarm-lab/ROpenCVLite} 18 | \item Report bugs at \url{https://github.com/swarm-lab/ROpenCVLite/issues} 19 | } 20 | 21 | } 22 | \author{ 23 | Simon Garnier, \email{garnier@njit.edu} 24 | } 25 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | if ! cmake_loc="$(type 'cmake')" || [ -z cmake_loc ] 2 | then 3 | echo "" 4 | echo "------------------ CMAKE NOT FOUND --------------------" 5 | echo "" 6 | echo "CMake was not found on the PATH. Please install CMake:" 7 | echo "" 8 | echo " - installr::install.cmake() (Windows; inside the R console)" 9 | echo " - yum install cmake (Fedora/CentOS; inside a terminal)" 10 | echo " - apt install cmake (Debian/Ubuntu; inside a terminal)." 11 | echo " - brew install cmake (MacOS; inside a terminal with Homebrew)" 12 | echo " - port install cmake (MacOS; inside a terminal with MacPorts)" 13 | echo "" 14 | echo "Alternatively install CMake from: " 15 | echo "" 16 | echo "-------------------------------------------------------" 17 | echo "" 18 | fi -------------------------------------------------------------------------------- /configure.win: -------------------------------------------------------------------------------- 1 | if ! cmake_loc="$(type 'cmake')" || [ -z cmake_loc ] 2 | then 3 | echo "" 4 | echo "------------------ CMAKE NOT FOUND --------------------" 5 | echo "" 6 | echo "CMake was not found on the PATH. Please install CMake:" 7 | echo "" 8 | echo " - installr::install.cmake() (Windows; inside the R console)" 9 | echo " - yum install cmake (Fedora/CentOS; inside a terminal)" 10 | echo " - apt install cmake (Debian/Ubuntu; inside a terminal)." 11 | echo " - brew install cmake (MacOS; inside a terminal with Homebrew)" 12 | echo " - port install cmake (MacOS; inside a terminal with MacPorts)" 13 | echo "" 14 | echo "Alternatively install CMake from: " 15 | echo "" 16 | echo "-------------------------------------------------------" 17 | echo "" 18 | fi -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | 3 | * local M4 OS X 14.5, R 4.1.3, 4.2.3, 4.3.2, 4.4.3, 4.5, R devel 4 | * local Windows 11, R R 4.1.3, 4.2.3, 4.3.2, 4.4.3, 4.5, R devel 5 | * local Ubuntu 24.04, R 4.1.3, 4.2.3, 4.3.2, 4.4.3, 4.5, R devel 6 | * Github Actions "windows-latest (release)" 7 | * Github Actions "macOS-latest (release)" 8 | * Github Actions "ubuntu-latest (release)" 9 | * Github Actions "ubuntu-latest (devel)" 10 | * Github Actions "ubuntu-latest (oldrel-1)" 11 | * win-builder.r-project.org 12 | 13 | ## R CMD check results 14 | 15 | * N/A. 16 | 17 | ## Downstream dependencies 18 | 19 | There are currently no downstream dependencies for this package. 20 | 21 | ## CRAN team comments 22 | 23 | * 1 NOTE: Version jumps in minor (submitted: 4.110.0, existing: 4.90.2) 24 | 25 | This is normal. Version 4.100.0 was skipped because I chose to skip the upgrade 26 | to OpenCV 4.10.0 and move directly to OpenCV 4.11.0. -------------------------------------------------------------------------------- /man/opencvConfig.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{opencvConfig} 4 | \alias{opencvConfig} 5 | \title{C/C++ configuration options} 6 | \usage{ 7 | opencvConfig(output = "libs", arch = NULL) 8 | } 9 | \arguments{ 10 | \item{output}{Either 'libs' for library configuration options or 'cflags' for 11 | C/C++ configuration flags.} 12 | 13 | \item{arch}{architecture relevant for Windows. If \code{NULL}, then 14 | \code{R.version$arch} will be used.} 15 | } 16 | \value{ 17 | A concatenated character string (with \code{\link{cat}}) of the 18 | configuration options. 19 | } 20 | \description{ 21 | This function returns the configuration options for compiling 22 | C/C++-based packages against OpenCV installed by \code{\link{ROpenCVLite}}. 23 | } 24 | \examples{ 25 | \dontrun{ 26 | if (isOpenCVInstalled()) { 27 | opencvConfig() 28 | opencvConfig(output = "cflags") 29 | opencvConfig(arch = R.version$arch) 30 | } 31 | } 32 | 33 | } 34 | \author{ 35 | Simon Garnier, \email{garnier@njit.edu} 36 | } 37 | -------------------------------------------------------------------------------- /vignettes/install.R: -------------------------------------------------------------------------------- 1 | ## ----eval=FALSE--------------------------------------------------------------- 2 | # if (!require("installr")) 3 | # install.packages("installr") 4 | # 5 | # installr::install.Rtools() 6 | 7 | ## ----eval=FALSE--------------------------------------------------------------- 8 | # if (!require("installr")) 9 | # install.packages("installr") 10 | # 11 | # installr::install.CMake() 12 | 13 | ## ----eval=FALSE--------------------------------------------------------------- 14 | # install.packages("devtools") 15 | 16 | ## ----eval=FALSE--------------------------------------------------------------- 17 | # install.packages("ROpenCVLite") 18 | 19 | ## ----eval=FALSE--------------------------------------------------------------- 20 | # devtools::install_github("swarm-lab/ROpenCVLite") 21 | 22 | ## ----eval=FALSE--------------------------------------------------------------- 23 | # library(ROpenCVLite) 24 | 25 | ## ----eval=FALSE--------------------------------------------------------------- 26 | # ROpenCVLite::installOpenCV() 27 | 28 | -------------------------------------------------------------------------------- /man/installOpenCV.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/install.R 3 | \name{installOpenCV} 4 | \alias{installOpenCV} 5 | \title{Install OpenCV} 6 | \usage{ 7 | installOpenCV(install_path = defaultOpenCVPath(), batch = FALSE) 8 | } 9 | \arguments{ 10 | \item{install_path}{A character string indicating the location at which 11 | OpenCV should be installed. By default, it is the value returned by 12 | \code{\link{defaultOpenCVPath}}.} 13 | 14 | \item{batch}{A boolean indicating whether to skip (\code{TRUE}) or not 15 | (\code{FALSE}, the default) the interactive installation dialog. This is 16 | useful when OpenCV needs to be installed in a non-interactive environment 17 | (e.g., during a batch installation on a server).} 18 | } 19 | \value{ 20 | A boolean. 21 | } 22 | \description{ 23 | This function attempts to download, compile and install OpenCV 24 | on the system. This process will take several minutes. 25 | } 26 | \examples{ 27 | \dontrun{ 28 | installOpenCV() 29 | } 30 | 31 | } 32 | \author{ 33 | Simon Garnier, \email{garnier@njit.edu} 34 | } 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea to improve ROpenCVLite 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 21 | 22 | **Is your feature request related to a problem? Please describe.** 23 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 24 | 25 | **Describe the solution you'd like** 26 | A clear and concise description of what you want to happen. 27 | 28 | **Describe alternatives you've considered** 29 | A clear and concise description of any alternative solutions or features you've considered. 30 | 31 | **Additional context** 32 | Add any other context or screenshots about the feature request here. 33 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: ROpenCVLite 2 | Type: Package 3 | Title: Helper Package for Installing OpenCV with R 4 | Version: 4.110.0 5 | Date: 2025-05-01 6 | Authors@R: c( 7 | person("Simon", "Garnier", email = "garnier@njit.edu", role = c("aut", "cre"), 8 | comment = c(ORCID = "0000-0002-3886-3974")), 9 | person("Muschelli", "John", email = "muschellij2@gmail.com", role = c("ctb")) 10 | ) 11 | Maintainer: Simon Garnier 12 | Description: Installs 'OpenCV' for use by other packages. 'OpenCV' 13 | is library of programming functions mainly aimed at real-time computer 14 | vision. This 'Lite' version installs the stable base version of 'OpenCV' and 15 | some of its experimental externally contributed modules. It does not provide 16 | R bindings directly. 17 | License: GPL-3 18 | LazyData: TRUE 19 | Imports: 20 | utils, 21 | parallel 22 | SystemRequirements: 23 | cmake 24 | RoxygenNote: 7.3.2 25 | Biarch: false 26 | Encoding: UTF-8 27 | Depends: 28 | R (>= 4.0.0) 29 | Suggests: 30 | covr, 31 | knitr, 32 | rmarkdown 33 | VignetteBuilder: knitr 34 | URL: https://swarm-lab.github.io/ROpenCVLite/, 35 | https://github.com/swarm-lab/ROpenCVLite 36 | BugReports: https://github.com/swarm-lab/ROpenCVLite/issues 37 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | name: pkgdown 13 | 14 | jobs: 15 | pkgdown: 16 | runs-on: ubuntu-latest 17 | # Only restrict concurrency for non-PR jobs 18 | concurrency: 19 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 20 | env: 21 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 22 | steps: 23 | - uses: actions/checkout@v3 24 | 25 | - uses: r-lib/actions/setup-pandoc@v2 26 | 27 | - uses: r-lib/actions/setup-r@v2 28 | with: 29 | use-public-rspm: true 30 | 31 | - uses: r-lib/actions/setup-r-dependencies@v2 32 | with: 33 | extra-packages: any::pkgdown, local::. 34 | needs: website 35 | 36 | - name: Build site 37 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 38 | shell: Rscript {0} 39 | 40 | - name: Deploy to GitHub pages 🚀 41 | if: github.event_name != 'pull_request' 42 | uses: JamesIves/github-pages-deploy-action@v4.4.1 43 | with: 44 | clean: false 45 | branch: gh-pages 46 | folder: docs 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report to help ROpenCVLite improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 20 | 21 | **Describe the bug** 22 | A clear and concise description of what the bug is. 23 | 24 | **To Reproduce** 25 | Steps to reproduce the behavior 26 | 27 | **Expected behavior** 28 | A clear and concise description of what you expected to happen. 29 | 30 | **Screenshots** 31 | If applicable, add screenshots to help explain your problem. 32 | 33 | **Computer (please complete the following information):** 34 | - Operating system: [e.g. MacOS] 35 | - Version [e.g. 11.2.1] 36 | 37 | **R (please complete the following information):** 38 | - R version: [e.g. 4.0.4] 39 | - ROpenCVLite version: [e.g. 4.50.0] 40 | - Cmake version: [e.g. 3.19.1] 41 | - Rtools version (Windows only): [e.g. 4.0] 42 | 43 | **Additional context** 44 | Add any other context about the problem here. 45 | -------------------------------------------------------------------------------- /test_install/test_script.R: -------------------------------------------------------------------------------- 1 | # Cleanup ----------------------------------------------------------------- 2 | tryCatch({ 3 | remove.packages("Rvision") 4 | }, error = function(e) cat("Rvision is not installed. Nothing to remove.")) 5 | 6 | tryCatch({ 7 | remove.packages("ROpenCVLite") 8 | }, error = function(e) cat("ROpenCVLite is not installed. Nothing to remove.")) 9 | 10 | 11 | # Dependencies ------------------------------------------------------------ 12 | if (!requireNamespace("utils", quietly = TRUE)) { 13 | install.packages("utils") 14 | } 15 | 16 | if (!requireNamespace("pkgbuild", quietly = TRUE)) { 17 | install.packages("pkgbuild") 18 | } 19 | 20 | if (!requireNamespace("parallel", quietly = TRUE)) { 21 | install.packages("parallel") 22 | } 23 | 24 | if (!requireNamespace("remotes", quietly = TRUE)) { 25 | install.packages("remotes") 26 | } 27 | 28 | 29 | # Testing ----------------------------------------------------------------- 30 | old_timeout <- getOption("timeout") 31 | options(timeout = 240) 32 | 33 | tryCatch({ 34 | install.packages(".", type = "source", repos = NULL, 35 | INSTALL_opts = c("--preclean", "--no-multiarch", "--with-keep.source")) 36 | 37 | ROpenCVLite::installOpenCV(batch = TRUE) 38 | 39 | remotes::install_github("swarm-lab/Rvision", force = TRUE, INSTALL_opts = "--no-multiarch") 40 | 41 | a <- Rvision::zeros(100, 100) 42 | Rvision::changeBitDepth(a, "32F", 1 / 255, target = "self") 43 | 44 | cat("Success") 45 | }, error = function(e) cat("Failure")) 46 | 47 | 48 | options(timeout = old_timeout) -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master, develop] 6 | pull_request: 7 | branches: [main, master, develop] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macos-latest, r: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'oldrel-1'} 26 | 27 | env: 28 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 29 | R_KEEP_PKG_SOURCE: yes 30 | 31 | steps: 32 | - uses: actions/checkout@v3 33 | 34 | - uses: r-lib/actions/setup-pandoc@v2 35 | 36 | - uses: r-lib/actions/setup-r@v2 37 | with: 38 | r-version: ${{ matrix.config.r }} 39 | http-user-agent: ${{ matrix.config.http-user-agent }} 40 | use-public-rspm: true 41 | 42 | - uses: r-lib/actions/setup-r-dependencies@v2 43 | with: 44 | extra-packages: any::rcmdcheck 45 | needs: check 46 | 47 | - uses: r-lib/actions/check-r-package@v2 48 | with: 49 | upload-snapshots: true 50 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | https://swarm-lab.github.io/ROpenCVLite/404.html 3 | https://swarm-lab.github.io/ROpenCVLite/LICENSE-text.html 4 | https://swarm-lab.github.io/ROpenCVLite/articles/index.html 5 | https://swarm-lab.github.io/ROpenCVLite/articles/install.html 6 | https://swarm-lab.github.io/ROpenCVLite/articles/usage.html 7 | https://swarm-lab.github.io/ROpenCVLite/authors.html 8 | https://swarm-lab.github.io/ROpenCVLite/index.html 9 | https://swarm-lab.github.io/ROpenCVLite/news/index.html 10 | https://swarm-lab.github.io/ROpenCVLite/reference/OpenCVPath.html 11 | https://swarm-lab.github.io/ROpenCVLite/reference/ROpenCVLite-package.html 12 | https://swarm-lab.github.io/ROpenCVLite/reference/defaultOpenCVPath.html 13 | https://swarm-lab.github.io/ROpenCVLite/reference/index.html 14 | https://swarm-lab.github.io/ROpenCVLite/reference/installOpenCV.html 15 | https://swarm-lab.github.io/ROpenCVLite/reference/isCmakeInstalled.html 16 | https://swarm-lab.github.io/ROpenCVLite/reference/isOpenCVInstalled.html 17 | https://swarm-lab.github.io/ROpenCVLite/reference/opencvConfig.html 18 | https://swarm-lab.github.io/ROpenCVLite/reference/opencvVersion.html 19 | https://swarm-lab.github.io/ROpenCVLite/reference/removeOpenCV.html 20 | 21 | 22 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: test-coverage 10 | 11 | jobs: 12 | test-coverage: 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | 20 | - uses: r-lib/actions/setup-r@v2 21 | with: 22 | use-public-rspm: true 23 | 24 | - name: Install Linux dependencies 25 | if: runner.os == 'Linux' 26 | run: | 27 | sudo apt update -y 28 | sudo apt install -y libavfilter-dev 29 | 30 | - name: Install Mac dependencies 31 | if: runner.os == 'macOS' 32 | run: brew install ffmpeg 33 | 34 | - uses: r-lib/actions/setup-r-dependencies@v2 35 | with: 36 | extra-packages: any::covr 37 | needs: coverage 38 | 39 | - name: Test coverage 40 | run: | 41 | covr::codecov( 42 | quiet = FALSE, 43 | clean = FALSE, 44 | install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") 45 | ) 46 | shell: Rscript {0} 47 | 48 | - name: Show testthat output 49 | if: always() 50 | run: | 51 | ## -------------------------------------------------------------------- 52 | find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true 53 | shell: bash 54 | 55 | - name: Upload test results 56 | if: failure() 57 | uses: actions/upload-artifact@v4 58 | with: 59 | name: coverage-test-failures 60 | path: ${{ runner.temp }}/package 61 | -------------------------------------------------------------------------------- /test_install/test_install.R: -------------------------------------------------------------------------------- 1 | # Dependencies ------------------------------------------------------------ 2 | if (!requireNamespace("processx", quietly = TRUE)) { 3 | install.packages("processx") 4 | } 5 | 6 | if (!requireNamespace("progress", quietly = TRUE)) { 7 | install.packages("progress") 8 | } 9 | 10 | 11 | # Environment ------------------------------------------------------------- 12 | library(processx) 13 | library(progress) 14 | 15 | callback <- function(line, proc) { 16 | r <- regexpr("\\[(.*?)%\\]", line) 17 | 18 | if (r[1] == 1 & !pb$finished) { 19 | pb$update(as.numeric(gsub("\\[(.*?)%\\]", "\\1", regmatches(line, r))) / 100) 20 | } 21 | } 22 | 23 | 24 | # Script ------------------------------------------------------------------ 25 | res <- run("rig", c("list", "--plain"), echo_cmd = TRUE, stderr_to_stdout = TRUE, 26 | windows_verbatim_args = TRUE) 27 | v <- strsplit(res$stdout, c("\n", "\r\n"))[[1]] 28 | 29 | env_par <- NULL 30 | if (.Platform$OS.type == "windows") { 31 | env_par <- ps::ps_environ(ps::ps_parent(ps::ps_handle())) 32 | attr(env_par, "class") <- NULL 33 | env_par <- env_par[nchar(names(env_par)) > 0] 34 | } 35 | 36 | for (r in v) { 37 | pb <- progress_bar$new(format = " Compiling [:bar] :percent", clear = FALSE) 38 | 39 | res <- run("rig", c("run", paste0("-r", r), "-ftest_install/test_script.R"), 40 | echo_cmd = TRUE, spinner = TRUE, stderr_to_stdout = TRUE, 41 | windows_verbatim_args = TRUE, stdout_line_callback = callback, 42 | env = env_par) 43 | 44 | pb$terminate() 45 | 46 | stdout <- strsplit(res$stdout, c("\n", "\r\n"))[[1]] 47 | 48 | if (stdout[length(stdout)] != "Success") { 49 | con <- file(paste0("test_install/log_", r, ".txt"), "wb") 50 | writeBin(paste(stdout, collapse = "\n"), con) 51 | close(con) 52 | } 53 | 54 | cat(paste0("R ", r, ": ", stdout[length(stdout)], "\n\n")) 55 | } 56 | -------------------------------------------------------------------------------- /logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 28 | 29 | 30 | 33 | 34 | 35 | ROpenCV 36 | Lite 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 28 | 29 | 30 | 33 | 34 | 35 | ROpenCV 36 | Lite 37 | 38 | 39 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .onLoad <- function(lib, pkg) { 2 | if (.Platform$OS.type == "windows") { 3 | pkgPath <- find.package("ROpenCVLite") 4 | installPath <- gsub("ROpenCVLite", "", pkgPath) 5 | opath <- Sys.getenv("PATH") 6 | if (.Platform$r_arch == "i386") { 7 | binPath <- "/opencv/x86/mingw/bin" 8 | } else { 9 | binPath <- "/opencv/x64/mingw/bin" 10 | } 11 | binPath <- utils::shortPathName(paste0(installPath, binPath)) 12 | Sys.setenv(PATH = paste(binPath, opath, sep = ";")) 13 | } 14 | 15 | if (Sys.info()[["sysname"]] == "Linux") { 16 | pkgPath <- find.package("ROpenCVLite") 17 | installPath <- gsub("ROpenCVLite", "", pkgPath) 18 | libPath <- paste0(installPath, "/opencv/lib") 19 | Sys.setenv(LD_LIBRARY_PATH = paste0(Sys.getenv("LD_LIBRARY_PATH"), ":", libPath)) 20 | } 21 | } 22 | 23 | .onAttach <- function(lib, pkg) { 24 | if (.Platform$OS.type == "windows") { 25 | pkgPath <- find.package("ROpenCVLite") 26 | installPath <- gsub("ROpenCVLite", "", pkgPath) 27 | opath <- Sys.getenv("PATH") 28 | if (.Platform$r_arch == "i386") { 29 | binPath <- "/opencv/x86/mingw/bin" 30 | } else { 31 | binPath <- "/opencv/x64/mingw/bin" 32 | } 33 | binPath <- utils::shortPathName(paste0(installPath, binPath)) 34 | Sys.setenv(PATH = paste(binPath, opath, sep = ";")) 35 | } 36 | 37 | if (Sys.info()[["sysname"]] == "Linux") { 38 | pkgPath <- find.package("ROpenCVLite") 39 | installPath <- gsub("ROpenCVLite", "", pkgPath) 40 | libPath <- paste0(installPath, "/opencv/lib") 41 | Sys.setenv(LD_LIBRARY_PATH = paste0(Sys.getenv("LD_LIBRARY_PATH"), ":", libPath)) 42 | } 43 | 44 | if (!ROpenCVLite::isOpenCVInstalled()) { 45 | installOpenCV() 46 | } else { 47 | pkgVersion <- paste0(strsplit(as.character(utils::packageVersion("ROpenCVLite")), "\\.")[[1]][1:2], collapse = "") 48 | cvVersion <- gsub("\\D+", "", ROpenCVLite::opencvVersion()) 49 | 50 | if (!is.null(pkgVersion)) { 51 | if (pkgVersion != cvVersion) { 52 | installOpenCV() 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /vignettes/usage.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | author: "Simon Garnier" 3 | title: "2 - Using ROpenCVLite" 4 | output: rmarkdown::html_vignette 5 | vignette: > 6 | %\VignetteIndexEntry{2 - Using ROpenCVLite} 7 | %\VignetteEngine{knitr::rmarkdown} 8 | %\VignetteEncoding{UTF-8} 9 | --- 10 | 11 | The goal of [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) is to 12 | enable developers to create their own packages for [`R`](https://cran.r-project.org) 13 | based on [`OpenCV`](https://opencv.org/). Computer vision is just one of the 14 | possible applications for [`OpenCV`](https://opencv.org/). It can do many more 15 | things, such as fast matrix processing and GPU computing. By providing access to 16 | a standardized installation of [`OpenCV`](https://opencv.org/), we hope to help 17 | the [`R`](https://cran.r-project.org) community take advantage of this fantastic 18 | library. 19 | 20 | --- 21 | 22 | ## Create a package using [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) 23 | 24 | Follow these steps to configure your package for [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite): 25 | 26 | 1. Set [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) as a dependency 27 | in the DESCRIPTION file of your package. 28 | 2. Use the [`opencvConfig` function](https://swarm-lab.github.io/ROpenCVLite/reference/opencvConfig.html) 29 | provided with [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) to: 30 | + set the `PKG_LIBS` value of the Makevars and Makevars.win 31 | files of your package (using `opencvConfig("libs")`). 32 | + set the `PKG_CPPFLAGS` () value of the Makevars and Makevars.win 33 | files of your package (using `opencvConfig("cflags")`). 34 | 35 | You can find an example of how to set up your package with 36 | [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) in our 37 | [Rvision](https://github.com/swarm-lab/Rvision) package: 38 | 39 | * [DESCRIPTION](https://github.com/swarm-lab/Rvision/blob/master/DESCRIPTION) 40 | * [Makevars](https://github.com/swarm-lab/Rvision/blob/master/src/Makevars) 41 | * [Makevars.win](https://github.com/swarm-lab/Rvision/blob/master/src/Makevars.win) 42 | -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 25 | 26 | 27 | 30 | 31 | 32 | ROpenCV 33 | Lite 34 | 35 | -------------------------------------------------------------------------------- /.github/workflows/rhub.yaml: -------------------------------------------------------------------------------- 1 | # R-hub's generic GitHub Actions workflow file. It's canonical location is at 2 | # https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml 3 | # You can update this file to a newer version using the rhub2 package: 4 | # 5 | # rhub::rhub_setup() 6 | # 7 | # It is unlikely that you need to modify this file manually. 8 | 9 | name: R-hub 10 | run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" 11 | 12 | on: 13 | workflow_dispatch: 14 | inputs: 15 | config: 16 | description: 'A comma separated list of R-hub platforms to use.' 17 | type: string 18 | default: 'linux,windows,macos' 19 | name: 20 | description: 'Run name. You can leave this empty now.' 21 | type: string 22 | id: 23 | description: 'Unique ID. You can leave this empty now.' 24 | type: string 25 | 26 | jobs: 27 | 28 | setup: 29 | runs-on: ubuntu-latest 30 | outputs: 31 | containers: ${{ steps.rhub-setup.outputs.containers }} 32 | platforms: ${{ steps.rhub-setup.outputs.platforms }} 33 | 34 | steps: 35 | # NO NEED TO CHECKOUT HERE 36 | - uses: r-hub/actions/setup@v1 37 | with: 38 | config: ${{ github.event.inputs.config }} 39 | id: rhub-setup 40 | 41 | linux-containers: 42 | needs: setup 43 | if: ${{ needs.setup.outputs.containers != '[]' }} 44 | runs-on: ubuntu-latest 45 | name: ${{ matrix.config.label }} 46 | strategy: 47 | fail-fast: false 48 | matrix: 49 | config: ${{ fromJson(needs.setup.outputs.containers) }} 50 | container: 51 | image: ${{ matrix.config.container }} 52 | 53 | steps: 54 | - uses: r-hub/actions/checkout@v1 55 | - uses: r-hub/actions/platform-info@v1 56 | with: 57 | token: ${{ secrets.RHUB_TOKEN }} 58 | job-config: ${{ matrix.config.job-config }} 59 | - uses: r-hub/actions/setup-deps@v1 60 | with: 61 | token: ${{ secrets.RHUB_TOKEN }} 62 | job-config: ${{ matrix.config.job-config }} 63 | - uses: r-hub/actions/run-check@v1 64 | with: 65 | token: ${{ secrets.RHUB_TOKEN }} 66 | job-config: ${{ matrix.config.job-config }} 67 | 68 | other-platforms: 69 | needs: setup 70 | if: ${{ needs.setup.outputs.platforms != '[]' }} 71 | runs-on: ${{ matrix.config.os }} 72 | name: ${{ matrix.config.label }} 73 | strategy: 74 | fail-fast: false 75 | matrix: 76 | config: ${{ fromJson(needs.setup.outputs.platforms) }} 77 | 78 | steps: 79 | - uses: r-hub/actions/checkout@v1 80 | - uses: r-hub/actions/setup-r@v1 81 | with: 82 | job-config: ${{ matrix.config.job-config }} 83 | token: ${{ secrets.RHUB_TOKEN }} 84 | - uses: r-hub/actions/platform-info@v1 85 | with: 86 | token: ${{ secrets.RHUB_TOKEN }} 87 | job-config: ${{ matrix.config.job-config }} 88 | - uses: r-hub/actions/setup-deps@v1 89 | with: 90 | job-config: ${{ matrix.config.job-config }} 91 | token: ${{ secrets.RHUB_TOKEN }} 92 | - uses: r-hub/actions/run-check@v1 93 | with: 94 | job-config: ${{ matrix.config.job-config }} 95 | token: ${{ secrets.RHUB_TOKEN }} 96 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | Articles • ROpenCVLite 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
37 | 38 |
39 |

All vignettes

40 |
41 | 42 |
1 - Installing ROpenCVLite
43 |
44 |
2 - Using ROpenCVLite
45 |
46 |
47 |
48 | 49 | 50 |
53 | 54 | 57 | 58 |
59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ROpenCVLite - Install OpenCV with R 2 | 3 | 4 | [![R-CMD-check](https://github.com/swarm-lab/ROpenCVLite/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/swarm-lab/ROpenCVLite/actions/workflows/R-CMD-check.yaml) 5 | [![Codecov test coverage](https://codecov.io/gh/swarm-lab/ROpenCVLite/branch/master/graph/badge.svg)](https://app.codecov.io/gh/swarm-lab/ROpenCVLite?branch=master) 6 | [![CRAN status](https://www.r-pkg.org/badges/version/ROpenCVLite)](https://CRAN.R-project.org/package=ROpenCVLite) 7 | [![CRANLOGS downloads](https://cranlogs.r-pkg.org/badges/ROpenCVLite)](https://cran.r-project.org/package=ROpenCVLite) 8 | 9 | 10 | 11 | ## Description 12 | 13 | [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) is a utility package 14 | that installs [`OpenCV`](https://opencv.org/) within [`R`](https://cran.r-project.org) 15 | for use by other packages. This package is not a wrapper around [`OpenCV`](https://opencv.org/) 16 | (it does not provide access to [`OpenCV`](https://opencv.org/) functions in R), 17 | not is it a computer vision package for [`R`](https://cran.r-project.org). All 18 | it does is compiling and installing [`OpenCV`](https://opencv.org/) within your 19 | [`R`](https://cran.r-project.org) installation so that other packages can easily 20 | find it and compile against it. 21 | 22 | --- 23 | 24 | ## Quick start guides 25 | 26 | 1. [Installing ROpenCVLite](https://swarm-lab.github.io/ROpenCVLite/articles/install.html) 27 | 2. [Using ROpenCVLite](https://swarm-lab.github.io/ROpenCVLite/articles/usage.html) 28 | 3. [Function documentation](https://swarm-lab.github.io/ROpenCVLite/reference/) 29 | 30 | --- 31 | 32 | ## FAQ 33 | 34 | ### What is OpenCV? 35 | 36 | [`OpenCV`](https://opencv.org/) is one of the most - if not the most - popular 37 | and efficient open-source computer vision library available today. If you want 38 | to develop fast video processing software or implement real time computer vision 39 | algorithms, you pretty much have to use [`OpenCV`](https://opencv.org/) nowadays. 40 | 41 | ### Why is [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) necessary? 42 | 43 | There are no computer vision package available for [`R`](https://cran.r-project.org) 44 | currently. There are some very good image processing packages (see 45 | [imager](https://dahtah.github.io/imager/) for instance) but none of them can 46 | handle fast processing of large videos. 47 | 48 | The goal of [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) is to 49 | promote the development of efficient computer vision packages for [`R`](https://cran.r-project.org) 50 | based on [`OpenCV`](https://opencv.org/). [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) 51 | facilitates the installation of [`OpenCV`](https://opencv.org/) in a convenient 52 | location for other packages to find it and compile against it. 53 | 54 | ### Couldn't you just ship [`OpenCV`](https://opencv.org/)'s binaries with your package? 55 | 56 | Yes, but... it is fairly difficult to ship binary files compiled against 57 | [`OpenCV`](https://opencv.org/) that will work for sure on someone else's computer. 58 | It is not [`OpenCV`](https://opencv.org/)'s fault; it is because there are so many 59 | video formats and standards for peripherals out there that nobody can be certain 60 | what interfaces and libraries will be available on anyone's computer to grab 61 | images from videos and camera streams. The least worst solution for developers 62 | is therefore to make sure that there is a copy of [`OpenCV`](https://opencv.org/) 63 | on each user's computer that has been compiled taking into account the 64 | specificities of said computer. 65 | 66 | HOWEVER... 67 | 68 | [`OpenCV`](https://opencv.org/) is notoriously difficult to compile and install 69 | from scratch, especially for people without experience with low level languages. 70 | This is where [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) come into 71 | play. This package tries as much as possible to cleanly compile [`OpenCV`](https://opencv.org/) 72 | and to install it in a standardized location that all [`R`](https://cran.r-project.org) 73 | package developers can easily find. 74 | 75 | ### Why "Lite"? Are you keeping something from us? 76 | 77 | [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) compiles and installs 78 | the core modules of the [`OpenCV`](https://opencv.org/) library but does not 79 | compile or install its [contributed extra modules](https://github.com/opencv/opencv_contrib). 80 | This is to reduce the compilation time (which is already long enough) and also 81 | because most of these extra modules are (1) too specific for most applications of 82 | [`OpenCV`](https://opencv.org/), and (2) they do not always compile nicely. 83 | 84 | We will work toward providing a mechanism to install the extra modules, but this 85 | is not part of our immediate plans. 86 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # ROpenCVLite 4.110.0 2 | 3 | ## New features 4 | 5 | * Upgrades package to OpenCV 4.11.0. 6 | 7 | ## Minor improvements and fixes 8 | 9 | * Fixes issue with CMake 4. 10 | 11 | --- 12 | 13 | # ROpenCVLite 4.90.2 14 | 15 | ## New features 16 | 17 | * N/A. 18 | 19 | ## Minor improvements and fixes 20 | 21 | * Removes pkgbuild dependency. 22 | 23 | --- 24 | 25 | # ROpenCVLite 4.90.1 26 | 27 | ## New features 28 | 29 | * Adds WeChat QR code module (thanks to @wresch). 30 | * Adds pkgconfig files (thanks to @wresch). 31 | 32 | ## Minor improvements and fixes 33 | 34 | * Remove some processor optimization to avoid errors on Windows with recent CPUs. 35 | 36 | --- 37 | 38 | # ROpenCVLite 4.90.0 39 | 40 | ## New features 41 | 42 | * Upgrade package to OpenCV 4.9.0. 43 | * Remove support for R < 4.0.0. 44 | 45 | ## Minor improvements and fixes 46 | 47 | * Add compilation flags required to avoid errors on Windows 11. 48 | * Overhaul of the installation functions for easier update management. 49 | 50 | --- 51 | 52 | # ROpenCVLite 4.80.1 53 | 54 | ## New features 55 | 56 | * N/A. 57 | 58 | ## Minor improvements and fixes 59 | 60 | * Add compilation flags required with latest Rtools on Windows. 61 | 62 | --- 63 | 64 | # ROpenCVLite 4.80.0 65 | 66 | ## New features 67 | 68 | * Upgrade package to OpenCV 4.8.0. 69 | 70 | ## Minor improvements and fixes 71 | 72 | * N/A. 73 | 74 | --- 75 | 76 | # ROpenCVLite 4.70.0 77 | 78 | ## New features 79 | 80 | * Upgrade package to OpenCV 4.7.0. 81 | 82 | ## Minor improvements and fixes 83 | 84 | * N/A. 85 | 86 | --- 87 | 88 | # ROpenCVLite 4.60.3 89 | 90 | ## New features 91 | 92 | * Adds ximgproc "extra" module. 93 | 94 | ## Minor improvements and fixes 95 | 96 | * N/A. 97 | 98 | --- 99 | 100 | # ROpenCVLite 4.60.2 101 | 102 | ## New features 103 | 104 | * Adds function to remove OpenCV. 105 | 106 | ## Minor improvements and fixes 107 | 108 | * Removes unnecessary messages during package installation. 109 | 110 | --- 111 | 112 | # ROpenCVLite 4.60.1 113 | 114 | ## New features 115 | 116 | * Upgrade package to OpenCV 4.6.0. 117 | 118 | ## Minor improvements and fixes 119 | 120 | * N/A. 121 | 122 | --- 123 | 124 | # ROpenCVLite 4.55.2 125 | 126 | ## New features 127 | 128 | * N/A. 129 | 130 | ## Minor improvements and fixes 131 | 132 | * Compatible with new RTools 4.2 toolchain. 133 | 134 | --- 135 | 136 | # ROpenCVLite 4.55.1 137 | 138 | ## New features 139 | 140 | * Add possibility to install OpenCV in custom directory. 141 | * Change default installation directory. 142 | 143 | ## Minor improvements and fixes 144 | 145 | * Fix documentation. 146 | 147 | --- 148 | 149 | # ROpenCVLite 4.55.0 150 | 151 | ## New features 152 | 153 | * Upgrade package to OpenCV 4.5.5. 154 | 155 | ## Minor improvements and fixes 156 | 157 | * N/A. 158 | 159 | --- 160 | 161 | # ROpenCVLite 4.52.1 162 | 163 | ## New features 164 | 165 | * N/A. 166 | 167 | ## Minor improvements and fixes 168 | 169 | * Fix installation bug on Windows after upgrade to latest pkgbuild version. 170 | 171 | --- 172 | 173 | # ROpenCVLite 4.52.0 174 | 175 | ## New features 176 | 177 | * Upgrade package to OpenCV 4.5.2 178 | 179 | ## Minor improvements and fixes 180 | 181 | * N/A. 182 | 183 | --- 184 | 185 | # ROpenCVLite 4.51.0 186 | 187 | ## New features 188 | 189 | * Upgrade package to OpenCV 4.5.1 190 | * OpenCV compiles with OpenCL support and other optimizations when possible. 191 | 192 | ## Minor improvements and fixes 193 | 194 | * N/A. 195 | 196 | --- 197 | 198 | # ROpenCVLite 4.50.0 199 | 200 | ## New features 201 | 202 | * Upgrade package to OpenCV 4.5.0 203 | * OpenCV compiles with OpenMP support when possible. 204 | 205 | ## Minor improvements and fixes 206 | 207 | * N/A. 208 | 209 | --- 210 | 211 | # ROpenCVLite 4.430.2 212 | 213 | ## New features 214 | 215 | N/A 216 | 217 | ## Minor improvements and fixes 218 | 219 | * Fix an issue with detecting when a new version of OpenCV is available. 220 | 221 | --- 222 | 223 | # ROpenCVLite 4.430.1 224 | 225 | ## New features 226 | 227 | N/A 228 | 229 | ## Minor improvements and fixes 230 | 231 | * Fix an issue with detecting Rtools with R 3.x on Windows. 232 | 233 | --- 234 | 235 | # ROpenCVLite 4.430.0 236 | 237 | ## New features 238 | 239 | * Package updated to use the latest OpenCV release (4.3.0). 240 | * Package updated to work with RTools 4.0 (Windows only). 241 | 242 | ## Minor improvements and fixes 243 | 244 | * A CMake check is now made during the package installation. 245 | 246 | --- 247 | 248 | # ROpenCVLite 3.412.1 249 | 250 | ## New features 251 | 252 | N/A 253 | 254 | ## Minor improvements and fixes 255 | 256 | * If an old installation exists, it is deleted before upgrading/reinstalling OpenCV. 257 | 258 | --- 259 | 260 | # ROpenCVLite 0.3.412 261 | 262 | ## New features 263 | 264 | * Package updated to use the latest OpenCV release (4.1.2). 265 | 266 | ## Minor improvements and fixes 267 | 268 | N/A 269 | 270 | --- 271 | 272 | # ROpenCVLite 0.3.410 273 | 274 | ## New features 275 | 276 | * Package ready for release to CRAN. 277 | 278 | ## Minor improvements and fixes 279 | 280 | N/A -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('nav.navbar').headroom(); 6 | 7 | Toc.init({ 8 | $nav: $("#toc"), 9 | $scope: $("main h2, main h3, main h4, main h5, main h6") 10 | }); 11 | 12 | if ($('#toc').length) { 13 | $('body').scrollspy({ 14 | target: '#toc', 15 | offset: $("nav.navbar").outerHeight() + 1 16 | }); 17 | } 18 | 19 | // Activate popovers 20 | $('[data-bs-toggle="popover"]').popover({ 21 | container: 'body', 22 | html: true, 23 | trigger: 'focus', 24 | placement: "top", 25 | sanitize: false, 26 | }); 27 | 28 | $('[data-bs-toggle="tooltip"]').tooltip(); 29 | 30 | /* Clipboard --------------------------*/ 31 | 32 | function changeTooltipMessage(element, msg) { 33 | var tooltipOriginalTitle=element.getAttribute('data-bs-original-title'); 34 | element.setAttribute('data-bs-original-title', msg); 35 | $(element).tooltip('show'); 36 | element.setAttribute('data-bs-original-title', tooltipOriginalTitle); 37 | } 38 | 39 | if(ClipboardJS.isSupported()) { 40 | $(document).ready(function() { 41 | var copyButton = ""; 42 | 43 | $("div.sourceCode").addClass("hasCopyButton"); 44 | 45 | // Insert copy buttons: 46 | $(copyButton).prependTo(".hasCopyButton"); 47 | 48 | // Initialize tooltips: 49 | $('.btn-copy-ex').tooltip({container: 'body'}); 50 | 51 | // Initialize clipboard: 52 | var clipboard = new ClipboardJS('[data-clipboard-copy]', { 53 | text: function(trigger) { 54 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); 55 | } 56 | }); 57 | 58 | clipboard.on('success', function(e) { 59 | changeTooltipMessage(e.trigger, 'Copied!'); 60 | e.clearSelection(); 61 | }); 62 | 63 | clipboard.on('error', function(e) { 64 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 65 | }); 66 | 67 | }); 68 | } 69 | 70 | /* Search marking --------------------------*/ 71 | var url = new URL(window.location.href); 72 | var toMark = url.searchParams.get("q"); 73 | var mark = new Mark("main#main"); 74 | if (toMark) { 75 | mark.mark(toMark, { 76 | accuracy: { 77 | value: "complementary", 78 | limiters: [",", ".", ":", "/"], 79 | } 80 | }); 81 | } 82 | 83 | /* Search --------------------------*/ 84 | /* Adapted from https://github.com/rstudio/bookdown/blob/2d692ba4b61f1e466c92e78fd712b0ab08c11d31/inst/resources/bs4_book/bs4_book.js#L25 */ 85 | // Initialise search index on focus 86 | var fuse; 87 | $("#search-input").focus(async function(e) { 88 | if (fuse) { 89 | return; 90 | } 91 | 92 | $(e.target).addClass("loading"); 93 | var response = await fetch($("#search-input").data("search-index")); 94 | var data = await response.json(); 95 | 96 | var options = { 97 | keys: ["what", "text", "code"], 98 | ignoreLocation: true, 99 | threshold: 0.1, 100 | includeMatches: true, 101 | includeScore: true, 102 | }; 103 | fuse = new Fuse(data, options); 104 | 105 | $(e.target).removeClass("loading"); 106 | }); 107 | 108 | // Use algolia autocomplete 109 | var options = { 110 | autoselect: true, 111 | debug: true, 112 | hint: false, 113 | minLength: 2, 114 | }; 115 | var q; 116 | async function searchFuse(query, callback) { 117 | await fuse; 118 | 119 | var items; 120 | if (!fuse) { 121 | items = []; 122 | } else { 123 | q = query; 124 | var results = fuse.search(query, { limit: 20 }); 125 | items = results 126 | .filter((x) => x.score <= 0.75) 127 | .map((x) => x.item); 128 | if (items.length === 0) { 129 | items = [{dir:"Sorry 😿",previous_headings:"",title:"No results found.",what:"No results found.",path:window.location.href}]; 130 | } 131 | } 132 | callback(items); 133 | } 134 | $("#search-input").autocomplete(options, [ 135 | { 136 | name: "content", 137 | source: searchFuse, 138 | templates: { 139 | suggestion: (s) => { 140 | if (s.title == s.what) { 141 | return `${s.dir} >
${s.title}
`; 142 | } else if (s.previous_headings == "") { 143 | return `${s.dir} >
${s.title}
> ${s.what}`; 144 | } else { 145 | return `${s.dir} >
${s.title}
> ${s.previous_headings} > ${s.what}`; 146 | } 147 | }, 148 | }, 149 | }, 150 | ]).on('autocomplete:selected', function(event, s) { 151 | window.location.href = s.path + "?q=" + q + "#" + s.id; 152 | }); 153 | }); 154 | })(window.jQuery || window.$) 155 | 156 | document.addEventListener('keydown', function(event) { 157 | // Check if the pressed key is '/' 158 | if (event.key === '/') { 159 | event.preventDefault(); // Prevent any default action associated with the '/' key 160 | document.getElementById('search-input').focus(); // Set focus to the search input 161 | } 162 | }); 163 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page not found (404) • ROpenCVLite 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Skip to contents 24 | 25 | 26 |
60 |
61 |
65 | 66 | Content not found. Please use links in the navbar. 67 | 68 |
69 |
70 | 71 | 72 |
75 | 76 | 79 | 80 |
81 |
82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | Authors and Citation • ROpenCVLite 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
37 | 38 |
39 |

Authors

40 | 41 |
  • 42 |

    Simon Garnier. Author, maintainer. 43 |

    44 |
  • 45 |
  • 46 |

    Muschelli John. Contributor. 47 |

    48 |
  • 49 |
50 | 51 |
52 |

Citation

53 |

Source: inst/CITATION

54 | 55 |

Simon Garnier and John Muschelli (2025). ROpenCVLite - Helper package for installing OpenCV with R. R package version 4.110.0.

56 |
@Manual{,
57 |   title = {{ROpenCVLite} - Helper package for installing OpenCV with R},
58 |   author = {Simon Garnier and John Muschelli},
59 |   year = {2025},
60 |   note = {R package version 4.110.0},
61 |   url = {https://swarm-lab.github.io/ROpenCVLite/},
62 | }
63 |
64 | 65 |
67 | 68 | 69 |
72 | 73 | 76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/reference/isCmakeInstalled.html: -------------------------------------------------------------------------------- 1 | 2 | Check Cmake Installation — isCmakeInstalled • ROpenCVLite 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
39 | 40 |
41 |

This function checks that Cmake is installed on the system.

42 |
43 | 44 |
45 |

Usage

46 |
isCmakeInstalled()
47 |
48 | 49 |
50 |

Value

51 |

A boolean.

52 |
53 |
54 |

Author

55 |

Simon Garnier, garnier@njit.edu

56 |
57 | 58 |
59 |

Examples

60 |
isCmakeInstalled()
61 | #> [1] TRUE
62 | 
63 | 
64 |
65 |
67 | 68 | 69 |
72 | 73 | 76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/reference/isOpenCVInstalled.html: -------------------------------------------------------------------------------- 1 | 2 | Check OpenCV Installation — isOpenCVInstalled • ROpenCVLite 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
39 | 40 |
41 |

This function checks that OpenCV is installed and accessible.

42 |
43 | 44 |
45 |

Usage

46 |
isOpenCVInstalled()
47 |
48 | 49 |
50 |

Value

51 |

A boolean.

52 |
53 |
54 |

Author

55 |

Simon Garnier, garnier@njit.edu

56 |
57 | 58 |
59 |

Examples

60 |
isOpenCVInstalled()
61 | #> [1] TRUE
62 | 
63 | 
64 |
65 |
67 | 68 | 69 |
72 | 73 | 76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | Package index • ROpenCVLite 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
37 | 38 |
39 |

All functions

40 | 41 | 42 | 43 | 44 |
45 | 46 | 47 | 48 | 49 |
50 | 51 | OpenCVPath() 52 | 53 |
54 |
Install Location of OpenCV
55 |
56 | 57 | ROpenCVLite ROpenCVLite-package 58 | 59 |
60 |
ROpenCVLite: A package to install OpenCV within R
61 |
62 | 63 | defaultOpenCVPath() 64 | 65 |
66 |
Default Install Location of OpenCV
67 |
68 | 69 | installOpenCV() 70 | 71 |
72 |
Install OpenCV
73 |
74 | 75 | isCmakeInstalled() 76 | 77 |
78 |
Check Cmake Installation
79 |
80 | 81 | isOpenCVInstalled() 82 | 83 |
84 |
Check OpenCV Installation
85 |
86 | 87 | opencvConfig() 88 | 89 |
90 |
C/C++ configuration options
91 |
92 | 93 | opencvVersion() 94 | 95 |
96 |
OpenCV Version
97 |
98 | 99 | removeOpenCV() 100 | 101 |
102 |
Remove OpenCV
103 |
104 |
105 | 106 | 107 |
110 | 111 | 114 | 115 |
116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /docs/reference/ROpenCVLite-package.html: -------------------------------------------------------------------------------- 1 | 2 | ROpenCVLite: A package to install OpenCV within R — ROpenCVLite-package • ROpenCVLite 7 | Skip to contents 8 | 9 | 10 |
37 |
38 |
43 | 44 |
45 |

This is a utility package that installs OpenCV within R for use 46 | by other packages. This Lite version does not contain any of the contributed 47 | modules of OpenCV.

48 |
49 | 50 | 51 | 58 |
59 |

Author

60 |

Simon Garnier, garnier@njit.edu

61 |
62 | 63 |
65 | 66 | 67 |
70 | 71 | 74 | 75 |
76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /docs/reference/removeOpenCV.html: -------------------------------------------------------------------------------- 1 | 2 | Remove OpenCV — removeOpenCV • ROpenCVLite 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
39 | 40 |
41 |

This function removes OpenCV from the system.

42 |
43 | 44 |
45 |

Usage

46 |
removeOpenCV()
47 |
48 | 49 |
50 |

Value

51 |

A boolean.

52 |
53 |
54 |

Author

55 |

Simon Garnier, garnier@njit.edu

56 |
57 | 58 |
59 |

Examples

60 |
if (FALSE) { # \dontrun{
61 | installOpenCV()
62 | } # }
63 | 
64 | 
65 |
66 |
68 | 69 | 70 |
73 | 74 | 77 | 78 |
79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/reference/OpenCVPath.html: -------------------------------------------------------------------------------- 1 | 2 | Install Location of OpenCV — OpenCVPath • ROpenCVLite 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
39 | 40 |
41 |

This function returns the location at which OpenCV is installed.

42 |
43 | 44 |
45 |

Usage

46 |
OpenCVPath()
47 |
48 | 49 |
50 |

Value

51 |

A character string.

52 |
53 |
54 |

Author

55 |

Simon Garnier, garnier@njit.edu

56 |
57 | 58 |
59 |

Examples

60 |
if (FALSE) { # \dontrun{
61 |  OpenCVPath()
62 | } # }
63 | 
64 | 
65 |
66 |
68 | 69 | 70 |
73 | 74 | 77 | 78 |
79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/reference/opencvVersion.html: -------------------------------------------------------------------------------- 1 | 2 | OpenCV Version — opencvVersion • ROpenCVLite 5 | Skip to contents 6 | 7 | 8 |
35 |
36 |
41 | 42 |
43 |

This function determines the version of OpenCV installed within 44 | R.

45 |
46 | 47 |
48 |

Usage

49 |
opencvVersion()
50 |
51 | 52 |
53 |

Value

54 |

A character string.

55 |
56 |
57 |

Author

58 |

Simon Garnier, garnier@njit.edu

59 |
60 | 61 |
62 |

Examples

63 |
if (isOpenCVInstalled()) {
64 |   opencvVersion()
65 | }
66 | #> [1] "Version 4.11.0"
67 | 
68 | 
69 |
70 |
72 | 73 | 74 |
77 | 78 | 81 | 82 |
83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/reference/defaultOpenCVPath.html: -------------------------------------------------------------------------------- 1 | 2 | Default Install Location of OpenCV — defaultOpenCVPath • ROpenCVLite 5 | Skip to contents 6 | 7 | 8 |
35 |
36 |
41 | 42 |
43 |

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

45 |
46 | 47 |
48 |

Usage

49 |
defaultOpenCVPath()
50 |
51 | 52 |
53 |

Value

54 |

A character string.

55 |
56 |
57 |

Author

58 |

Simon Garnier, garnier@njit.edu

59 |
60 | 61 |
62 |

Examples

63 |
if (FALSE) { # \dontrun{
64 | defaultOpenCVPath()
65 | } # }
66 | 
67 | 
68 |
69 |
71 | 72 | 73 |
76 | 77 | 80 | 81 |
82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /docs/articles/usage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 2 - Using ROpenCVLite • ROpenCVLite 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Skip to contents 23 | 24 | 25 |
59 | 60 | 61 | 62 | 63 |
64 |
73 | 74 | 75 | 76 |

The goal of ROpenCVLite 77 | is to enable developers to create their own packages for R based on OpenCV. Computer vision is 78 | just one of the possible applications for OpenCV. It can do many more 79 | things, such as fast matrix processing and GPU computing. By providing 80 | access to a standardized installation of OpenCV, we hope to help the 81 | R community take 82 | advantage of this fantastic library.

83 |
84 |
85 |

Create a package using ROpenCVLite 86 |

87 |

Follow these steps to configure your package for ROpenCVLite:

88 |
    89 |
  1. Set ROpenCVLite 90 | as a dependency in the DESCRIPTION file of your package.
  2. 91 |
  3. Use the opencvConfig 92 | function provided with ROpenCVLite 93 | to: 94 |
      95 |
    • set the PKG_LIBS value of the Makevars and Makevars.win 96 | files of your package (using opencvConfig("libs")).
    • 97 |
    • set the PKG_CPPFLAGS () value of the Makevars and 98 | Makevars.win files of your package (using 99 | opencvConfig("cflags")).
    • 100 |
    101 |
  4. 102 |
103 |

You can find an example of how to set up your package with ROpenCVLite 104 | in our Rvision 105 | package:

106 | 111 |
112 |
114 |
115 | 116 | 117 | 118 |
121 | 122 | 125 | 126 |
127 |
128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /docs/reference/installOpenCV.html: -------------------------------------------------------------------------------- 1 | 2 | Install OpenCV — installOpenCV • ROpenCVLite 5 | Skip to contents 6 | 7 | 8 |
35 |
36 |
41 | 42 |
43 |

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

45 |
46 | 47 |
48 |

Usage

49 |
installOpenCV(install_path = defaultOpenCVPath(), batch = FALSE)
50 |
51 | 52 |
53 |

Arguments

54 | 55 | 56 |
install_path
57 |

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

60 | 61 | 62 |
batch
63 |

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

67 | 68 |
69 |
70 |

Value

71 |

A boolean.

72 |
73 |
74 |

Author

75 |

Simon Garnier, garnier@njit.edu

76 |
77 | 78 |
79 |

Examples

80 |
if (FALSE) { # \dontrun{
 81 | installOpenCV()
 82 | } # }
 83 | 
 84 | 
85 |
86 |
88 | 89 | 90 |
93 | 94 | 97 | 98 |
99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /vignettes/install.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | author: "Simon Garnier" 3 | title: "1 - Installing ROpenCVLite" 4 | output: rmarkdown::html_vignette 5 | vignette: > 6 | %\VignetteIndexEntry{1 - Installing ROpenCVLite} 7 | %\VignetteEngine{knitr::rmarkdown} 8 | %\VignetteEncoding{UTF-8} 9 | --- 10 | 11 | Installing [`ROpenCVLite`](https://github.com/swarm-lab/ROpenCVLite) should go 12 | smoothly on all major operating systems (Mac, Windows, and most major Linux 13 | distributions). There are a few steps to follow before installing the package 14 | itself in order to prepare all the necessary external (i.e. non-R) dependencies 15 | for [`OpenCV`](https://opencv.org/). You should also make sure that your R 16 | version is 4.0 or higher. Support for older versions of R has been removed. 17 | 18 | All installation steps are described below. 19 | 20 | --- 21 | 22 | + [1 - Before installing ](#before-installing ) 23 | + [1.1 - Windows](#windows) 24 | + [1.2 - Mac](#mac) 25 | + [1.3 - Linux](#linux) 26 | + [1.4 - Mac, Linux and Windows](#mac-linux-and-windows) 27 | + [2 - Installing `ROpenCVLite`](#installing-ropencvlite) 28 | 29 | --- 30 | 31 | ## 1 - Before installing 32 | 33 | ### 1.1 - Windows 34 | 35 | Before installing `ROpenCVLite`, you will need to install 36 | [`Rtools`](https://cran.r-project.org/bin/windows/Rtools/) and 37 | [`CMake`](https://cmake.org/). 38 | 39 | #### 1.1.1 - Rtools 40 | 41 | You will need to install the version of `Rtools` that corresponds to your version 42 | of R. You can check your version of R by typing `R.version` in the R console. 43 | 44 | + If your R version starts with 4.0 or 4.1, you will need to install `Rtools40`. 45 | + If your R version starts with 4.2, you will need to install `Rtools42`. 46 | + If your R version starts with 4.3 or 4.4 (devel), you will need to install `Rtools43`. 47 | 48 | There are multiple ways to install `Rtools` on Windows: 49 | 50 | ##### **Option 1** 51 | 52 | Use the convenience function provided by the `installr` library: 53 | 54 | ```{r eval=FALSE} 55 | if (!require("installr")) 56 | install.packages("installr") 57 | 58 | installr::install.Rtools() 59 | ``` 60 | 61 | *Note:* If you install `Rtools40`, make sure to tell the installer to add `Rtools` 62 | to your "PATH" during the installation process. This is not required anymore 63 | with `Rtools42` and `Rtools43`. 64 | 65 | ##### **Option 2** 66 | 67 | If you have the [`rig`](https://github.com/r-lib/rig) utility installed on your 68 | computer, you can install `Rtools` from a terminal running PowerShell: 69 | 70 | ```{bash eval=FALSE} 71 | # For Rtools40 72 | rig add rtools40 73 | 74 | # For Rtools42 75 | rig add rtools42 76 | 77 | # For Rtools43 78 | rig add rtools43 79 | ``` 80 | 81 | ##### **Option 3** 82 | 83 | If you have the [`winget`](https://learn.microsoft.com/en-us/windows/package-manager/) 84 | utility installed on your computer, you can install `Rtools` from a terminal 85 | running PowerShell: 86 | 87 | ```{bash eval=FALSE} 88 | winget install RProject.Rtools 89 | ``` 90 | 91 | *Note:* Only `Rtools42` seems to be available through `winget` at the moment. 92 | 93 | ##### **Option 4** 94 | 95 | You can manually download `Rtools` at 96 | [https://cran.r-project.org/bin/windows/Rtools/](https://cran.r-project.org/bin/windows/Rtools/). 97 | 98 | *Note:* If you install `Rtools40`, make sure to tell the installer to add `Rtools` 99 | to your "PATH" during the installation process. This is not required anymore 100 | with `Rtools42` and `Rtools43`. 101 | 102 | #### 1.1.1 - Cmake 103 | 104 | Installing `Cmake` is only required if your R version starts with 4.0 or 4.1 and, 105 | therefore, you have installed `Rtools40`. For newer versions of R, `Cmake` is 106 | included in `Rtools42` and `Rtools43` and you can skip this step. 107 | 108 | Any version of `Cmake` 3.24 or higher should work. There are multiple ways to 109 | install `Cmake` on Windows: 110 | 111 | ##### **Option 1** 112 | 113 | Use the convenience function provided by the `installr` library: 114 | 115 | ```{r eval=FALSE} 116 | if (!require("installr")) 117 | install.packages("installr") 118 | 119 | installr::install.CMake() 120 | ``` 121 | 122 | During the installation process, make sure to tell the installer to add `CMake` 123 | to your "PATH". 124 | 125 | ##### **Option 2** 126 | 127 | If you have the [`winget`](https://learn.microsoft.com/en-us/windows/package-manager/) 128 | utility installed on your computer, you can install `Cmake` from a terminal 129 | running PowerShell: 130 | 131 | ```{bash eval=FALSE} 132 | winget install cmake 133 | ``` 134 | 135 | ##### **Option 3** 136 | 137 | You can manually download the `CMake` installer for Windows at 138 | [https://cmake.org/download/](https://cmake.org/download/). Make sure to tell 139 | the installer to add `CMake` to your "PATH" during the installation process. 140 | 141 | --- 142 | 143 | ### 1.2 - Mac 144 | 145 | Before installing `ROpenCVLite`, you will need to install the latest version of 146 | [`CMake`](https://cmake.org/). There are multiple ways to install `Cmake` on Mac: 147 | 148 | ##### **Option 1** 149 | 150 | If you have [`homebrew`](https://brew.sh/) installed, run the following command 151 | in your terminal: 152 | 153 | ```bash 154 | brew install cmake 155 | ``` 156 | 157 | ##### **Option 2** 158 | 159 | If you have [`MacPorts`](https://www.macports.org/) installed, run the following 160 | command in your terminal: 161 | 162 | ```bash 163 | sudo port install cmake 164 | ``` 165 | 166 | ##### **Option 3** 167 | 168 | Go to [https://cmake.org/download/](https://cmake.org/download/). Scroll down 169 | until you reach the "Latest Release" section. Download the installer for Mac OS 170 | X (.dmg file). Once the download is complete, double-click on the installer and 171 | accept the license agreement. Drag and drop the `Cmake` app into your 172 | `Applications` folder. 173 | 174 | To make `Cmake` accessible to `R`, open a terminal and type: 175 | 176 | `sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install` 177 | 178 | It will ask for your administrator password. 179 | 180 | --- 181 | 182 | ### 1.3 - Linux 183 | 184 | Before installing `ROpenCVLite`, you will need to install the latest version of 185 | [`CMake`](https://cmake.org/). Hereafter are two options to do this on Linux. 186 | 187 | + **Option 1** 188 | 189 | Use your distribution's package management system. For instance on Ubuntu-like 190 | systems, you can install `Cmake` by typing the following command in your terminal: 191 | 192 | ```bash 193 | sudo apt install cmake 194 | ``` 195 | 196 | Other distributions will have different package managers. Refer to the 197 | documentation of your distribution for finding the proper way to install `Cmake` 198 | on your system. 199 | 200 | + **Option 2** 201 | 202 | Download `CMake` for Linux at [https://cmake.org/download/](https://cmake.org/download/). 203 | However it is recommended that you install it using your distribution's package 204 | management system. 205 | 206 | --- 207 | 208 | ### 1.4 - Mac, Linux and Windows 209 | 210 | Before installing `ROpenCVLite`, you will need to install the `devtools` package 211 | in `R`. 212 | 213 | ```{r eval=FALSE} 214 | install.packages("devtools") 215 | ``` 216 | 217 | --- 218 | 219 | ## 2 - Installing `ROpenCVLite` 220 | 221 | You can install `ROpenCVLite` from CRAN as follows: 222 | 223 | ```{r eval=FALSE} 224 | install.packages("ROpenCVLite") 225 | ``` 226 | 227 | Or you can install the latest development version (not recommended) as follows: 228 | 229 | ```{r eval=FALSE} 230 | devtools::install_github("swarm-lab/ROpenCVLite") 231 | ``` 232 | 233 | This will not install `OpenCV` yet. You will be asked whether you want to install 234 | it the first time you load the package. 235 | 236 | ```{r eval=FALSE} 237 | library(ROpenCVLite) 238 | ``` 239 | 240 | This step can take some time. Go make yourself a cup of coffee or two while 241 | `ROpenCVLite` downloads, compiles and installs `OpenCV` on your system. 242 | 243 | In addition, you can also request the (re)installation of `OpenCV` at any time 244 | as follows: 245 | 246 | ```{r eval=FALSE} 247 | ROpenCVLite::installOpenCV() 248 | ``` 249 | 250 | `ROpenCVLite` will also automatically detect when a new version of `OpenCV` is 251 | available and will offer to update it for you. 252 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | #' @title Install Location of OpenCV 2 | #' 3 | #' @description This function returns the location at which OpenCV is installed. 4 | #' 5 | #' @return A character string. 6 | #' 7 | #' @author Simon Garnier, \email{garnier@@njit.edu} 8 | #' 9 | #' @examples 10 | #' \dontrun{ 11 | #' OpenCVPath() 12 | #' } 13 | #' 14 | #' @export 15 | OpenCVPath <- function() { 16 | pkgPath <- find.package("ROpenCVLite") 17 | 18 | if (file.exists(paste0(pkgPath, "/path"))) { 19 | path <- readLines(paste0(pkgPath, "/path"), 1) 20 | } else { 21 | path <- character() 22 | } 23 | 24 | if (length(path) == 0) 25 | path <- defaultOpenCVPath() 26 | 27 | if (dir.exists(paste0(path, "/include/"))) { 28 | path 29 | } else { 30 | stop("OpenCV is not installed on this system. Please use installOpenCV() to install it.") 31 | } 32 | } 33 | 34 | 35 | #' @title Check OpenCV Installation 36 | #' 37 | #' @description This function checks that OpenCV is installed and accessible. 38 | #' 39 | #' @return A boolean. 40 | #' 41 | #' @author Simon Garnier, \email{garnier@@njit.edu} 42 | #' 43 | #' @examples 44 | #' isOpenCVInstalled() 45 | #' 46 | #' @export 47 | isOpenCVInstalled <- function() { 48 | path <- try(OpenCVPath(), silent = TRUE) 49 | 50 | if (inherits(path, "try-error")) { 51 | FALSE 52 | } else { 53 | dir.exists(paste0(path, "/include/")) 54 | } 55 | } 56 | 57 | 58 | #' @title Check Cmake Installation 59 | #' 60 | #' @description This function checks that Cmake is installed on the system. 61 | #' 62 | #' @return A boolean. 63 | #' 64 | #' @author Simon Garnier, \email{garnier@@njit.edu} 65 | #' 66 | #' @examples 67 | #' isCmakeInstalled() 68 | #' 69 | #' @export 70 | isCmakeInstalled <- function() { 71 | cmake <- system("cmake --version", ignore.stdout = TRUE) == 0 72 | 73 | if (cmake) { 74 | cmake 75 | } else { 76 | cat("------------------ CMAKE NOT FOUND --------------------\n") 77 | cat("\n") 78 | cat("CMake was not found on the PATH. Please install CMake:\n") 79 | cat("\n") 80 | cat(" - installr::install.cmake() (Windows; inside the R console)\n") 81 | cat(" - yum install cmake (Fedora/CentOS; inside a terminal)\n") 82 | cat(" - apt install cmake (Debian/Ubuntu; inside a terminal)\n") 83 | cat(" - brew install cmake (MacOS; inside a terminal with Homebrew)\n") 84 | cat(" - port install cmake (MacOS; inside a terminal with MacPorts)\n") 85 | cat("\n") 86 | cat("Alternatively install CMake from: \n") 87 | cat("\n") 88 | cat("-------------------------------------------------------\n") 89 | cat("\n") 90 | cmake 91 | } 92 | } 93 | 94 | 95 | #' @title OpenCV Version 96 | #' 97 | #' @description This function determines the version of OpenCV installed within 98 | #' R. 99 | #' 100 | #' @return A character string. 101 | #' 102 | #' @author Simon Garnier, \email{garnier@@njit.edu} 103 | #' 104 | #' @examples 105 | #' if (isOpenCVInstalled()) { 106 | #' opencvVersion() 107 | #' } 108 | #' 109 | #' @export 110 | opencvVersion <- function() { 111 | if (isOpenCVInstalled()) { 112 | if (.Platform$OS.type == "windows") { 113 | pcPath <- "/OpenCVConfig-version.cmake" 114 | pc <- utils::read.table(paste0(OpenCVPath(), pcPath), sep = "\t")[1, 1] 115 | paste0("Version ", gsub(")", "", gsub(".*VERSION ", "", pc))) 116 | } else { 117 | odir <- dir(OpenCVPath()) 118 | lib <- odir[grepl("lib", odir)] 119 | pcPath <- paste0("/", lib, "/cmake/opencv4/OpenCVConfig-version.cmake") 120 | pc <- utils::read.table(paste0(OpenCVPath(), pcPath), sep = "\t")[1, 1] 121 | paste0("Version ", gsub(")", "", gsub(".*VERSION ", "", pc))) 122 | } 123 | } else { 124 | stop("OpenCV is not installed on this system. Please use installOpenCV() to install it.") 125 | } 126 | } 127 | 128 | 129 | #' @title C/C++ configuration options 130 | #' 131 | #' @description This function returns the configuration options for compiling 132 | #' C/C++-based packages against OpenCV installed by \code{\link{ROpenCVLite}}. 133 | #' 134 | #' @param output Either 'libs' for library configuration options or 'cflags' for 135 | #' C/C++ configuration flags. 136 | #' 137 | #' @param arch architecture relevant for Windows. If \code{NULL}, then 138 | #' \code{R.version$arch} will be used. 139 | #' 140 | #' @return A concatenated character string (with \code{\link{cat}}) of the 141 | #' configuration options. 142 | #' 143 | #' @author Simon Garnier, \email{garnier@@njit.edu} 144 | #' 145 | #' @examples 146 | #' \dontrun{ 147 | #' if (isOpenCVInstalled()) { 148 | #' opencvConfig() 149 | #' opencvConfig(output = "cflags") 150 | #' opencvConfig(arch = R.version$arch) 151 | #' } 152 | #' } 153 | #' 154 | #' @export 155 | opencvConfig <- function(output = "libs", arch = NULL) { 156 | if (!isOpenCVInstalled()) 157 | stop("OpenCV is not installed on this system. Please use installOpenCV() to install it.") 158 | 159 | prefix <- OpenCVPath() 160 | 161 | if (output == "libs") { 162 | if (.Platform$OS.type == "windows") { 163 | if (is.null(arch)) { 164 | arch = R.version$arch 165 | } 166 | if (grepl("i386", arch)) { 167 | execPrefix <- paste0(prefix, "/x86/mingw") 168 | } else { 169 | execPrefix <- paste0(prefix, "/x64/mingw") 170 | } 171 | libDir <- paste0(execPrefix, "/lib") 172 | libs <- gsub("libopencv", "opencv", list.files(libDir, "lib*")) 173 | libs <- gsub("\\.a", "", libs) 174 | libs <- gsub("\\.dll", "", libs) 175 | libs <- ifelse(substring(libs, 1, 3) == "lib", substring(libs, 4), libs) 176 | libs <- paste0("-l", libs) 177 | cat(paste0('-L"', utils::shortPathName(libDir), '"'), libs) 178 | } else { 179 | execPrefix <- prefix 180 | odir <- dir(execPrefix) 181 | lib <- odir[grepl("lib", odir)] 182 | libDir <- paste0(execPrefix, "/", lib) 183 | libs <- gsub("libopencv", "opencv", list.files(libDir, "lib*")) 184 | libs <- gsub("\\.so", "", libs) 185 | libs <- gsub("\\.dylib", "", libs) 186 | libs <- libs[!grepl("\\.", libs)] 187 | libs <- paste0("-l", libs) 188 | if (Sys.info()[1] == "Darwin") { 189 | cat(paste0("-L", libDir, " ", paste0(libs, collapse = " "))) 190 | } else { 191 | cat(paste0("-Wl,-rpath=", libDir, " ", "-L", libDir, " ", paste0(libs, collapse = " "))) 192 | } 193 | } 194 | } else if (output == "cflags") { 195 | if (.Platform$OS.type == "windows") { 196 | includedirOld <- paste0(prefix, "/include/opencv2") 197 | includedirNew <- paste0(prefix, "/include") 198 | 199 | if (is.null(arch)) { 200 | arch = R.version$arch 201 | } 202 | if (grepl("i386", arch)) { 203 | execdir <- paste0(prefix, "/x86/mingw/bin") 204 | } else { 205 | execdir <- paste0(prefix, "/x64/mingw/bin") 206 | } 207 | 208 | cat(paste0('-I"', utils::shortPathName(includedirOld), '" -I"', 209 | utils::shortPathName(includedirNew), '" -I"', 210 | utils::shortPathName(execdir), '"')) 211 | } else { 212 | includedirOld <- paste0(prefix, "/include/opencv4") 213 | includedirNew <- paste0(prefix, "/include") 214 | 215 | cat(paste0("-I", includedirOld, " -I", includedirNew)) 216 | } 217 | } else { 218 | stop("output should be either 'libs' or 'cflags'") 219 | } 220 | } 221 | 222 | 223 | .findRtools <- function() { 224 | if (.Platform$OS.type != "windows") { 225 | stop("Rtools is Windows only.") 226 | } 227 | 228 | if (version$major < 4) { 229 | stop("ROpenCVLite requires a R version > 4.0.") 230 | } 231 | 232 | if (version$minor < 2) { 233 | rtools <- "rtools40" 234 | } else { 235 | rtools <- paste0("rtools", sub("\\D*(\\d+).*", "\\1", paste0(version$major, version$minor))) 236 | } 237 | 238 | path <- strsplit(Sys.getenv("PATH"), ";")[[1]] 239 | ix <- grep(rtools, path)[1] 240 | rtools_path <- utils::shortPathName(sub(paste0("(", rtools, ").*"), "\\1", path[ix])) 241 | rtools_version <- system( 242 | paste0("powershell (Get-Item ", rtools_path, "/unins000.exe).VersionInfo.ProductVersion"), 243 | intern = TRUE 244 | ) 245 | rtools_version <- gsub(" ", "", rtools_version) 246 | 247 | if (is.na(rtools_version)) 248 | stop("Rtools unavailable or unsupported Rtools version.") 249 | 250 | list(path = unname(rtools_path), version = unname(rtools_version)) 251 | } 252 | -------------------------------------------------------------------------------- /vignettes/usage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2 - Using ROpenCVLite 17 | 18 | 31 | 32 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 |

2 - Using ROpenCVLite

240 |

Simon Garnier

241 | 242 | 243 | 244 |

The goal of ROpenCVLite 245 | is to enable developers to create their own packages for R based on OpenCV. Computer vision is 246 | just one of the possible applications for OpenCV. It can do many more 247 | things, such as fast matrix processing and GPU computing. By providing 248 | access to a standardized installation of OpenCV, we hope to help the 249 | R community take 250 | advantage of this fantastic library.

251 |
252 |
253 |

Create a package using ROpenCVLite

254 |

Follow these steps to configure your package for ROpenCVLite:

255 |
    256 |
  1. Set ROpenCVLite 257 | as a dependency in the DESCRIPTION file of your package.
  2. 258 |
  3. Use the opencvConfig 259 | function provided with ROpenCVLite 260 | to: 261 |
      262 |
    • set the PKG_LIBS value of the Makevars and Makevars.win 263 | files of your package (using opencvConfig("libs")).
    • 264 |
    • set the PKG_CPPFLAGS () value of the Makevars and 265 | Makevars.win files of your package (using 266 | opencvConfig("cflags")).
    • 267 |
  4. 268 |
269 |

You can find an example of how to set up your package with ROpenCVLite 270 | in our Rvision 271 | package:

272 | 277 |
278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 293 | 294 | 295 | 296 | -------------------------------------------------------------------------------- /docs/reference/opencvConfig.html: -------------------------------------------------------------------------------- 1 | 2 | C/C++ configuration options — opencvConfig • ROpenCVLite 5 | Skip to contents 6 | 7 | 8 |
35 |
36 |
41 | 42 |
43 |

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

45 |
46 | 47 |
48 |

Usage

49 |
opencvConfig(output = "libs", arch = NULL)
50 |
51 | 52 |
53 |

Arguments

54 | 55 | 56 |
output
57 |

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

59 | 60 | 61 |
arch
62 |

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

64 | 65 |
66 |
67 |

Value

68 |

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

70 |
71 |
72 |

Author

73 |

Simon Garnier, garnier@njit.edu

74 |
75 | 76 |
77 |

Examples

78 |
if (FALSE) { # \dontrun{
 79 |  if (isOpenCVInstalled()) {
 80 |    opencvConfig()
 81 |    opencvConfig(output = "cflags")
 82 |    opencvConfig(arch = R.version$arch)
 83 |  }
 84 | } # }
 85 | 
 86 | 
87 |
88 |
90 | 91 | 92 |
95 | 96 | 99 | 100 |
101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /R/install.R: -------------------------------------------------------------------------------- 1 | #' @title Default Install Location of OpenCV 2 | #' 3 | #' @description This function returns the location at which OpenCV should be 4 | #' installed by default. 5 | #' 6 | #' @return A character string. 7 | #' 8 | #' @author Simon Garnier, \email{garnier@@njit.edu} 9 | #' 10 | #' @examples 11 | #' \dontrun{ 12 | #' defaultOpenCVPath() 13 | #' } 14 | #' 15 | #' @export 16 | defaultOpenCVPath <- function() { 17 | pkgPath <- find.package("ROpenCVLite") 18 | paste0(gsub("ROpenCVLite", "", pkgPath), "ROpenCV") 19 | } 20 | 21 | 22 | .configure <- function(install_path = defaultOpenCVPath(), version) { 23 | config <- list() 24 | 25 | config$arch <- unname(Sys.info()["machine"]) 26 | if (!grepl("64", config$arch)) { 27 | stop("Unsupported CPU architecture.") 28 | } 29 | 30 | config$os_type <- .Platform$OS.type 31 | 32 | if (config$os_type == "windows") { 33 | config$install_path <- utils::shortPathName(install_path) 34 | config$pkg_path <- utils::shortPathName(find.package("ROpenCVLite")) 35 | config$os <- gsub("\r", "", gsub("Caption=", "", system("wmic os get Caption,CSDVersion /value", intern = TRUE)[3])) 36 | config$core <- paste0("https://github.com/opencv/opencv/archive/", version, ".tar.gz") 37 | config$contrib <- paste0("https://github.com/opencv/opencv_contrib/archive/", version, ".tar.gz") 38 | rtools <- .findRtools() 39 | config$rtools_path <- rtools$path 40 | config$rtools_version <- rtools$version 41 | 42 | if (config$rtools_version < "4.2") { 43 | config$cmake_path <- utils::shortPathName(system("where cmake.exe", intern = TRUE)) 44 | 45 | if (length(config$cmake_path) > 1) { 46 | v <- sapply(config$cmake_path, function(cmake) gsub("cmake version ", "", system(paste0(cmake, " --version"), intern = TRUE)[1])) 47 | config$cmake_path <- config$cmake_path[which(v == max(v))] 48 | } 49 | 50 | config$gcc_path <- paste0(config$rtools_path, "\\mingw64\\bin\\gcc.exe") 51 | config$gpp_path <- paste0(config$rtools_path, "\\mingw64\\bin\\g++.exe") 52 | config$windres_path <- paste0(config$rtools_path, "\\mingw64\\bin\\windres.exe") 53 | config$make_path <- paste0(config$rtools_path, "\\usr\\bin\\make.exe") 54 | } else { 55 | config$cmake_path <- paste0(config$rtools_path, "\\x86_64-w64-mingw32.static.posix\\bin\\cmake.exe") 56 | config$gcc_path <- paste0(config$rtools_path, "\\x86_64-w64-mingw32.static.posix\\bin\\gcc.exe") 57 | config$gpp_path <- paste0(config$rtools_path, "\\x86_64-w64-mingw32.static.posix\\bin\\g++.exe") 58 | config$windres_path <- paste0(config$rtools_path, "\\x86_64-w64-mingw32.static.posix\\bin\\windres.exe") 59 | config$make_path <- paste0(config$rtools_path, "\\usr\\bin\\make.exe") 60 | } 61 | 62 | config$tmp_dir <- base::tempdir() 63 | config$source_dir <- paste0(config$tmp_dir, "\\opencv-", version, "\\") 64 | config$contrib_dir <- paste0(config$tmp_dir, "\\opencv_contrib-", version, "\\modules") 65 | config$build_dir <- paste0(config$source_dir, "build") 66 | 67 | ix <- grepl("path", names(config)) | grepl("dir", names(config)) 68 | config[ix] <- lapply(config[ix], function(st) gsub("\\\\", "/", utils::shortPathName(st))) 69 | } else if (config$os_type == "unix") { 70 | config$install_path <- install_path 71 | config$pkg_path <- find.package("ROpenCVLite") 72 | config$os <- unname(Sys.info()["sysname"]) 73 | config$core <- paste0("https://github.com/opencv/opencv/archive/", version, ".zip") 74 | config$contrib <- paste0("https://github.com/opencv/opencv_contrib/archive/", version, ".zip") 75 | config$cmake_path <- system("which cmake", intern = TRUE) 76 | config$gcc_path <- system("which gcc", intern = TRUE) 77 | config$gpp_path <- system("which g++", intern = TRUE) 78 | config$make_path <- system("which make", intern = TRUE) 79 | config$tmp_dir <- base::tempdir() 80 | config$source_dir <- paste0(config$tmp_dir, "/opencv-", version, "/") 81 | config$contrib_dir <- paste0(config$tmp_dir, "/opencv_contrib-", version, "/modules") 82 | config$build_dir <- paste0(config$source_dir, "build") 83 | 84 | ix <- grepl("path", names(config)) | grepl("dir", names(config)) 85 | config[ix] <- lapply(config[ix], normalizePath, mustWork = FALSE, winslash = "/") 86 | } else { 87 | stop("Unsupported OS type.") 88 | } 89 | 90 | config 91 | } 92 | 93 | 94 | .cmake <- function(config) { 95 | paste0( 96 | '"', config$cmake_path, '"', 97 | ' -G "Unix Makefiles"', 98 | " -Wno-dev", 99 | ' -DCMAKE_C_COMPILER="', config$gcc_path, '"', 100 | ' -DCMAKE_CXX_COMPILER="', config$gpp_path, '"', 101 | switch(config$os_type, 102 | windows = paste0( 103 | ' -DCMAKE_RC_COMPILER="', config$windres_path, '"', 104 | " -DOpenCV_ARCH=x64", 105 | " -DOpenCV_RUNTIME=mingw", 106 | " -DBUILD_SHARED_LIBS=ON", 107 | " -DCPU_DISPATCH=SSE4_1,SSE4_2,FP16,AV" 108 | ) 109 | ), 110 | ' -DCMAKE_MAKE_PROGRAM="', config$make_path, '"', 111 | " -DCMAKE_CXX_STANDARD=11", 112 | " -DENABLE_PRECOMPILED_HEADERS=OFF", 113 | " -DOPENCV_EXTRA_MODULES_PATH=", config$contrib_dir, 114 | " -DBUILD_LIST=calib3d,core,dnn,features2d,flann,gapi,highgui,imgcodecs,imgproc,ml,objdetect,photo,stitching,video,videoio,ximgproc,wechat_qrcode", 115 | " -DOPENCV_GENERATE_PKGCONFIG=ON", 116 | " -DWITH_OPENMP=ON", 117 | " -DWITH_TBB=ON", 118 | " -DWITH_EIGEN=ON", 119 | " -DWITH_LAPACK=ON", 120 | " -DBUILD_opencv_world=OFF", 121 | " -DBUILD_opencv_contrib_world=OFF", 122 | " -DBUILD_PERF_TESTS=OFF", 123 | " -DBUILD_TESTS=OFF", 124 | ' -DCMAKE_C_FLAGS_RELEASE="-fstack-protector-strong"', 125 | ' -DCMAKE_CXX_FLAGS_RELEASE="-fstack-protector-strong"', 126 | " -DINSTALL_CREATE_DISTRIB=ON", 127 | " -DCMAKE_BUILD_TYPE=RELEASE", 128 | ' -DCMAKE_INSTALL_PREFIX="', config$install_path, '"', 129 | ' -B"', config$build_dir, '"', 130 | ' -H"', config$source_dir, '"' 131 | ) 132 | } 133 | 134 | 135 | #' @title Install OpenCV 136 | #' 137 | #' @description This function attempts to download, compile and install OpenCV 138 | #' on the system. This process will take several minutes. 139 | #' 140 | #' @param install_path A character string indicating the location at which 141 | #' OpenCV should be installed. By default, it is the value returned by 142 | #' \code{\link{defaultOpenCVPath}}. 143 | #' 144 | #' @param batch A boolean indicating whether to skip (\code{TRUE}) or not 145 | #' (\code{FALSE}, the default) the interactive installation dialog. This is 146 | #' useful when OpenCV needs to be installed in a non-interactive environment 147 | #' (e.g., during a batch installation on a server). 148 | #' 149 | #' @return A boolean. 150 | #' 151 | #' @author Simon Garnier, \email{garnier@@njit.edu} 152 | #' 153 | #' @examples 154 | #' \dontrun{ 155 | #' installOpenCV() 156 | #' } 157 | #' 158 | #' @export 159 | installOpenCV <- function(install_path = defaultOpenCVPath(), batch = FALSE) { 160 | install <- 0 161 | pkg_version <- "4.11.0" 162 | 163 | if (interactive()) { 164 | if (isOpenCVInstalled()) { 165 | cv_version <- gsub("Version ", "", opencvVersion()) 166 | 167 | if (pkg_version == cv_version) { 168 | install <- utils::menu( 169 | c("yes", "no"), 170 | title = "OpenCV is already installed on this system. Would you like to reinstall it now? This will take several minutes." 171 | ) 172 | } else { 173 | install <- utils::menu( 174 | c("yes", "no"), 175 | title = "A new version of OpenCV is available. Would you like to install it now? This will take several minutes." 176 | ) 177 | } 178 | } else { 179 | install <- utils::menu( 180 | c("yes", "no"), 181 | title = "OpenCV is not installed on this system. Would you like to install it now? This will take several minutes." 182 | ) 183 | } 184 | } else { 185 | if (batch) { 186 | packageStartupMessage("OpenCV being installed in non-interactive mode!") 187 | install <- 1 188 | } else { 189 | packageStartupMessage("OpenCV can only be installed in interactive mode. To override this in a non-interactive context, use installOpenCV(batch = TRUE).") 190 | } 191 | } 192 | 193 | if (!isCmakeInstalled()) { 194 | install <- 0 195 | } 196 | 197 | if (install == 1) { 198 | config <- .configure(normalizePath(install_path, mustWork = FALSE), pkg_version) 199 | message(paste0("OpenCV will be installed in ", config$install_path)) 200 | old <- try(OpenCVPath(), silent = TRUE) 201 | 202 | if (dir.exists(config$install_path)) { 203 | message("Clearing install path.") 204 | unlink(config$install_path, recursive = TRUE) 205 | } 206 | 207 | if (inherits(config$install_path, "try-error")) { 208 | if (dir.exists(old)) { 209 | message("Removing old OpenCV installation.") 210 | unlink(old, recursive = TRUE) 211 | } 212 | } 213 | 214 | dir.create(config$install_path, showWarnings = FALSE) 215 | dir.create(config$tmp_dir, showWarnings = FALSE) 216 | 217 | if (config$os_type == "windows") { 218 | utils::download.file(config$core, paste0(config$tmp_dir, "/opencv.tar.gz")) 219 | utils::untar(paste0(config$tmp_dir, "/opencv.tar.gz"), exdir = config$tmp_dir) 220 | utils::download.file(config$contrib, paste0(config$tmp_dir, "/opencv_contrib.tar.gz")) 221 | utils::untar(paste0(config$tmp_dir, "/opencv_contrib.tar.gz"), exdir = config$tmp_dir) 222 | } else { 223 | utils::download.file(config$core, paste0(config$tmp_dir, "/opencv.zip")) 224 | utils::unzip(paste0(config$tmp_dir, "/opencv.zip"), exdir = config$tmp_dir) 225 | utils::download.file(config$contrib, paste0(config$tmp_dir, "/opencv_contrib.zip")) 226 | utils::unzip(paste0(config$tmp_dir, "/opencv_contrib.zip"), exdir = config$tmp_dir) 227 | 228 | tmp <- readLines(paste0(config$source_dir, "cmake/OpenCVModule.cmake")) 229 | ix <- which(grepl("# adds dependencies to OpenCV module", tmp)) - 1 230 | insert <- c( 231 | '# set CMAKE_INSTALL_NAME_DIR if CMAKE_INSTALL_PREFIX isn\'t default value of "/usr/local"', 232 | 'if(UNIX AND NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local")', 233 | " set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)", 234 | '# message ("setting CMAKE_INSTALL_NAME_DIR: ${CMAKE_INSTALL_NAME_DIR}")', 235 | "endif()", 236 | "" 237 | ) 238 | writeLines( 239 | c(tmp[1:ix], insert, tmp[(ix + 1):length(tmp)]), 240 | paste0(config$source_dir, "cmake/OpenCVModule.cmake") 241 | ) 242 | } 243 | 244 | # To be removed once the CMake 4 issue is resolved in the next OpenCV release 245 | tmp <- readLines(paste0(config$source_dir, "cmake/OpenCVGenPkgconfig.cmake")) 246 | ix <- which(grepl("cmake_minimum_required", tmp)) 247 | insert <- "cmake_minimum_required(VERSION 3.5)" 248 | writeLines( 249 | c(tmp[1:(ix - 1)], insert, tmp[(ix + 1):length(tmp)]), 250 | paste0(config$source_dir, "cmake/OpenCVGenPkgconfig.cmake") 251 | ) 252 | 253 | dir.create(config$build_dir, showWarnings = FALSE) 254 | system(.cmake(config)) 255 | system(paste0(config$make_path, " -j", parallel::detectCores(), " -C ", config$build_dir)) 256 | system(paste0(config$make_path, " -C", config$build_dir, " install")) 257 | writeLines(config$install_path, con = paste0(config$pkg_path, "/path")) 258 | } else { 259 | packageStartupMessage("OpenCV was not installed at this time. You can install it at any time by using the installOpenCV() function.") 260 | } 261 | 262 | isOpenCVInstalled() 263 | } 264 | 265 | 266 | #' @title Remove OpenCV 267 | #' 268 | #' @description This function removes OpenCV from the system. 269 | #' 270 | #' @return A boolean. 271 | #' 272 | #' @author Simon Garnier, \email{garnier@@njit.edu} 273 | #' 274 | #' @examples 275 | #' \dontrun{ 276 | #' installOpenCV() 277 | #' } 278 | #' 279 | #' @export 280 | removeOpenCV <- function() { 281 | if (isOpenCVInstalled()) { 282 | uninstall <- utils::menu( 283 | c("yes", "no"), 284 | title = "Would you like to completely remove OpenCV from your R installation? You can reinstall it at any time by using the installOpenCV() function." 285 | ) 286 | print(uninstall) 287 | 288 | if (uninstall == 1) { 289 | unlink(OpenCVPath(), recursive = TRUE) 290 | !isOpenCVInstalled() 291 | } else { 292 | !isOpenCVInstalled() 293 | } 294 | } else { 295 | message("OpenCV is not installed on this system. Nothing to be done.") 296 | !isOpenCVInstalled() 297 | } 298 | } 299 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Helper Package for Installing OpenCV with R • ROpenCVLite 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Skip to contents 26 | 27 | 28 |
62 |
63 |
64 | 68 | 69 | 70 | 71 |
72 |

Description 73 |

74 |

ROpenCVLite is a utility package that installs OpenCV within R for use by other packages. This package is not a wrapper around OpenCV (it does not provide access to OpenCV functions in R), not is it a computer vision package for R. All it does is compiling and installing OpenCV within your R installation so that other packages can easily find it and compile against it.

75 |
76 |
77 |
78 |

Quick start guides 79 |

80 |
    81 |
  1. Installing ROpenCVLite
  2. 82 |
  3. Using ROpenCVLite
  4. 83 |
  5. Function documentation
  6. 84 |
85 |
86 |
87 |
88 |

FAQ 89 |

90 |
91 |

What is OpenCV? 92 |

93 |

OpenCV is one of the most - if not the most - popular and efficient open-source computer vision library available today. If you want to develop fast video processing software or implement real time computer vision algorithms, you pretty much have to use OpenCV nowadays.

94 |
95 |
96 |

Why is ROpenCVLite necessary? 97 |

98 |

There are no computer vision package available for R currently. There are some very good image processing packages (see imager for instance) but none of them can handle fast processing of large videos.

99 |

The goal of ROpenCVLite is to promote the development of efficient computer vision packages for R based on OpenCV. ROpenCVLite facilitates the installation of OpenCV in a convenient location for other packages to find it and compile against it.

100 |
101 |
102 |

Couldn’t you just ship OpenCV’s binaries with your package? 103 |

104 |

Yes, but… it is fairly difficult to ship binary files compiled against OpenCV that will work for sure on someone else’s computer. It is not OpenCV’s fault; it is because there are so many video formats and standards for peripherals out there that nobody can be certain what interfaces and libraries will be available on anyone’s computer to grab images from videos and camera streams. The least worst solution for developers is therefore to make sure that there is a copy of OpenCV on each user’s computer that has been compiled taking into account the specificities of said computer.

105 |

HOWEVER…

106 |

OpenCV is notoriously difficult to compile and install from scratch, especially for people without experience with low level languages. This is where ROpenCVLite come into play. This package tries as much as possible to cleanly compile OpenCV and to install it in a standardized location that all R package developers can easily find.

107 |
108 |
109 |

Why “Lite”? Are you keeping something from us? 110 |

111 |

ROpenCVLite compiles and installs the core modules of the OpenCV library but does not compile or install its contributed extra modules. This is to reduce the compilation time (which is already long enough) and also because most of these extra modules are (1) too specific for most applications of OpenCV, and (2) they do not always compile nicely.

112 |

We will work toward providing a mechanism to install the extra modules, but this is not part of our immediate plans.

113 |
114 |
115 |
116 |
160 |
161 | 162 | 163 | 172 |
173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | --------------------------------------------------------------------------------