bioidiap/xbob.flandmark — pull request #2 by ties (2013-06-14 14:00:17+00:00)
Title: subsequent invocations of the detector might return stale keypoints

When the detector is invoked on a series of images, the detector returns stale keypoints when an input contains a bounding box and the detector was not able to extract keypoints.

#### example
![7](https://f.cloud.github.com/assets/199058/654334/41625010-d4f7-11e2-830c-4f30d3104dff.png)![8](https://f.cloud.github.com/assets/199058/654338/59079194-d4f7-11e2-8ab0-6b5b6e806116.png)

### reproduction steps
Download and run the [`stale_keypoints.py` file and sample images](https://gist.github.com/ties/105f244604687ba844f1).

The sample images are pre-processed images from the Kaggle/icml_2013_wrepl emotion recognition challenge. The script should generate the output as seen above.

### cause
The detector did not check the return code of the facial landmark detector.

When the detector returned an error code, the stale key-points from a previous invocation were returned. If no previous invocation of the detector was successful, the detector could return uninitialised memory resulting in an segmentation fault e.g.,

```pytb
Using gpu device 0: GeForce GT 650M
batch 0
..Traceback (most recent call last):
File "stale_keypoints.py", line 22, in
bob.ip.draw_cross(im, int(feature[0]), int(feature[1]), 3, white)
OverflowError: Python int too large to convert to C long
Segmentation fault: 11
```
#### fix
The wrapper should check the result of the landmark detector and only copy the keypoints when the invocation was successful. When the detection is unsuccessful, an empty keypoint list should be returned.

### result
When the cascade found a bounding box, but no keypoints have been extracted, the detector returns an empty list of keypoints.

![7](https://f.cloud.github.com/assets/199058/654327/2318963c-d4f7-11e2-99b6-8406f1fcaa07.png)![8](https://f.cloud.github.com/assets/199058/654331/28f6272c-d4f7-11e2-8491-efcca5992a6b.png)