Articles
36 |All vignettes
40 | 41 | 42 |- 1 - Installing ROpenCVLite 43 |
- 44 |
- 2 - Using ROpenCVLite 45 |
- 46 |
2 |
3 |
4 | [](https://github.com/swarm-lab/ROpenCVLite/actions/workflows/R-CMD-check.yaml)
5 | [](https://app.codecov.io/gh/swarm-lab/ROpenCVLite?branch=master)
6 | [](https://CRAN.R-project.org/package=ROpenCVLite)
7 | [](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} > This function checks that Cmake is installed on the system.
42 |Simon Garnier, garnier@njit.edu
56 |This function checks that OpenCV is installed and accessible.
42 |Simon Garnier, garnier@njit.edu
56 |OpenCVPath()
52 |
53 | ROpenCVLite ROpenCVLite-package
58 |
59 | defaultOpenCVPath()
64 |
65 | installOpenCV()
70 |
71 | isCmakeInstalled()
76 |
77 | isOpenCVInstalled()
82 |
83 | opencvConfig()
88 |
89 | opencvVersion()
94 |
95 | removeOpenCV()
100 |
101 | R/ROpenCVLite.R
41 | ROpenCVLite-package.RdThis 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 |Useful links:
Report bugs at https://github.com/swarm-lab/ROpenCVLite/issues
Simon Garnier, garnier@njit.edu
61 |This function removes OpenCV from the system.
42 |Simon Garnier, garnier@njit.edu
56 |if (FALSE) { # \dontrun{
61 | installOpenCV()
62 | } # }
63 |
64 | This function returns the location at which OpenCV is installed.
42 |Simon Garnier, garnier@njit.edu
56 |This function determines the version of OpenCV installed within 44 | R.
45 |Simon Garnier, garnier@njit.edu
59 |if (isOpenCVInstalled()) {
64 | opencvVersion()
65 | }
66 | #> [1] "Version 4.11.0"
67 |
68 | This function returns the location at which OpenCV should be 44 | installed by default.
45 |Simon Garnier, garnier@njit.edu
59 |vignettes/usage.Rmd
71 | usage.RmdThe 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.
ROpenCVLite
86 | Follow these steps to configure your package for ROpenCVLite:
ROpenCVLite
90 | as a dependency in the DESCRIPTION file of your package.opencvConfig
92 | function provided with ROpenCVLite
93 | to:
94 | PKG_LIBS value of the Makevars and Makevars.win
96 | files of your package (using opencvConfig("libs")).PKG_CPPFLAGS () value of the Makevars and
98 | Makevars.win files of your package (using
99 | opencvConfig("cflags")).You can find an example of how to set up your package with ROpenCVLite
104 | in our Rvision
105 | package:
This function attempts to download, compile and install OpenCV 44 | on the system. This process will take several minutes.
45 |installOpenCV(install_path = defaultOpenCVPath(), batch = FALSE)A character string indicating the location at which
58 | OpenCV should be installed. By default, it is the value returned by
59 | defaultOpenCVPath.
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).
Simon Garnier, garnier@njit.edu
76 |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.
ROpenCVLiteFollow these steps to configure your package for ROpenCVLite:
ROpenCVLite
257 | as a dependency in the DESCRIPTION file of your package.opencvConfig
259 | function provided with ROpenCVLite
260 | to:
261 | PKG_LIBS value of the Makevars and Makevars.win
263 | files of your package (using opencvConfig("libs")).PKG_CPPFLAGS () value of the Makevars and
265 | Makevars.win files of your package (using
266 | opencvConfig("cflags")).You can find an example of how to set up your package with ROpenCVLite
270 | in our Rvision
271 | package:
This function returns the configuration options for compiling
44 | C/C++-based packages against OpenCV installed by ROpenCVLite.
A concatenated character string (with cat) of the
69 | configuration options.
Simon Garnier, garnier@njit.edu
74 |if (FALSE) { # \dontrun{
79 | if (isOpenCVInstalled()) {
80 | opencvConfig()
81 | opencvConfig(output = "cflags")
82 | opencvConfig(arch = R.version$arch)
83 | }
84 | } # }
85 |
86 | 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.
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.
ROpenCVLite necessary?
97 | 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.
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.
OpenCV’s binaries with your package?
103 | 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.
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.
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.
We will work toward providing a mechanism to install the extra modules, but this is not part of our immediate plans.
113 |