Skip to content

Commit

Permalink
clean warnings in perception/camera (ApolloAuto#2192)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaWaiTsoiBaidu authored and Jiangtao Hu committed Dec 13, 2018
1 parent 8d55ae2 commit 91898d3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion modules/perception/camera/common/camera_ground_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void GroundFittingCostFunc(const T *p,
const T *refp = d;
for (int i = 0; i < n; ++i) {
T d_proj = refx[0] * p[0] + p[1];
T proj_err = fabs(d_proj - refp[0]);
T proj_err = static_cast<T>(fabs(d_proj - refp[0]));
if (proj_err < error_tol) {
inliers[(*nr_inlier)++] = i;
*cost += proj_err;
Expand Down
6 changes: 4 additions & 2 deletions modules/perception/camera/common/math_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ namespace camera {

template<typename Dtype>
inline Dtype sigmoid(Dtype x) {
return 1.0 / (1.0 + exp(-x));
return static_cast<Dtype>(1.0) /
static_cast<Dtype>(1.0 + exp(static_cast<double>(-x)));
}
template<typename Dtype>
inline Dtype gaussian(Dtype x, Dtype mu, Dtype sigma) {
return std::exp(-(x - mu) * (x - mu) / (2 * sigma * sigma));
return static_cast<Dtype>(std::exp(-(x - mu) * (x - mu) /
(2 * sigma * sigma)));
}
template<typename Dtype>
Dtype sqr(Dtype x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ struct HistogramEstimatorParams {
data_ep = params.data_ep;
assert(nr_bins_in_histogram > 0 && data_ep > data_sp);

step_bin = (data_ep - data_sp) / nr_bins_in_histogram;
step_bin = (data_ep - data_sp) / static_cast<float>(nr_bins_in_histogram);

int w = params.smooth_kernel.size();
int w = static_cast<int>(params.smooth_kernel.size());
assert(w >= 1);
smooth_kernel_width = w;
smooth_kernel.resize(smooth_kernel_width);
Expand Down Expand Up @@ -149,7 +149,8 @@ class HistogramEstimator {
}

float GetValFromIndex(int index) const {
return (params_.data_sp + (index + 0.5f) * params_.step_bin);
return (params_.data_sp +
(static_cast<float>(index) + 0.5f) * params_.step_bin);
}

void Smooth(const uint32_t *hist_input, int nr_bins,
Expand All @@ -163,7 +164,7 @@ class HistogramEstimator {
void Decay(uint32_t *hist, int nr_bins) {
float df = params_.decay_factor;
for (int i = 0; i < nr_bins; ++i) {
hist[i] = static_cast<uint32_t>(hist[i] * df);
hist[i] = static_cast<uint32_t>(static_cast<float>(hist[i]) * df);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class LaneBasedCalibrator {
}

bool IsTravelingStraight(const float &vehicle_yaw_changed) const {
float abs_yaw = fabs(vehicle_yaw_changed);
float abs_yaw = static_cast<float>(fabs(vehicle_yaw_changed));
return abs_yaw < params_.max_allowed_yaw_angle_in_radian;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ class ObjMapper {
float *x /*init outside*/) const;

void FillRyScoreSingleBin(const float &ry) {
int nr_bins_ry = ry_score_.size();
int nr_bins_ry = static_cast<int>(ry_score_.size());
memset(ry_score_.data(), 0, sizeof(float) * nr_bins_ry);
const float PI = common::Constant<float>::PI();
int index = std::floor((ry + PI) * nr_bins_ry / (2 * PI));
int index = static_cast<int>(std::floor((ry + PI) *
static_cast<float>(nr_bins_ry) /
(2.0f * PI)));
ry_score_[index % nr_bins_ry] = 1.0f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class SemanticReviser : public BaseTrafficLightTracker {

private:
traffic_light::tracker::SemanticReviseParam semantic_param_;
float revise_time_s_ = 1.5;
float blink_threshold_s_ = 0.4;
float non_blink_threshold_s_ = 0.8;
float revise_time_s_ = 1.5f;
float blink_threshold_s_ = 0.4f;
float non_blink_threshold_s_ = 0.8f;
int hysteretic_threshold_ = 1;
std::vector<SemanticTable> history_semantic_;
};
Expand Down

0 comments on commit 91898d3

Please sign in to comment.