{"action":"opened","issue":{"url":"https://api.github.com/repos/liuliu/ccv/issues/152","labels_url":"https://api.github.com/repos/liuliu/ccv/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/liuliu/ccv/issues/152/comments","events_url":"https://api.github.com/repos/liuliu/ccv/issues/152/events","html_url":"https://github.com/liuliu/ccv/issues/152","id":103351191,"number":152,"title":"Infinite loop in ccv_bbf_detect_objects","user":{"login":"jpolsonaz","id":13987242,"avatar_url":"https://avatars.githubusercontent.com/u/13987242?v=3","gravatar_id":"","url":"https://api.github.com/users/jpolsonaz","html_url":"https://github.com/jpolsonaz","followers_url":"https://api.github.com/users/jpolsonaz/followers","following_url":"https://api.github.com/users/jpolsonaz/following{/other_user}","gists_url":"https://api.github.com/users/jpolsonaz/gists{/gist_id}","starred_url":"https://api.github.com/users/jpolsonaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpolsonaz/subscriptions","organizations_url":"https://api.github.com/users/jpolsonaz/orgs","repos_url":"https://api.github.com/users/jpolsonaz/repos","events_url":"https://api.github.com/users/jpolsonaz/events{/privacy}","received_events_url":"https://api.github.com/users/jpolsonaz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-26T19:53:49Z","updated_at":"2015-08-26T19:53:49Z","closed_at":null,"body":"ccv_bbf_detect_objects gets in an infinite loop if a detection is at the far right or bottom of an image.  Here's a patch which fixes the problem.\r\n\r\ndiff --git a/lib/ccv_bbf.c b/lib/ccv_bbf.c\r\nindex 7c6754a..4f115da 100644\r\n--- a/lib/ccv_bbf.c\r\n+++ b/lib/ccv_bbf.c\r\n@@ -209,7 +209,7 @@ static int _ccv_prepare_background_data(ccv_bbf_classifier_cascade_t* cascade, c\r\n \t\t\t\t\t\t\tbreak;\r\n \t\t\t\t\t\t}\r\n \t\t\t\t\trect = (ccv_rect_t*)ccv_array_get(detected, r);\r\n-\t\t\t\t\tif ((rect->x < 0) || (rect->y < 0) || (rect->width + rect->x >= image->cols) || (rect->height + rect->y >= image->rows))\r\n+\t\t\t\t\tif ((rect->x < 0) || (rect->y < 0) || (rect->width + rect->x > image->cols) || (rect->height + rect->y > image->rows))\r\n \t\t\t\t\t{\r\n \t\t\t\t\t\tflag = 1;\r\n \t\t\t\t\t\tr = gsl_rng_uniform_int(rng, detected->rnum);\r\n"}}