This is a sample collector for my gestures-based human-computer/robot interaction project, but also can be used to collect any samples using web-cam for general use.
It depends on Qt and Opencv, and sample images using a webcam.
Run
mkdir build
cd build
cmake ..
make
The sample collector program depends on Qt5 (with Qt5Core and Qt5Widgets) and OpenCV 3 (with the libs opencv_core, opencv_video, opencv_videoio, opencv_imgproc and opencv_imgcodecs).
After compilation, an executable file named collector
will be generated in the bin
folder. Just run it.
During sampling, in the folder specified by you, two directories will be made. One directory is used to store BMP
images obtained by sampling through the webcam, while the other directory is used to store PGM
images who are generated through extracting hand regions from the corresponding BMP
images.
The PGM
images are generated by the function HandDetector::detect
defiend in src/HandDetector.cpp
. Basically, a PGM
image is generated through
-
Color filtering
-
7X7 Gaussian blurring with variance 0.8
-
Thresholding: set white color for pixels whose gray-scaled value is greater than 10 out of 255
-
Morphological transformation: opening first and then closing, both with a 9x9 kernel with the following shape
`0, 0, 0, 0, 1, 0, 0, 0, 0` `0, 1, 1, 1, 1, 1, 1, 1, 0` `0, 1, 1, 1, 1, 1, 1, 1, 0` `1, 1, 1, 1, 1, 1, 1, 1, 1` `1, 1, 1, 1, 1, 1, 1, 1, 1` `1, 1, 1, 1, 1, 1, 1, 1, 1` `0, 1, 1, 1, 1, 1, 1, 1, 0` `0, 1, 1, 1, 1, 1, 1, 1, 0` `0, 0, 0, 0, 1, 0, 0, 0, 0`