Skip to content

Commit

Permalink
Exposes isOpenCVInstalled.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjmgarnier committed May 15, 2019
1 parent e7c0a34 commit 87aea72
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 7 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(installOpenCV)
export(isOpenCVInstalled)
export(opencvConfig)
export(opencvVersion)
21 changes: 16 additions & 5 deletions R/opencv.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
.isOpenCVInstalled <- function() {
#' @title Check OpenCV Installation
#'
#' @description This functions checks that OpenCV is installed within the R
#' library.
#'
#' @return A boolean indicating whether OpenCV was or not installed on the system.
#'
#' @author Simon Garnier, \email{garnier@@njit.edu}
#'
#' @export
isOpenCVInstalled <- function() {
pkgPath <- find.package("ROpenCVLite")
dir.exists(paste0(pkgPath, "/opencv/include/"))
}


#' @title Install OpenCV
#'
#' @description This function will attempt to download, compile and install
Expand All @@ -26,7 +37,7 @@ installOpenCV <- function(force = FALSE) {

if (force) {
install <- 1
} else if (.isOpenCVInstalled()) {
} else if (isOpenCVInstalled()) {
if (interactive()) {
install <- utils::menu(c("yes", "no"), title = "Do you want to reinstall OpenCV on this system? This will take several minutes.")
}
Expand Down Expand Up @@ -104,7 +115,7 @@ installOpenCV <- function(force = FALSE) {
message("OpenCV was not installed at this time. You can install it at any time by using the installOpenCV() function.")
}

.isOpenCVInstalled()
isOpenCVInstalled()
}


Expand All @@ -119,7 +130,7 @@ installOpenCV <- function(force = FALSE) {
#'
#' @export
opencvVersion <- function() {
if (.isOpenCVInstalled()) {
if (isOpenCVInstalled()) {
pkgPath <- find.package("ROpenCVLite")

if (.Platform$OS.type == "windows") {
Expand Down Expand Up @@ -155,7 +166,7 @@ opencvVersion <- function() {
#'
#' @export
opencvConfig <- function(output = "libs", arch = NULL) {
if (!.isOpenCVInstalled())
if (!isOpenCVInstalled())
stop("OpenCV is not installed on this system. Please use installOpenCV() to install it.")

pkgPath <- find.package("ROpenCVLite")
Expand Down
6 changes: 6 additions & 0 deletions docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

203 changes: 203 additions & 0 deletions docs/reference/isOpenCVInstalled.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<url>
<loc>https://swarm-lab.github.io/ROpenCVLite//reference/installOpenCV.html</loc>
</url>
<url>
<loc>https://swarm-lab.github.io/ROpenCVLite//reference/isOpenCVInstalled.html</loc>
</url>
<url>
<loc>https://swarm-lab.github.io/ROpenCVLite//reference/opencvConfig.html</loc>
</url>
Expand Down
18 changes: 18 additions & 0 deletions man/isOpenCVInstalled.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions vignettes/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ <h2>1 - Before installing</h2>
<h3>1.1 - Windows</h3>
<p>Before installing <code>ROpenCVLite</code>, you will need to install the latest versions of <a href="https://cmake.org/"><code>CMake</code></a> and <a href="https://cran.r-project.org/bin/windows/Rtools/"><code>Rtools</code></a>.</p>
<p>Download <code>CMake</code> for Windows at <a href="https://cmake.org/download/">https://cmake.org/download/</a>.</p>
<p>Download the latest “frozen” version of <code>Rtools</code> at <a href="https://cran.r-project.org/bin/windows/Rtools/">https://cran.r-project.org/bin/windows/Rtools/</a>.</p>
<p>Download the latest “recommended” version of <code>Rtools</code> at <a href="https://cran.r-project.org/bin/windows/Rtools/">https://cran.r-project.org/bin/windows/Rtools/</a>.</p>
<p>In both cases, make sure to tell the installer to add <code>CMake</code> and <code>Rtools</code> to your “PATH”.</p>
</div>
<div id="mac" class="section level3">
Expand Down Expand Up @@ -360,8 +360,13 @@ <h3>1.4 - Mac, Linux and Windows</h3>
</div>
<div id="installing-ropencvlite" class="section level2">
<h2>2 - Installing <code>ROpenCVLite</code></h2>
<p>You can install <code>ROpenCVLite</code> from its Github repository as follows:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1">devtools<span class="op">::</span><span class="kw">install_github</span>(<span class="st">&quot;swarm-lab/ROpenCVLite&quot;</span>)</a></code></pre></div>
<p>This step can take some time. Go make yourself a cup of coffee or two.</p>
<p>This will not install <code>OpenCV</code> yet. You will be asked whether you want to install it the first time you load the package.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1"><span class="kw">library</span>(ROpenCVLite)</a></code></pre></div>
<p>This step can take some time. Go make yourself a cup of coffee or two while <code>ROpenCVLite</code> downloads, compiles and installs <code>OpenCV</code> on your system.</p>
<p>In addition, you can also request the (re)installation of <code>OpenCV</code> at any time as follows:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">ROpenCVLite<span class="op">::</span><span class="kw">installOpenCV</span>()</a></code></pre></div>
</div>


Expand Down

0 comments on commit 87aea72

Please sign in to comment.