Integral Channel Features or ICFDetector
Hi,i got problems when i'm training ICFDetector too. I debuged to find that it will say :
Opencv error:Assertion failed ((unsigned)i < (unsigned)cn) in cv::Vec<float,6>::operator []
when running to
void computeChannels(InputArray image, vector<Mat>& channels)
Mat_<Vec6f> hist = Mat_<Vec6f>::zeros(grad.rows, grad.cols);
//const float to_deg = 180 / 3.1415926f;
for (int row = 0; row < grad.rows; ++row) {
for (int col = 0; col < grad.cols; ++col) {
//float angle = atan2(row_der(row, col), col_der(row, col)) * to_deg;
float angle = angles(row, col);
if (angle < 0)
angle += 180;
int ind = (int)(angle / 30);
// If angle == 180, prevent index overflow
if (ind == 6)
ind = 5;
hist(row, col)[ind] = grad(row, col) * 255;
}
}
i have set the params ,dont know why it happened; and here is my code
ICFDetectorParams params;
params.feature_count = 2000; // parser.get<int>("feature_count");42000
params.weak_count = 100; // parser.get<int>("weak_count"); 200
params.bg_per_image = 5; // parser.get<int>("bg_per_image");
params.model_n_rows = 128;
params.model_n_cols = 64;
params.features_type = "icf";
params.alpha = 0.15f; // default: 0.02
icf.train(pos_fileNames,bg_fileNames,params);
Can u tell me any problems?
The ICF detector is in the contrib repository with a good reason. It is broken, slow and it has a terrible accuracy for the moment. What I am guessing that is happening is that either your channel matrix or your input image is invalid. Can you check this?
it looks like this issue to me.
also see here please
I commented the loop code , it can run correctly .But i know it's not my want . So my input image is vaild.And I dont know how to check channel matrix ,sorry about that.
I found the reason.Because cartToPolar(col_der, row_der, grad, angles, true) , the angles will range from 0 to 360 ; So when "float angle = angles(row, col); int ind = (int)(angle / 30);" "ind" can be larger than 5 ,but the number of the channel is 6 .That is the reason .
I change
if (angle < 0) angle += 180;
toif (angle >180) angle -= 180;
And it works !