A method for setting a tridimensional shape detection classifier for detecting tridimensional shapes from depth images in which each pixel represents a depth distance from a source to a scene, each depth image being dividable into one or more patches (Ip, In) of given dimensions, the classifier comprising a forest of at least a binary tree for obtaining the class probability of a given shape comprising nodes associated with a distance function (f) that taking at least a pixel position in a patch calculate a pixel distance, the method comprising:
- obtaining one or more positive patches (Ip) of the given dimensions from a depth image, said one or more positive patches containing the shape to be detected,
- and obtaining one or more negative patches (In) of the given dimensions from a depth image, said one or more negative patches not containing the shape to be detected,
- the method comprises:
- for each obtained positive or negative patch
- traversing the binary trees starting from their root node using the distance function at each node to decide to continue to one of the child nodes of the next level until a leaf node of each binary tree is reached;
- calculating in each reached leaf node the distance function for the patch using candidate groups of parameters, each candidate group of parameters comprising:
- at least a pixel position (u, v) in a patch,
- a depth clipping window (k) in the patch and
- a pixel distance threshold (θ);
- by comparing the result of the distance function using the at least a pixel position and the depth clipping window with the pixel distance threshold of each candidate group, and computing its statistics;
- and when more than a predefined number of positive or negative patches are applied to a leaf node of the classifier:
- selecting for that leaf node the candidate group of parameters that best separate the positive and negative patches into two groups for calculating the class probability of the shape in that leaf node using the distance function;
- creating a new level of the binary tree from that leaf node comprising two newly created leave nodes, thus that leaf node becoming a node, and
- passing the statistics from that leaf node that has become a node to the newly created leaf nodes.