Ask Your Question

Boost custom weak classifiers

asked 2016-05-26 07:16:29 -0500

Killerwife gravatar image

Hello, I am trying to implement my own weak classifiers in connection with AdaBoost. Currently I am unable to figure out any way using cv::ml:boost. Am I missing something or does this algorithm implementation only support decision trees?

My goal is to implement my own flavor of haar features and/or use my own HOG implementation.

I apologis

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-09-01 11:06:10 -0500

luug gravatar image

It is quite simple to train an AdaBoost classifier. The following steps are needed:

cv::Ptr<cv::ml::Boost> boost_ = cv::ml::Boost::create();
cv::Ptr<cv::ml::TrainData> data = cv::ml::TrainData::create(train_data, cv::ml::ROW_SAMPLE, train_labels)
  • train_data is a matrix of size NxF where N is the number of samples and F is the number of features. The type of the matrix has to be CV_32FC1.
  • train_labels is a matrix of size Nx1 where N has the same value as above, so number of samples/labels. This matrix constains all labels beloning to the data. In the case you are using a binary classifier, labels can be for example 0 and 1. The type of this matrix has to be CV_32SC1.

Train the model by using:


After the training you can predict single samples by passing a matrix of the size NxF and the type CV_32FC1 (same as above) to the function predcit function:


There is an API documentation and also a short Tutorial available.

Regarding to :

I am trying to implement my own weak classifiers in connection with AdaBoost

There can be passed evry kind of feature to the algorithm as e.g number of green points in an image or what ever.

edit flag offensive delete link more


I like the fact you are providing concrete solutions, although it might be just a waste of time to reopen topics from May 2016. That user is either long gone, already found the solution or is fired by now :)

StevenPuttemans gravatar imageStevenPuttemans ( 2017-09-04 05:44:33 -0500 )edit

Hi Steven, I think, it is not waste of time :). Currently, I am searching information for AdaBoost classifier and it is very helpful for me.

vps gravatar imagevps ( 2017-09-04 08:25:08 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-05-26 07:16:29 -0500

Seen: 281 times

Last updated: Sep 01 '17