bnosac / dlib Goto Github PK
View Code? Open in Web Editor NEWallowing R users to work with dlib through Rcpp
allowing R users to work with dlib through Rcpp
The link from README.md to https://github.com/bnosac/image.dlib is broken.
It seems that conversions of exit()
, abort()
, std::cout
and std::cerr
into Rcpp equivalents have been done for complying to CRAN rules. But I just ran into this error again when CRAN-checking one of my packages the links to dlib. It seems assert()
is prohibited as well by CRAN but it is still in use in dlib as far as I understand.
Hi! I'm really interested in using dlib's find_max_global
from R, so I tried to install the package but I ran into errors. Here's my sessionInfo()
and the logs from my second installation attempt. (My first gave me a lot of errors related to JPEG loading, so I removed -DDLIB_JPEG_SUPPORT
in Makevars)
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 rstudioapi_0.8 magrittr_1.5 usethis_1.4.0 devtools_2.0.1 pkgload_1.0.2
[7] R6_2.3.0 rlang_0.3.1 tools_3.5.2 pkgbuild_1.0.2 sessioninfo_1.1.1 cli_1.0.1
[13] withr_2.1.2 remotes_2.0.2 yaml_2.2.0 assertthat_0.2.0 digest_0.6.18 rprojroot_1.3-2
[19] crayon_1.3.4 processx_3.2.0 callr_3.0.0 base64enc_0.1-3 fs_1.2.6 ps_1.2.1
[25] testthat_2.0.1 glue_1.3.0 memoise_1.1.0 compiler_3.5.2 desc_1.2.0 backports_1.1.2
[31] prettyunits_1.0.2
> devtools::install_local('~/lib/dlib/')
✔ checking for file ‘/private/var/folders/tk/pjpslqns2z36gd_64m23j2kx__t6v6/T/RtmpI1e9Tz/filecea31e5fc152/dlib/DESCRIPTION’ ...
─ preparing ‘dlib’: (595ms)
✔ checking DESCRIPTION meta-information
─ cleaning src
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘dlib_1.1.tar.gz’
Warning: invalid uid value replaced by that for user 'nobody'
Warning: invalid gid value replaced by that for user 'nobody'
* installing *source* package ‘dlib’ ...
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -include r_cmd_check_happiness.h -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -DDLIB_PNG_SUPPORT -DDLIB_NO_GUI_SUPPORT -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -include r_cmd_check_happiness.h -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -DDLIB_PNG_SUPPORT -DDLIB_NO_GUI_SUPPORT -fPIC -Wall -g -O2 -c dlib-core.cpp -o dlib-core.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -include r_cmd_check_happiness.h -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -DDLIB_PNG_SUPPORT -DDLIB_NO_GUI_SUPPORT -fPIC -Wall -g -O2 -c dlib-example.cpp -o dlib-example.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -include r_cmd_check_happiness.h -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -I../inst/include -DDLIB_PNG_SUPPORT -DDLIB_NO_GUI_SUPPORT -fPIC -Wall -g -O2 -c r_cmd_check_happiness.cc -o r_cmd_check_happiness.o
clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/clang4/lib -o dlib.so RcppExports.o dlib-core.o dlib-example.o r_cmd_check_happiness.o -lpng -lz -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/dlib/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
sh: line 1: 53608 Segmentation fault: 11 '/Library/Frameworks/R.framework/Resources/bin/R' --no-save --slave 2>&1 < '/var/folders/tk/pjpslqns2z36gd_64m23j2kx__t6v6/T//RtmpdVwV4F/filed11e39c17dce'
*** caught segfault ***
address 0xffffffffffffffe8, cause 'memory not mapped'
Traceback:
1: dyn.load(file, DLLpath = DLLpath, ...)
2: library.dynam(lib, package, package.lib)
3: loadNamespace(package, lib.loc)
4: doTryCatch(return(expr), name, parentenv, handler)
5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
6: tryCatchList(expr, classes, parentenv, handlers)
7: tryCatch({ attr(package, "LibPath") <- which.lib.loc ns <- loadNamespace(package, lib.loc) env <- attachNamespace(ns, pos = pos, deps)}, error = function(e) { P <- if (!is.null(cc <- conditionCall(e))) paste(" in", deparse(cc)[1L]) else "" msg <- gettextf("package or namespace load failed for %s%s:\n %s", sQuote(package), P, conditionMessage(e)) if (logical.return) message(paste("Error:", msg), domain = NA) else stop(msg, call. = FALSE, domain = NA)})
8: library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE)
9: withCallingHandlers(expr, packageStartupMessage = function(c) invokeRestart("muffleMessage"))
10: suppressPackageStartupMessages(library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE))
11: doTryCatch(return(expr), name, parentenv, handler)
12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
13: tryCatchList(expr, classes, parentenv, handlers)
14: tryCatch(expr, error = function(e) { call <- conditionCall(e) if (!is.null(call)) { if (identical(call[[1L]], quote(doTryCatch))) call <- sys.call(-4L) dcall <- deparse(call)[1L] prefix <- paste("Error in", dcall, ": ") LONG <- 75L sm <- strsplit(conditionMessage(e), "\n")[[1L]] w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w") if (is.na(w)) w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L], type = "b") if (w > LONG) prefix <- paste0(prefix, "\n ") } else prefix <- "Error : " msg <- paste0(prefix, conditionMessage(e), "\n") .Internal(seterrmessage(msg[1L])) if (!silent && isTRUE(getOption("show.error.messages"))) { cat(msg, file = outFile) .Internal(printDeferredWarnings()) } invisible(structure(msg, class = "try-error", condition = e))})
15: try(suppressPackageStartupMessages(library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE)))
16: tools:::.test_load_package("dlib", "/Library/Frameworks/R.framework/Versions/3.5/Resources/library")
An irrecoverable exception occurred. R is aborting now ...
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/dlib’
Error in i.p(...) :
(converted from warning) installation of package ‘/var/folders/tk/pjpslqns2z36gd_64m23j2kx__t6v6/T//RtmpI1e9Tz/filecea387c6070/dlib_1.1.tar.gz’ had non-zero exit status
Thank you very much for this package! I want to do constrained optimization with Rcpp and found this package helpful.
I would like to test the examples given in optimization_ex.cpp.html (http://dlib.net/optimization_ex.cpp.html) in Rcpp but got the following message:
no matching constructor for initialization of 'dlib::matrix<double,0,1,
dlib::memory_manager_stateless_kernel_1,dlib::row_major_layout>'
Below are my codes:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::depends(dlib)]]
#include <dlib/optimization.h>
using namespace dlib;
using namespace std;
typedef matrix<double,0,1> column_vector;
// [[Rcpp::export]]
double rosen (const column_vector& m)
{
//const column_vector m;
//const double x = m(0);
//const double y = m(1);
const double x = 1;
const double y = 1;
double res = 100.0pow(y - xx,2) + pow(1 - x,2);
return(res);
}
Can you provide me with some guidance on the problem? Thanks.
Hello,
Thanks for the package.
I tried to use this package to face detection, but it does not works as expected:
I use very simple example:
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::depends(dlib)]]
#include <Rcpp.h>
#include <iostream>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_io.h>
using namespace Rcpp;
//' @title Detect face
//'
//' @param file Path to image file
//'
//' @export
//'
// [[Rcpp::export]]
void face_detect(std::string file) {
dlib::frontal_face_detector detector = dlib::get_frontal_face_detector();
dlib::array2d<unsigned char> img;
dlib::load_image(img, file);
std::vector<dlib::rectangle> dets = detector(img);
std::cout << "Number of faces detected: " << dets.size() << std::endl;
}
And Makevars:
CXX_STD = CXX11
PKG_CPPFLAGS = -DENABLE_ASSERTS
PKG_LIBS = -lpthread -lX11
My installation output below:
> devtools::install()
✔ checking for file ‘/home/xxx/projects/R/packages/RFace/DESCRIPTION’ ...
─ preparing ‘RFace’:
✔ checking DESCRIPTION meta-information ...
─ cleaning src
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
Removed empty directory ‘RFace/inst/extdata’
Removed empty directory ‘RFace/inst’
Removed empty directory ‘RFace/man’
─ building ‘RFace_0.1.0.tar.gz’
Running /usr/lib64/R/bin/R CMD INSTALL /tmp/Rtmp7mY9II/RFace_0.1.0.tar.gz --install-tests
* installing to library ‘/home/xxx/R/x86_64-pc-linux-gnu-library/3.5’
* installing *source* package ‘RFace’ ...
** libs
clang++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG -DENABLE_ASSERTS -I"/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I"/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/dlib/include" -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG -DENABLE_ASSERTS -I"/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I"/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/dlib/include" -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c face_detection.cpp -o face_detection.o
clang++ -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o RFace.so RcppExports.o face_detection.o -lpthread -lX11 -L/usr/lib64/R/lib -lR
installing to /home/xxx/R/x86_64-pc-linux-gnu-library/3.5/RFace/libs
** R
** byte-compile and prepare package for lazy loading
** help
No man pages found in package ‘RFace’
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘RFace’ in dyn.load(file, DLLpath = DLLpath, ...):
не могу загрузить разделяемый объект '/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/RFace/libs/RFace.so':
/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/RFace/libs/RFace.so: undefined symbol: _ZN4dlib6base64D1Ev
Ошибка: загрузка не удалась
Выполнение остановлено
ERROR: loading failed
* removing ‘/home/xxx/R/x86_64-pc-linux-gnu-library/3.5/RFace’
Should I compile dlib and link with it? How can I do it using this package?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.