cvDetect : Simple OpenCV Image/Webcam Detections for R
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) )
Related tool/package/library versions for creating this package
Winodws 7 OS 64 bit
Install cvDetect binary package (Windows only)
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.
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.
d:\ROpencv\x64\mingw\bin;d:\ROpencv\x86\mingw\bin;............... or only d:\ROpencv\x64\mingw\bin;...............
In R, install zip file via "Install package(s) from local files..." menu
Compile and install cvDetect source package (Windows only)
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.
Suppose we save cvDetect_0.1.1.tar.gz under d:\temp directory:
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)
Original C++ detection source codes used in cvDetect
Face detection: OpenCV library demo code
Hand/Palm detection: by Andol Li
Finger detection: by Abner Matheus