Package pycv :: Package cs :: Package cv :: Module detect :: Class ObjectDetector
[hide private]
[frames] | no frames]

Class ObjectDetector

source code

Instance Methods [hide private]
 
__init__(self, object_type, flag=0, param1=None, param2=None, block_size=256)
Initialize an ObjectDetector.
source code
 
__del__(self) source code
 
_detect_block(self, roi)
Detect objects in the current block.
source code
 
_display_block(self, roi)
Diplay the current block.
source code
 
_update_org_img(self, img) source code
 
_group_overlapping(self, z)
Group overlapping windows
source code
 
detect(self, img, scale_factor=1.1, min_neighbors=1, group_overlapping=True)
Detect objects from a grayscale image.
source code
Method Details [hide private]

__init__(self, object_type, flag=0, param1=None, param2=None, block_size=256)
(Constructor)

source code 

Initialize an ObjectDetector.

Input:
object_type: the type of object to detect,
in ('frontal_face','profile_face','upper_body','lower_body','full_body')
flag: the type of operation of the object detector
0 = use opencv's default haar cascade 1 = use the cascade stored in a BinaryClassifier, see param1, param2 2 = same as 1 but use opencv's default haar cascade to post-verify 3 = use the cascade stored in a text file named by param1 4 = same as 3 but use opencv's default haar cascade to post-verify
param1: [optional] a strong classifier to classify a patch into object/non-object
If flag is 1 or 2: This holds a BinaryClassifier If flag is 3 or 4: This holds a path to the text file storing the cascade
param2: [optional] If flag is 1 or 2:
this holds the length of the image patch (e.g. 20-by-20 or 24-by-24)
block_size : int
length of a square block. An image is divided into blocks if it is too large. This offers fast and stable object detection.

_detect_block(self, roi)

source code 
Detect objects in the current block.
Parameters:
  • roi (CvRECT) - rectangle of interest of the top-left corner
Returns:
array of the top-left corner(s) of the detected face(s)

_display_block(self, roi)

source code 
Diplay the current block.
Parameters:
  • roi (CvRECT) - rectangle of interest of the top-left corner
Returns:
array of the top-left corner(s) of the detected face(s)

_group_overlapping(self, z)

source code 
Group overlapping windows
Returns:
y : array of (x,y,w,h)
array of windows after groupping

detect(self, img, scale_factor=1.1, min_neighbors=1, group_overlapping=True)

source code 
Detect objects from a grayscale image.

Input:
    img: a POINTER(IplImage) of depth IPL_DEPTH_8U and 1 or 3 channels
    scale_factor: The factor by which the search window is scaled 
        between the subsequent scans, for example, 1.1 means increasing window by 10%.
    min_neighbors: Minimum number (minus 1) of neighbor rectangles that makes up an object. 
        All the groups of a smaller number of rectangles than min_neighbors-1 are rejected. 
        If min_neighbors is 0, the function does not any grouping at all and returns all 
        the detected candidate rectangles, which may be useful if the user wants to apply 
        a customized grouping procedure.
    group_overlapping: if True then overlapping locations are grouped
Output:
    z: an 'int' numpy.array of tuples (x,y,w,h) representing the object locations