mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
add documents of CvHaarClassifierCascade
This commit is contained in:
parent
5348bf91de
commit
19b8a74911
4 changed files with 41 additions and 61 deletions
|
@ -11,11 +11,7 @@
|
||||||
/*
|
/*
|
||||||
* Document-class: OpenCV::CvHaarClassifierCascade
|
* Document-class: OpenCV::CvHaarClassifierCascade
|
||||||
*
|
*
|
||||||
* CvHaarClassifierCascade object is "fast-object-detector".
|
* Haar Feature-based Cascade Classifier for Object Detection
|
||||||
* This detector can discover object (e.g. human's face) from image.
|
|
||||||
*
|
|
||||||
* Find face-area from picture "lena"...
|
|
||||||
* link:../images/face_detect_from_lena.jpg
|
|
||||||
*/
|
*/
|
||||||
__NAMESPACE_BEGIN_OPENCV
|
__NAMESPACE_BEGIN_OPENCV
|
||||||
__NAMESPACE_BEGIN_CVHAARCLASSIFERCASCADE
|
__NAMESPACE_BEGIN_CVHAARCLASSIFERCASCADE
|
||||||
|
@ -28,23 +24,6 @@ rb_class()
|
||||||
return rb_klass;
|
return rb_klass;
|
||||||
}
|
}
|
||||||
|
|
||||||
void define_ruby_class()
|
|
||||||
{
|
|
||||||
if (rb_klass)
|
|
||||||
return;
|
|
||||||
/*
|
|
||||||
* opencv = rb_define_module("OpenCV");
|
|
||||||
*
|
|
||||||
* note: this comment is used by rdoc.
|
|
||||||
*/
|
|
||||||
VALUE opencv = rb_module_opencv();
|
|
||||||
|
|
||||||
rb_klass = rb_define_class_under(opencv, "CvHaarClassifierCascade", rb_cObject);
|
|
||||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
|
||||||
rb_define_singleton_method(rb_klass, "load", RUBY_METHOD_FUNC(rb_load), 1);
|
|
||||||
rb_define_method(rb_klass, "detect_objects", RUBY_METHOD_FUNC(rb_detect_objects), -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_allocate(VALUE klass)
|
rb_allocate(VALUE klass)
|
||||||
{
|
{
|
||||||
|
@ -61,18 +40,13 @@ cvhaarclassifiercascade_free(void* ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
|
||||||
* CvHaarClassiferCascade.load(<i>path</i>) -> object-detector
|
|
||||||
*
|
|
||||||
* Load trained cascade of haar classifers from file.
|
* Load trained cascade of haar classifers from file.
|
||||||
* Object detection classifiers are stored in XML or YAML files.
|
|
||||||
* sample of object detection classifier files is included by OpenCV.
|
|
||||||
*
|
*
|
||||||
* You can found these at
|
* @overload load(filename)
|
||||||
* C:\Program Files\OpenCV\data\haarcascades\*.xml (Windows, default install path)
|
* @param filename [String] Haar classifer file name
|
||||||
*
|
* @return [CvHaarClassifierCascade] Object detector
|
||||||
* e.g. you want to try to detect human's face.
|
* @scope class
|
||||||
* detector = CvHaarClassiferCascade.load("haarcascade_frontalface_alt.xml")
|
* @opencv_func cvLoad
|
||||||
*/
|
*/
|
||||||
VALUE
|
VALUE
|
||||||
rb_load(VALUE klass, VALUE path)
|
rb_load(VALUE klass, VALUE path)
|
||||||
|
@ -90,35 +64,23 @@ rb_load(VALUE klass, VALUE path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* Detects objects of different sizes in the input image.
|
||||||
* detect_objects(image[, options]) -> cvseq(include CvAvgComp object)
|
|
||||||
* detect_objects(image[, options]){|cmp| ... } -> cvseq(include CvAvgComp object)
|
|
||||||
*
|
*
|
||||||
* Detects objects in the image. This method finds rectangular regions in the
|
* @overload detect_objects(image, options = nil)
|
||||||
* given image that are likely to contain objects the cascade has been trained
|
* @param image [CvMat,IplImage] Matrix of the type CV_8U containing an image where objects are detected.
|
||||||
* for and return those regions as a sequence of rectangles.
|
* @param options [Hash] Options
|
||||||
*
|
* @option options [Number] :scale_factor
|
||||||
* * <i>option</i> should be Hash include these keys.
|
* Parameter specifying how much the image size is reduced at each image scale.
|
||||||
* :scale_factor (should be > 1.0)
|
* @option options [Number] :storage
|
||||||
* The factor by which the search window is scaled between the subsequent scans,
|
|
||||||
* 1.1 mean increasing window by 10%.
|
|
||||||
* :storage
|
|
||||||
* Memory storage to store the resultant sequence of the object candidate rectangles
|
* Memory storage to store the resultant sequence of the object candidate rectangles
|
||||||
* :flags
|
* @option options [Number] :min_neighbors
|
||||||
* Mode of operation. Currently the only flag that may be specified is CV_HAAR_DO_CANNY_PRUNING .
|
* Parameter specifying how many neighbors each candidate rectangle should have to retain it.
|
||||||
* If it is set, the function uses Canny edge detector to reject some image regions that contain
|
* @option options [CvSize] :min_size
|
||||||
* too few or too much edges and thus can not contain the searched object. The particular threshold
|
* Minimum possible object size. Objects smaller than that are ignored.
|
||||||
* values are tuned for face detection and in this case the pruning speeds up the processing
|
* @option options [CvSize] :max_size
|
||||||
* :min_neighbors
|
* Maximum possible object size. Objects larger than that are ignored.
|
||||||
* Minimum number (minus 1) of neighbor rectangles that makes up an object.
|
* @return [CvSeq<CvAvgComp>] Detected objects as a list of rectangles
|
||||||
* All the groups of a smaller number of rectangles than min_neighbors - 1 are rejected.
|
* @opencv_func cvHaarDetectObjects
|
||||||
* If min_neighbors is 0, the function does not any grouping at all and returns all the detected
|
|
||||||
* candidate rectangles, whitch many be useful if the user wants to apply a customized grouping procedure.
|
|
||||||
* :min_size
|
|
||||||
* Minimum window size. By default, it is set to size of samples the classifier has been
|
|
||||||
* trained on (~20x20 for face detection).
|
|
||||||
* :max_size
|
|
||||||
* aximum window size to use. By default, it is set to the size of the image.
|
|
||||||
*/
|
*/
|
||||||
VALUE
|
VALUE
|
||||||
rb_detect_objects(int argc, VALUE *argv, VALUE self)
|
rb_detect_objects(int argc, VALUE *argv, VALUE self)
|
||||||
|
@ -164,5 +126,23 @@ rb_detect_objects(int argc, VALUE *argv, VALUE self)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
init_ruby_class()
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
// For documentation using YARD
|
||||||
|
VALUE opencv = rb_define_module("OpenCV");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (rb_klass)
|
||||||
|
return;
|
||||||
|
|
||||||
|
VALUE opencv = rb_module_opencv();
|
||||||
|
rb_klass = rb_define_class_under(opencv, "CvHaarClassifierCascade", rb_cObject);
|
||||||
|
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||||
|
rb_define_singleton_method(rb_klass, "load", RUBY_METHOD_FUNC(rb_load), 1);
|
||||||
|
rb_define_method(rb_klass, "detect_objects", RUBY_METHOD_FUNC(rb_detect_objects), -1);
|
||||||
|
}
|
||||||
|
|
||||||
__NAMESPACE_END_CVHAARCLASSIFERCASCADE
|
__NAMESPACE_END_CVHAARCLASSIFERCASCADE
|
||||||
__NAMESPACE_END_OPENCV
|
__NAMESPACE_END_OPENCV
|
||||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVHAARCLASSIFERCASCADE
|
||||||
|
|
||||||
VALUE rb_class();
|
VALUE rb_class();
|
||||||
|
|
||||||
void define_ruby_class();
|
void init_ruby_class();
|
||||||
|
|
||||||
VALUE rb_allocate(VALUE klass);
|
VALUE rb_allocate(VALUE klass);
|
||||||
|
|
||||||
|
|
|
@ -711,7 +711,7 @@ extern "C" {
|
||||||
|
|
||||||
mOpenCV::cCvConnectedComp::init_ruby_class();
|
mOpenCV::cCvConnectedComp::init_ruby_class();
|
||||||
mOpenCV::cCvAvgComp::init_ruby_class();
|
mOpenCV::cCvAvgComp::init_ruby_class();
|
||||||
mOpenCV::cCvHaarClassifierCascade::define_ruby_class();
|
mOpenCV::cCvHaarClassifierCascade::init_ruby_class();
|
||||||
mOpenCV::mGUI::define_ruby_module();
|
mOpenCV::mGUI::define_ruby_module();
|
||||||
mOpenCV::mGUI::cWindow::define_ruby_class();
|
mOpenCV::mGUI::cWindow::define_ruby_class();
|
||||||
mOpenCV::mGUI::cTrackbar::define_ruby_class();
|
mOpenCV::mGUI::cTrackbar::define_ruby_class();
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
Loading…
Reference in a new issue