Skip to content

Commit ed32932

Browse files
authored
Merge pull request #51 from swarm-lab/develop
Upgrade to OpenCV 4.11 and CMake 4
2 parents db7fb52 + 4e9ac45 commit ed32932

38 files changed

+674
-891
lines changed

.github/workflows/test-coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1616

1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919

2020
- uses: r-lib/actions/setup-r@v2
2121
with:
@@ -54,7 +54,7 @@ jobs:
5454

5555
- name: Upload test results
5656
if: failure()
57-
uses: actions/upload-artifact@v3
57+
uses: actions/upload-artifact@v4
5858
with:
5959
name: coverage-test-failures
6060
path: ${{ runner.temp }}/package

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: ROpenCVLite
22
Type: Package
33
Title: Helper Package for Installing OpenCV with R
4-
Version: 4.90.2
5-
Date: 2024-08-01
4+
Version: 4.110.0
5+
Date: 2025-05-01
66
Authors@R: c(
77
person("Simon", "Garnier", email = "[email protected]", role = c("aut", "cre"),
88
comment = c(ORCID = "0000-0002-3886-3974")),

NEWS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
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+
113
# ROpenCVLite 4.90.2
214

315
## New features

R/install.R

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#'
1010
#' @examples
1111
#' \dontrun{
12-
#' defaultOpenCVPath()
12+
#' defaultOpenCVPath()
1313
#' }
1414
#'
1515
#' @export
@@ -23,15 +23,16 @@ defaultOpenCVPath <- function() {
2323
config <- list()
2424

2525
config$arch <- unname(Sys.info()["machine"])
26-
if (!grepl("64", config$arch))
26+
if (!grepl("64", config$arch)) {
2727
stop("Unsupported CPU architecture.")
28+
}
2829

2930
config$os_type <- .Platform$OS.type
3031

3132
if (config$os_type == "windows") {
3233
config$install_path <- utils::shortPathName(install_path)
3334
config$pkg_path <- utils::shortPathName(find.package("ROpenCVLite"))
34-
config$os <- gsub("\r", "", gsub("Caption=", "", system('wmic os get Caption,CSDVersion /value', intern = TRUE)[3]))
35+
config$os <- gsub("\r", "", gsub("Caption=", "", system("wmic os get Caption,CSDVersion /value", intern = TRUE)[3]))
3536
config$core <- paste0("https://github.com/opencv/opencv/archive/", version, ".tar.gz")
3637
config$contrib <- paste0("https://github.com/opencv/opencv_contrib/archive/", version, ".tar.gz")
3738
rtools <- .findRtools()
@@ -94,34 +95,36 @@ defaultOpenCVPath <- function() {
9495
paste0(
9596
'"', config$cmake_path, '"',
9697
' -G "Unix Makefiles"',
97-
' -Wno-dev',
98+
" -Wno-dev",
9899
' -DCMAKE_C_COMPILER="', config$gcc_path, '"',
99100
' -DCMAKE_CXX_COMPILER="', config$gpp_path, '"',
100101
switch(config$os_type,
101-
windows = paste0(' -DCMAKE_RC_COMPILER="', config$windres_path, '"',
102-
' -DOpenCV_ARCH=x64',
103-
' -DOpenCV_RUNTIME=mingw',
104-
' -DBUILD_SHARED_LIBS=ON',
105-
' -DCPU_DISPATCH=SSE4_1,SSE4_2,FP16,AV')
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+
)
106109
),
107110
' -DCMAKE_MAKE_PROGRAM="', config$make_path, '"',
108-
' -DCMAKE_CXX_STANDARD=11',
109-
' -DENABLE_PRECOMPILED_HEADERS=OFF',
110-
' -DOPENCV_EXTRA_MODULES_PATH=', config$contrib_dir,
111-
' -DBUILD_LIST=calib3d,core,dnn,features2d,flann,gapi,highgui,imgcodecs,imgproc,ml,objdetect,photo,stitching,video,videoio,ximgproc,wechat_qrcode',
112-
' -DOPENCV_GENERATE_PKGCONFIG=ON',
113-
' -DWITH_OPENMP=ON',
114-
' -DWITH_TBB=ON',
115-
' -DWITH_EIGEN=ON',
116-
' -DWITH_LAPACK=ON',
117-
' -DBUILD_opencv_world=OFF',
118-
' -DBUILD_opencv_contrib_world=OFF',
119-
' -DBUILD_PERF_TESTS=OFF',
120-
' -DBUILD_TESTS=OFF',
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",
121124
' -DCMAKE_C_FLAGS_RELEASE="-fstack-protector-strong"',
122125
' -DCMAKE_CXX_FLAGS_RELEASE="-fstack-protector-strong"',
123-
' -DINSTALL_CREATE_DISTRIB=ON',
124-
' -DCMAKE_BUILD_TYPE=RELEASE',
126+
" -DINSTALL_CREATE_DISTRIB=ON",
127+
" -DCMAKE_BUILD_TYPE=RELEASE",
125128
' -DCMAKE_INSTALL_PREFIX="', config$install_path, '"',
126129
' -B"', config$build_dir, '"',
127130
' -H"', config$source_dir, '"'
@@ -149,15 +152,13 @@ defaultOpenCVPath <- function() {
149152
#'
150153
#' @examples
151154
#' \dontrun{
152-
#' installOpenCV()
155+
#' installOpenCV()
153156
#' }
154157
#'
155158
#' @export
156159
installOpenCV <- function(install_path = defaultOpenCVPath(), batch = FALSE) {
157160
install <- 0
158-
pkg_version <- paste0(
159-
strsplit(as.character(utils::packageVersion("ROpenCVLite")), "")[[1]][c(1, 3, 4)],
160-
collapse = ".")
161+
pkg_version <- "4.11.0"
161162

162163
if (interactive()) {
163164
if (isOpenCVInstalled()) {
@@ -166,16 +167,19 @@ installOpenCV <- function(install_path = defaultOpenCVPath(), batch = FALSE) {
166167
if (pkg_version == cv_version) {
167168
install <- utils::menu(
168169
c("yes", "no"),
169-
title = "OpenCV is already installed on this system. Would you like to reinstall it now? This will take several minutes.")
170+
title = "OpenCV is already installed on this system. Would you like to reinstall it now? This will take several minutes."
171+
)
170172
} else {
171173
install <- utils::menu(
172174
c("yes", "no"),
173-
title = "A new version of OpenCV is available. Would you like to install it now? This will take several minutes.")
175+
title = "A new version of OpenCV is available. Would you like to install it now? This will take several minutes."
176+
)
174177
}
175178
} else {
176179
install <- utils::menu(
177180
c("yes", "no"),
178-
title = "OpenCV is not installed on this system. Would you like to install it now? This will take several minutes.")
181+
title = "OpenCV is not installed on this system. Would you like to install it now? This will take several minutes."
182+
)
179183
}
180184
} else {
181185
if (batch) {
@@ -186,8 +190,9 @@ installOpenCV <- function(install_path = defaultOpenCVPath(), batch = FALSE) {
186190
}
187191
}
188192

189-
if (!isCmakeInstalled())
193+
if (!isCmakeInstalled()) {
190194
install <- 0
195+
}
191196

192197
if (install == 1) {
193198
config <- .configure(normalizePath(install_path, mustWork = FALSE), pkg_version)
@@ -225,15 +230,26 @@ installOpenCV <- function(install_path = defaultOpenCVPath(), batch = FALSE) {
225230
insert <- c(
226231
'# set CMAKE_INSTALL_NAME_DIR if CMAKE_INSTALL_PREFIX isn\'t default value of "/usr/local"',
227232
'if(UNIX AND NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local")',
228-
' set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)',
233+
" set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)",
229234
'# message ("setting CMAKE_INSTALL_NAME_DIR: ${CMAKE_INSTALL_NAME_DIR}")',
230-
'endif()',
231-
''
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")
232241
)
233-
writeLines(c(tmp[1:ix], insert, tmp[(ix + 1):length(tmp)]),
234-
paste0(config$source_dir, "cmake/OpenCVModule.cmake"))
235242
}
236243

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+
237253
dir.create(config$build_dir, showWarnings = FALSE)
238254
system(.cmake(config))
239255
system(paste0(config$make_path, " -j", parallel::detectCores(), " -C ", config$build_dir))
@@ -257,15 +273,16 @@ installOpenCV <- function(install_path = defaultOpenCVPath(), batch = FALSE) {
257273
#'
258274
#' @examples
259275
#' \dontrun{
260-
#' installOpenCV()
276+
#' installOpenCV()
261277
#' }
262278
#'
263279
#' @export
264280
removeOpenCV <- function() {
265281
if (isOpenCVInstalled()) {
266282
uninstall <- utils::menu(
267283
c("yes", "no"),
268-
title = "Would you like to completely remove OpenCV from your R installation? You can reinstall it at any time by using the installOpenCV() function.")
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+
)
269286
print(uninstall)
270287

271288
if (uninstall == 1) {

cran-comments.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
## Test environments
22

3-
* local M1 OS X 14.5, R 4.0.5, 4.1.3, 4.2.3, 4.3.2, 4.4.1, R devel
4-
* local Windows 10, R 4.0.5, 4.1.3, 4.2.3, 4.3.2, 4.4.1, R devel
5-
* local Windows 11, R 4.0.5, 4.1.3, 4.2.3, 4.3.2, 4.4.1, R devel
6-
* local Ubuntu 24.04, R 4.0.5, 4.1.3, 4.2.3, 4.3.2, 4.4.1, R devel
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
76
* Github Actions "windows-latest (release)"
87
* Github Actions "macOS-latest (release)"
98
* Github Actions "ubuntu-latest (release)"
109
* Github Actions "ubuntu-latest (devel)"
1110
* Github Actions "ubuntu-latest (oldrel-1)"
12-
* r-hub ubuntu-latest on GitHub
13-
* r-hub macos-13 on GitHub
14-
* r-hub macos-latest on GitHub
15-
* r-hub windows-latest on GitHub
1611
* win-builder.r-project.org
1712

1813
## R CMD check results

docs/404.html

Lines changed: 26 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)