Back to Ccv

lib/ccv_bbf.c

site/0.6/lib/ccv-bbf/index.html

latest4.5 KB
Original Source

lib/ccv_bbf.c

ccv_bbf_classifier_cascade_new

void ccv_bbf_classifier_cascade_new(ccv_dense_matrix_t **posimg, int posnum, char** bgfiles, int bgnum, int negnum, ccv_size_t size, const char* dir, ccv_bbf_new_param_t params)

Create a new BBF classifier cascade from given positive examples and background images. This function has a hard dependency on GSL.

  • posimg : an array of positive examples.
  • posnum : number of positive examples.
  • bgfiles : an array of background images.
  • bgnum : number of background images.
  • negnum : number of negative examples that is harvested from background images.
  • size : the image size of positive examples.
  • dir : the working directory to store/retrieve intermediate data.
  • params : a ccv_bbf_new_param_t structure that defines various aspects of the training function.

ccv_bbf_new_param_t

  • pos_crit : positive criteria or the targeted recall ratio, BBF classifier tries to adjust the constant to meet this criteria.
  • neg_crit : negative criteria or the targeted reject ratio, BBF classifier tries to include more weak features until meet this criteria.
  • balance_k : weight positive examples differently from negative examples.
  • layer : the maximum layer trained for the classifier cascade.
  • feature_number : the maximum feature number for each classifier.
  • optimizer : CCV_BBF_GENETIC_OPT, using genetic algorithm to search the best weak feature; CCV_BBF_FLOAT_OPT, using float search to improve the found best weak feature.
  • detector : a ccv_bbf_params_t structure that will be used to search negative examples from background images.

ccv_bbf_detect_objects

ccv_array_t* ccv_bbf_detect_objects(ccv_dense_matrix_t* a, ccv_bbf_classifier_cascade_t** _cascade, int count, ccv_bbf_param_t params)

Using a BBF classifier cascade to detect objects in a given image. If you have several classifier cascades, it is better to use them in one method call. In this way, ccv will try to optimize the overall performance.

  • a : the input image.
  • cascade : an array of classifier cascades.
  • count : how many classifier cascades you’ve passed in.
  • params : a ccv_bbf_param_t structure that defines various aspects of the detector.

ccv_bbf_param_t

  • interval : interval images between the full size image and the half size one. e.g. 2 will generate 2 images in between full size image and half size one: image with full size, image with 5/6 size, image with 2/3 size, image with 1/2 size.
  • min_neighbors : 0: no grouping afterwards. 1: group objects that intersects each other. > 1: group objects that intersects each other, and only passes these that have at least min_neighbors intersected objects.
  • flags : CCV_BBF_NO_NESTED, if one class of object is inside another class of object, this flag will reject the first object.
  • accurate : BBF will generates 4 spatial scale variations for better accuracy. Set this parameter to 0 will reduce to 1 scale variation, and thus 3 times faster but lower the general accuracy of the detector.
  • size : the smallest object size that will be interesting to us.

ccv_bbf_read_classifier_cascade

ccv_bbf_classifier_cascade_t* ccv_bbf_read_classifier_cascade(const char* directory)

Read BBF classifier cascade from working directory.

  • directory : the working directory that trains a BBF classifier cascade.

ccv_bbf_classifier_cascade_read_binary

ccv_bbf_classifier_cascade_t* ccv_bbf_classifier_cascade_read_binary(char* s)

Load BBF classifier cascade from a memory region.

  • s : the memory region of binarized BBF classifier cascade.

ccv_bbf_classifier_cascade_write_binary

int ccv_bbf_classifier_cascade_write_binary(ccv_bbf_classifier_cascade_t* cascade, char* s, int slen)

Write BBF classifier cascade to a memory region.

  • cascade : the BBF classifier cascade.
  • s : the designated memory region.
  • slen : the size of the designated memory region.

It returns the actual size of the binarized BBF classifier cascade, if this size is larger than slen , please reallocate the memory region and do it again.

ccv_bbf_classifier_cascade_free

void ccv_bbf_classifier_cascade_free(ccv_bbf_classifier_cascade_t* cascade)

Free up the memory of BBF classifier cascade.

  • cascade : the BBF classifier cascade.

‹ back

comments powered by Disqus