Commit 4b161803 authored by Vlad Shakhuro's avatar Vlad Shakhuro

Warning fixes

parent 81d44b7e
......@@ -60,12 +60,12 @@ static vector<Mat> sample_patches(
const string& path,
int n_rows,
int n_cols,
int n_patches)
size_t n_patches)
{
vector<String> filenames;
glob(path, filenames);
vector<Mat> patches;
int patch_count = 0;
size_t patch_count = 0;
for (size_t i = 0; i < filenames.size(); ++i) {
Mat img = imread(filenames[i], CV_LOAD_IMAGE_GRAYSCALE);
for (int row = 0; row + n_rows < img.rows; row += n_rows) {
......@@ -116,7 +116,7 @@ void WBDetector::train(
const int stage_neg = 5000;
const int max_per_image = 25;
const float scales_arr[] = {.3, .4, .5, .6, .7, .8, .9, 1};
const float scales_arr[] = {.3f, .4f, .5f, .6f, .7f, .8f, .9f, 1.0f};
const vector<float> scales(scales_arr,
scales_arr + sizeof(scales_arr) / sizeof(*scales_arr));
......@@ -129,8 +129,8 @@ void WBDetector::train(
cerr << "compute features" << endl;
pos_data = Mat1b(n_features, pos_imgs.size());
neg_data = Mat1b(n_features, neg_imgs.size());
pos_data = Mat1b(n_features, (int)pos_imgs.size());
neg_data = Mat1b(n_features, (int)neg_imgs.size());
for (size_t k = 0; k < pos_imgs.size(); ++k) {
eval->setImage(pos_imgs[k], +1, 0, boost.get_feature_indices());
......@@ -142,7 +142,7 @@ void WBDetector::train(
for (size_t k = 0; k < neg_imgs.size(); ++k) {
eval->setImage(neg_imgs[k], 0, 0, boost.get_feature_indices());
for (int j = 0; j < n_features; ++j) {
neg_data.at<uchar>(j, k) = (*eval)(j);
neg_data.at<uchar>(j, (int)k) = (*eval)(j);
}
}
......@@ -201,7 +201,7 @@ void WBDetector::detect(
bboxes.clear();
confidences.clear();
vector<float> scales;
for (float scale = 0.2f; scale < 1.2f; scale *= 1.1) {
for (float scale = 0.2f; scale < 1.2f; scale *= 1.1f) {
scales.push_back(scale);
}
Ptr<CvFeatureParams> params = CvFeatureParams::create();
......
......@@ -114,7 +114,7 @@ void CvFeatureEvaluator::init(const CvFeatureParams *_featureParams,
generateFeatures();
}
void CvFeatureEvaluator::setImage(const Mat &, uchar clsLabel, int idx, const std::vector<int>& feature_ind)
void CvFeatureEvaluator::setImage(const Mat &, uchar clsLabel, int idx, const std::vector<int>&)
{
//CV_Assert(img.cols == winSize.width);
//CV_Assert(img.rows == winSize.height);
......
......@@ -84,7 +84,7 @@ static void compute_min_step(const Mat &data_pos, const Mat &data_neg, size_t n_
max(reduced_pos, reduced_neg, data_max);
data_max += 0.01;
data_step = (data_max - data_min) / (n_bins - 1);
data_step = (data_max - data_min) / (double)(n_bins - 1);
}
static void quantize_data(Mat &data, Mat1f &data_min, Mat1f &data_step)
......@@ -132,15 +132,15 @@ void WaldBoost::detect(Ptr<CvFeatureEvaluator> eval,
float scale = scales[i];
resize(img, resized_img, Size(), scale, scale);
eval->setImage(resized_img, 0, 0, feature_indices_);
int n_rows = 24 / scale;
int n_cols = 24 / scale;
int n_rows = (int)(24 / scale);
int n_cols = (int)(24 / scale);
for (int r = 0; r + 24 < resized_img.rows; r += step) {
for (int c = 0; c + 24 < resized_img.cols; c += step) {
//eval->setImage(resized_img(Rect(c, r, 24, 24)), 0, 0);
eval->setWindow(Point(c, r));
if (predict(eval, &h) == +1) {
int row = r / scale;
int col = c / scale;
int row = (int)(r / scale);
int col = (int)(c / scale);
bboxes.push_back(Rect(col, row, n_cols, n_rows));
confidences.push_back(h);
}
......@@ -164,14 +164,14 @@ void WaldBoost::detect(Ptr<CvFeatureEvaluator> eval,
float scale = scales[i];
resize(img, resized_img, Size(), scale, scale);
eval->setImage(resized_img, 0, 0, feature_indices_);
int n_rows = 24 / scale;
int n_cols = 24 / scale;
int n_rows = (int)(24 / scale);
int n_cols = (int)(24 / scale);
for (int r = 0; r + 24 < resized_img.rows; r += step) {
for (int c = 0; c + 24 < resized_img.cols; c += step) {
eval->setWindow(Point(c, r));
if (predict(eval, &h) == +1) {
int row = r / scale;
int col = c / scale;
int row = (int)(r / scale);
int col = (int)(c / scale);
bboxes.push_back(Rect(col, row, n_cols, n_rows));
confidences.push_back(h);
}
......@@ -233,7 +233,7 @@ void WaldBoost::fit(Mat& data_pos, Mat& data_neg)
compute_cdf(data_pos.row(feat_i), pos_weights, pos_cdf);
compute_cdf(data_neg.row(feat_i), neg_weights, neg_cdf);
float neg_total = sum(neg_weights)[0];
float neg_total = (float)sum(neg_weights)[0];
Mat1f err_direct = pos_cdf + neg_total - neg_cdf;
Mat1f err_backward = 1.0f - err_direct;
......@@ -265,7 +265,7 @@ void WaldBoost::fit(Mat& data_pos, Mat& data_neg)
}
float alpha = .5f * log((1 - min_err) / min_err);
float alpha = .5f * (float)log((1 - min_err) / min_err);
alphas_.push_back(alpha);
feature_indices_.push_back(min_feature_ind);
thresholds_.push_back(min_threshold);
......
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