在R中工作时无法在Windows OS中安装RopenCVLite

时间:2018-07-05 16:13:32

标签: r windows opencv cmake

我正在尝试在Windows OS中安装RopenCVLite。 我正在Windows 7、64位环境中的RStudio 3.5.0中工作。

我正在关注安装过程教程 https://swarm-lab.github.io/ROpenCVLite/articles/install.html

首先,我在计算机上安装了Cmake。

然后我尝试在R中运行以下代码,以安装“ RopenCVLite”

install.packages("pkgbuild") # pkgbuild is not available (for R version 3.5.0)
install.packages("devtools") # make sure you have the latest version from CRAN
library(devtools) # load package
devtools::install_github("r-lib/pkgbuild") # install updated version of pkgbuild from GitHub
library(pkgbuild) # load package
find_rtools() # should be TRUE, assuming you have Rtools 3.5



devtools::install_github("swarm-lab/ROpenCVLite")

我遇到以下错误

> devtools::install_github("swarm-lab/ROpenCVLite")
Downloading GitHub repo swarm-lab/ROpenCVLite@master
from URL https://api.github.com/repos/swarm-lab/ROpenCVLite/zipball/master
Installing ROpenCVLite
"C:/MANUAL~1/R-35~1.0/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD  \
  INSTALL  \
  "C:/Users/dell/AppData/Local/Temp/Rtmps5sa30/devtools1798506c6333/swarm-lab-ROpenCVLite-b9fcf19"  \
  --library="C:/Manually saved/R-3.5.0/library" --install-tests 

* installing *source* package 'ROpenCVLite' ...
+ set -e
+ mkdir inst/tmp
+ mkdir inst/opencv/
+ cd inst/tmp/
+ Rscript -e 'download.file("https://github.com/opencv/opencv/archive/3.4.1.tar.gz", "opencv-3.4.1.tar.gz")'
trying URL 'https://github.com/opencv/opencv/archive/3.4.1.tar.gz'
Content type 'application/x-gzip' length 87051748 bytes (83.0 MB)
==================================================
downloaded 83.0 MB

+ tar zxvf opencv-3.4.1.tar.gz
+ cp ../cap_dshow.cpp opencv-3.4.1/modules/videoio/src/
+ cd opencv-3.4.1
+ '[' -d C:/MANUAL~1/R-35~1.0/bin/x64 ']'
+ mkdir build64
+ cd build64
+ cmake -G 'Unix Makefiles' -DCMAKE_C_COMPILER=C:/Rtools/mingw_64/bin/gcc.exe -DCMAKE_CXX_COMPILER=C:/Rtools/mingw_64/bin/g++.exe -DCMAKE_RC_COMPILER=C:/Rtools/mingw_64/bin/windres.exe -DCMAKE_MAKE_PROGRAM=C:/Rtools/bin/make.exe -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_opencv_world=OFF -DBUILD_opencv_contrib_world=OFF -DBUILD_matlab=OFF -DPYTHON_EXECUTABLE=OFF -DBUILD_opencv_photo=OFF -DBUILD_PROTOBUF=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=../../../opencv/ ../
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in

CMake Error: Error executing cmake::LoadCache(). Aborting.

ERROR: configuration failed for package 'ROpenCVLite'
* removing 'C:/Manually saved/R-3.5.0/library/ROpenCVLite'
In R CMD INSTALL
Installation failed: Command failed (1)

任何建议总是值得赞赏的。

1 个答案:

答案 0 :(得分:1)

Avjit,希望它仍然可以帮助您安装ROpenCVLite。就在今天,我遇到了类似的错误问题,它显示了

cmake: not found

我能够弄清楚使用命令时安装失败的原因:

devtools::install_github("swarm-lab/ROpenCVLite")

这是因为安装cmake时,它将在Program Files(在我的机器上)下创建自己的Path文件夹。顺序应该是先在根文件夹C上安装Rtools,例如:

 C:\Rtools

安装后,然后安装CMake,但需要将Path文件夹更改为C:\ Rtools,它将在Rtools下创建并安装CMake。此安装消息是我确定顺序的方式。该脚本正在Rtools文件夹下查看CMake:

+ cmake -G 'Unix Makefiles' -DCMAKE_C_COMPILER=C:/Rtools/mingw_64/bin/gcc.exe -DCMAKE_CXX_COMPILER=C:/Rtools/mingw_64/bin/g++.exe -DCMAKE_RC_COMPILER=C:/Rtools/mingw_64/bin/windres.exe -DCMAKE_MAKE_PROGRAM=C:/Rtools/bin/make.exe -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_opencv_world=OFF -DBUILD_opencv_contrib_world=OFF -DBUILD_matlab=OFF -DPYTHON_EXECUTABLE=OFF -DBUILD_opencv_photo=OFF -DBUILD_PROTOBUF=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=../../../opencv/ ../

CMake错误:找不到CMAKE_ROOT !!!

您应该能够安装ROpenCVLite,而不会出现任何问题。希望这会有所帮助,如果有的话,请在复选标记上打上勾。