skimage2.feature.Cascade#

class skimage2.feature.Cascade#

Bases: object

Class for cascade of classifiers that is used for object detection.

The main idea behind cascade of classifiers is to create classifiers of medium accuracy and ensemble them into one strong classifier instead of just creating a strong one. The second advantage of cascade classifier is that easy examples can be classified only by evaluating some of the classifiers in the cascade, making the process much faster than the process of evaluating a one strong classifier.

Attributes:
epscnp.float32_t

Accuracy parameter. Increasing it, makes the classifier detect less false positives but at the same time the false negative score increases.

stages_numberPy_ssize_t

Amount of stages in a cascade. Each cascade consists of stumps i.e. trained features.

stumps_numberPy_ssize_t

The overall amount of stumps in all the stages of cascade.

features_numberPy_ssize_t

The overall amount of different features used by cascade. Two stumps can use the same features but has different trained values.

window_widthPy_ssize_t

The width of a detection window that is used. Objects smaller than this window can’t be detected.

window_heightPy_ssize_t

The height of a detection window.

stagesStage*

A pointer to the C array that stores stages information using a Stage struct.

featuresMBLBP*

A pointer to the C array that stores MBLBP features using an MBLBP struct.

LUTscnp.uint32_t*

A pointer to the C array with look-up tables that are used by trained MBLBP features (MBLBPStumps) to evaluate a particular region.

Notes

The cascade approach was first described by Viola and Jones [1], [2], although these initial publications used a set of Haar-like features. This implementation instead uses multi-scale block local binary pattern (MB-LBP) features [3].

References

[1]

Viola, P. and Jones, M. “Rapid object detection using a boosted cascade of simple features,” In: Proceedings of the 2001 IEEE Computer Society Conference on Computer Vision and Pattern Recognition. CVPR 2001, pp. I-I. DOI:10.1109/CVPR.2001.990517

[2]

Viola, P. and Jones, M.J, “Robust Real-Time Face Detection”, International Journal of Computer Vision 57, 137–154 (2004). DOI:10.1023/B:VISI.0000013087.49260.fb

[3]

Liao, S. et al. Learning Multi-scale Block Local Binary Patterns for Face Recognition. International Conference on Biometrics (ICB), 2007, pp. 828-837. In: Lecture Notes in Computer Science, vol 4642. Springer, Berlin, Heidelberg. DOI:10.1007/978-3-540-74549-5_87

__init__()#

Initialize cascade classifier.

Parameters:
xml_filefile’s path or file’s object

A file in a OpenCv format from which all the cascade classifier’s parameters are loaded.

epscnp.float32_t

Accuracy parameter. Increasing it, makes the classifier detect less false positives but at the same time the false negative score increases.

detect_multi_scale(img, scale_factor, step_ratio, min_size, max_size, min_neighbor_number=4, intersection_score_threshold=0.5)#

Search for the object on multiple scales of input image.

The function takes the input image, the scale factor by which the searching window is multiplied on each step, minimum window size and maximum window size that specify the interval for the search windows that are applied to the input image to detect objects.

Parameters:
img2-D or 3-D ndarray

Ndarray that represents the input image.

scale_factorcnp.float32_t

The scale by which searching window is multiplied on each step.

step_ratiocnp.float32_t

The ratio by which the search step in multiplied on each scale of the image. 1 represents the exaustive search and usually is slow. By setting this parameter to higher values the results will be worse but the computation will be much faster. Usually, values in the interval [1, 1.5] give good results.

min_sizetuple (int, int)

Minimum size of the search window.

max_sizetuple (int, int)

Maximum size of the search window.

min_neighbor_numberint

Minimum amount of intersecting detections in order for detection to be approved by the function.

intersection_score_thresholdcnp.float32_t

The minimum value of value of ratio (intersection area) / (small rectangle ratio) in order to merge two detections into one.

Returns:
outputlist of dicts

Dict have form {‘r’: int, ‘c’: int, ‘width’: int, ‘height’: int}, where ‘r’ represents row position of top left corner of detected window, ‘c’ - col position, ‘width’ - width of detected window, ‘height’ - height of detected window.

eps#
features_number#
stages_number#
stumps_number#
window_height#
window_width#