Simple R package for OpenCV face/hand/finger detection demo, with the help of ROpenCVLite and Rcpp packages. Currently Windows only.
(Also check http://steve-chen.tw/?p=737 (Traditional Chinese page) )
Winodws 7 OS 64 bit
R: 3.4.0
Rtools: Rtools34.exe
Rcpp: 0.12.10
OpenCV: 3.2.0
ROpenCVLite: 0.1.1
-
Download ROpencv_x64.zip +/- ROpencv_x86_part.zip
These are compiled OpenCV 3.2.0 binaries/libraries for Windows by Rtools34 mingw G++, using ROpenCVLite package.
ROpencv_x64.zip includes etc, include, and x64 sub-directories.
ROpencv_x86.zip only includes x87 sub-directory
-
Uncompress zip file(s) in some directory, e.g., d:\ROpencv
Under d:\ROpencv, there should be etc, include, x64, and/or x86 subdirectories.
Note:
If you feel uncomfortable to download binary files in 1. and 2. in this page, you can build them yourself by installing ROpenCVLite package and copy all the files and sub-directories under the compiled "opencv" directory it builds to a new directory (e.g. d:\ROpencv). The compiled "opencv" directory can be located in, e.g., d:\R\R-3.4.0\library\ROpenCVLite .
-
Modify PATH environment variable via Windows Control Panel:
add ROpencv binray directories to PATH environment variable.
This ensures R to find related OpenCV dll files when running cvDetect.
e.g.
d:\ROpencv\x64\mingw\bin;d:\ROpencv\x86\mingw\bin;............... or only d:\ROpencv\x64\mingw\bin;...............
-
Download cvDetect_0.1.1.zip:
In R, install zip file via "Install package(s) from local files..." menu
We have to install Rtools if we want to compile cvDetect from source.
-
Follow Stepe 1 to Step 3 in above binary package installation procedure.
-
Add an OPENCV environment variable via Windows Control Panel:
add, e.g., "d:\Ropencv" , to a new OPENCV environment variable.
This OPENCV environment varible is used in Makevars.win inside src directory.
-
Download cvDetect_0.1.1.tar.gz in this page.
-
In R:
Suppose we save cvDetect_0.1.1.tar.gz under d:\temp directory:
install.packages("d:/temp/cvDetect_0.1.1.tar.gz",repos=NULL,type="source")
Enter 'q' or 'Q' to stop these funcitons.
If cameraId = 0 does not work, try 1, 2,....
library(cvDetect) ?face_detect ?hand_detect ?finger_detect # face detection via webcam face_detect(cameraId=0) # face detection in Photo face_detect(imgFile="d:/pic/somePeople.jpg") # hand/palm detection via webcam hand_detect(cameraId=0) # finger detection via webcam finger_detect(cameraId=0)
Face detection: OpenCV library demo code
https://github.com/opencv/opencv_attic/blob/master/opencv/samples/cpp/multicascadeclassifier.cpp
Hand/Palm detection: by Andol Li
https://www.andol.me/1830/detecting-hand-gestures-using-haarcascades-training/
Finger detection: by Abner Matheus
https://picoledelimao.github.io/blog/2015/11/15/fingertip-detection-on-opencv/