diff --git a/modules/xobjdetect/include/opencv2/xobjdetect.hpp b/modules/xobjdetect/include/opencv2/xobjdetect.hpp index f28cbb49e..5d2dabbd0 100644 --- a/modules/xobjdetect/include/opencv2/xobjdetect.hpp +++ b/modules/xobjdetect/include/opencv2/xobjdetect.hpp @@ -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) {} }; diff --git a/modules/xobjdetect/src/acffeature.cpp b/modules/xobjdetect/src/acffeature.cpp index b347e62bd..d62fb843c 100644 --- a/modules/xobjdetect/src/acffeature.cpp +++ b/modules/xobjdetect/src/acffeature.cpp @@ -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(cell_row, cell_col); + sum += (int)channel.at(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_ feature_vals(1, features_.size()); - for( size_t i = 0; i < features_.size(); ++i ) + Mat_ 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_ 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); } } diff --git a/modules/xobjdetect/src/icfdetector.cpp b/modules/xobjdetect/src/icfdetector.cpp index 66c7edcd1..1c6216a42 100644 --- a/modules/xobjdetect/src/icfdetector.cpp +++ b/modules/xobjdetect/src/icfdetector.cpp @@ -68,7 +68,7 @@ void ICFDetector::train(const vector& image_filenames, vector 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& 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& image_filenames, } Mat_ 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 features = generateFeatures(model_size); ACFFeatureEvaluator feature_evaluator(features); - Mat_ data(features.size(), samples.size()); + Mat_ data((int)features.size(), (int)samples.size()); Mat_ feature_col; vector 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& 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); diff --git a/modules/xobjdetect/src/stump.cpp b/modules/xobjdetect/src/stump.cpp index e9dbfa764..6c63fd840 100644 --- a/modules/xobjdetect/src/stump.cpp +++ b/modules/xobjdetect/src/stump.cpp @@ -81,7 +81,7 @@ int Stump::train(const Mat& data, const Mat& labels, const Mat& weights) sorted_labels.at(row, col) = labels.at(0, indices.at(row, col)); sorted_weights.at(row, col) = - weights.at(0, indices.at(row, col)); + weights.at(0, indices.at(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(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(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); diff --git a/modules/xobjdetect/src/waldboost.cpp b/modules/xobjdetect/src/waldboost.cpp index c9062fa82..86e84d5f2 100644 --- a/modules/xobjdetect/src/waldboost.cpp +++ b/modules/xobjdetect/src/waldboost.cpp @@ -69,8 +69,8 @@ vector WaldBoost::train(const Mat& data, const Mat& labels) } Mat_ 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(0, col) == +1 ) @@ -101,7 +101,7 @@ vector 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(0, col) /= z;