swarm-lab / ROpenCVLite

Utility package to install OpenCV in R
https://swarm-lab.github.io/ROpenCVLite/
GNU General Public License v3.0
53 stars 17 forks source link

opencv_world causes installtion problems if VTK detected #2

Closed tractatus closed 7 years ago

tractatus commented 7 years ago

I would suggest that BUILD_opencv_world: false BUILD_opencv_contrib_world: false As well as other stuff such as python or matlab since the primarly use of this package is opencv with R.

-- Processing WORLD modules...
--     module opencv_core...
--     module opencv_flann...
--     module opencv_imgproc...
--     module opencv_ml...
--     module opencv_photo...
--     module opencv_video...
--     module opencv_viz...
CMake Error at cmake/OpenCVUtils.cmake:886 (target_link_libraries):
  Cannot specify link libraries for target "opencv_world" which is not built
  by this project.
Call Stack (most recent call first):
  modules/viz/CMakeLists.txt:10 (ocv_target_link_libraries)
  modules/world/CMakeLists.txt:13 (include)
  modules/world/CMakeLists.txt:26 (include_one_module)
sjmgarnier commented 7 years ago

@tractatus Thanks for your input. Just to be certain, you suggest to add the following to the cmake compilation command:

-DBUILD_opencv_world=OFF -DBUILD_opencv_contrib_world=OFF -DBUILD_matlab=OFF -DBUILD_PYTHON=OFF

Correct?

tractatus commented 7 years ago

@sjmgarnier yes. But its not a pull request more of a suggestion on how to maybe push this nice initiative forward :). I'm interested in maybe devote time to maintaining this R package.

Currently a fixed URL to github archive is used (I can see this as a potential future weakness). Rscript -e 'download.file("https://github.com/opencv/opencv/archive/3.2.0.zip", "opencv-3.2.0.zip")'

When unzipped this directory contains a CMakeList.txt and several .cmake files. For my taste current OpenCV archive is a little bit to much content for what one really want to do with OpenCV in R (mainly handling large image/video files and writing Rcpp extensions). Both Apple and CMake are currently undergoing some major security changes especially with regard to how /usr/local/lib is handled and this could be a major pain in the ass to cater to.

I would be very interested in maybe develop your R package ROpenCVLite so it uses a mirror (that we set up) to fetch a more minimalistic version of OpenCV.

A second long term goal would be an even more minimalistic opencv/R build that could include shared libraries for -lopencv_core -lopencv_highgui and -lopencv_imgproci that could even be distributed on CRAN.

sjmgarnier commented 7 years ago

@tractatus I've implemented it. Once I find the time to test that it compiles on Mac (already done, it works), Linux, and Windows, I'll push the changes to the repository.

I agree with you that I took the heavy route for installing OpenCV. I'm not an OpenCV specialist by any standards, but I was tired of having to switch between Python (or Matlab) to get my data and R to analyze it. So, I decided to start this thing to get a more streamlined data pipeline. I'd be happy to get all the help I can to move this project forward.

Regarding /usr/local/lib, it is not used by ROpenCVLite. ROpenCVLite installs OpenCV inside the R package directly. I did this for two reasons mainly:

  1. I didn't want to mess with people's setup (especially if they want to install OpenCV separately for other projects);

  2. I wanted to have a standardized location for R developers to find OpenCV across platforms (it's easy in this case since you just have to either search the installed package, or use ROpenCVLite's functions to set compilation flags and libraries automatically).

As I said, I'm more and end-user of OpenCV, so I've came up with a solution that I could understand, rather than the best solution possible. Any help and/or advice will certainly be very much appreciated.