Commit d8b0e8d5 authored by Vlad Shakhuro's avatar Vlad Shakhuro

Fix MS compiler warnings

parent 27692f5c
......@@ -109,7 +109,7 @@ struct CV_EXPORTS WaldBoostParams
int weak_count;
float alpha;
WaldBoostParams(): weak_count(100), alpha(0.01)
WaldBoostParams(): weak_count(100), alpha(0.01f)
{}
};
......
......@@ -83,7 +83,7 @@ void ACFFeatureEvaluator::setChannels(cv::InputArrayOfArrays channels)
int sum = 0;
for( int cell_row = row; cell_row < row + 4; ++cell_row )
for( int cell_col = col; cell_col < col + 4; ++cell_col )
sum += channel.at<float>(cell_row, cell_col);
sum += (int)channel.at<float>(cell_row, cell_col);
acf_channel(row / 4, col / 4) = sum;
}
......@@ -99,8 +99,8 @@ void ACFFeatureEvaluator::setPosition(Size position)
void ACFFeatureEvaluator::evaluateAll(OutputArray feature_values) const
{
Mat_<int> feature_vals(1, features_.size());
for( size_t i = 0; i < features_.size(); ++i )
Mat_<int> feature_vals(1, (int)features_.size());
for( int i = 0; i < (int)features_.size(); ++i )
{
feature_vals(0, i) = evaluate(i);
}
......@@ -146,13 +146,13 @@ void computeChannels(cv::InputArray image, cv::OutputArrayOfArrays channels_)
magnitude(row_der, col_der, grad);
Mat_<Vec6f> hist(grad.rows, grad.cols);
const float to_deg = 180 / 3.1415926;
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;
if (angle < 0)
angle += 180;
int ind = angle / 30;
int ind = (int)(angle / 30);
hist(row, col)[ind] = grad(row, col);
}
}
......
......@@ -68,7 +68,7 @@ void ICFDetector::train(const vector<string>& image_filenames,
vector<Mat> samples; /* positive samples + negative samples */
Mat sample, resized_sample;
size_t pos_count = 0;
int pos_count = 0;
for( size_t i = 0; i < image_filenames.size(); ++i, ++pos_count )
{
Mat img = imread(String(image_filenames[i].c_str()));
......@@ -92,7 +92,7 @@ void ICFDetector::train(const vector<string>& image_filenames,
for( size_t i = 0; i < image_filenames.size(); ++i )
{
Mat img = imread(String(image_filenames[i].c_str()));
for( size_t j = 0; j < pos_count / image_filenames.size() + 1; )
for( int j = 0; j < pos_count / image_filenames.size() + 1; )
{
Rect r;
r.x = rng.uniform(0, img.cols);
......@@ -112,19 +112,19 @@ void ICFDetector::train(const vector<string>& image_filenames,
}
Mat_<int> labels(1, pos_count + neg_count);
for( size_t i = 0; i < pos_count; ++i)
for( int i = 0; i < pos_count; ++i)
labels(0, i) = 1;
for( size_t i = pos_count; i < pos_count + neg_count; ++i )
for( int i = pos_count; i < pos_count + neg_count; ++i )
labels(0, i) = -1;
vector<Point3i> features = generateFeatures(model_size);
ACFFeatureEvaluator feature_evaluator(features);
Mat_<int> data(features.size(), samples.size());
Mat_<int> data((int)features.size(), (int)samples.size());
Mat_<int> feature_col;
vector<Mat> channels;
for( size_t i = 0; i < samples.size(); ++i )
for( int i = 0; i < (int)samples.size(); ++i )
{
computeChannels(samples[i], channels);
feature_evaluator.setChannels(channels);
......@@ -135,7 +135,7 @@ void ICFDetector::train(const vector<string>& image_filenames,
WaldBoostParams wparams;
wparams.weak_count = params.weak_count;
wparams.alpha = 0.001;
wparams.alpha = 0.001f;
WaldBoost waldboost(wparams);
waldboost.train(data, labels);
......
......@@ -81,7 +81,7 @@ int Stump::train(const Mat& data, const Mat& labels, const Mat& weights)
sorted_labels.at<int>(row, col) =
labels.at<int>(0, indices.at<int>(row, col));
sorted_weights.at<float>(row, col) =
weights.at<float>(0, indices.at<float>(row, col));
weights.at<float>(0, indices.at<int>(row, col));
}
}
......@@ -124,7 +124,7 @@ int Stump::train(const Mat& data, const Mat& labels, const Mat& weights)
float neg_total_weight = neg_cum_weights.at<float>(0, weights.cols - 1);
float eps = 1. / 4 * labels.cols;
float eps = 1.0f / 4 * labels.cols;
/* Compute minimal error */
float min_err = FLT_MAX;
......@@ -147,8 +147,8 @@ int Stump::train(const Mat& data, const Mat& labels, const Mat& weights)
float neg_right = neg_cum_weights.at<float>(row, col);
float neg_wrong = neg_total_weight - neg_right;
h_pos = .5 * log((pos_right + eps) / (pos_wrong + eps));
h_neg = .5 * log((neg_wrong + eps) / (neg_right + eps));
h_pos = (float)(.5 * log((pos_right + eps) / (pos_wrong + eps)));
h_neg = (float)(.5 * log((neg_wrong + eps) / (neg_right + eps)));
err = sqrt(pos_right * neg_wrong) + sqrt(pos_wrong * neg_right);
......
......@@ -69,8 +69,8 @@ vector<int> WaldBoost::train(const Mat& data, const Mat& labels)
}
Mat_<float> weights(labels.rows, labels.cols);
float pos_weight = 1. / (2 * pos_count);
float neg_weight = 1. / (2 * neg_count);
float pos_weight = 1.0f / (2 * pos_count);
float neg_weight = 1.0f / (2 * neg_count);
for( int col = 0; col < weights.cols; ++col )
{
if( labels.at<int>(0, col) == +1 )
......@@ -101,7 +101,7 @@ vector<int> WaldBoost::train(const Mat& data, const Mat& labels)
}
// Normalize weights
float z = sum(weights)[0];
float z = (float)sum(weights)[0];
for( int col = 0; col < weights.cols; ++col)
{
weights.at<float>(0, col) /= z;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment