Commit e5f9f979 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

fixed build warnings on Windows

parent 1686b0d9
...@@ -74,7 +74,7 @@ static void removeOcclusions(const Mat& flow, ...@@ -74,7 +74,7 @@ static void removeOcclusions(const Mat& flow,
static void wd(Mat& d, int top_shift, int bottom_shift, int left_shift, int right_shift, float sigma) { static void wd(Mat& d, int top_shift, int bottom_shift, int left_shift, int right_shift, float sigma) {
for (int dr = -top_shift, r = 0; dr <= bottom_shift; ++dr, ++r) { for (int dr = -top_shift, r = 0; dr <= bottom_shift; ++dr, ++r) {
for (int dc = -left_shift, c = 0; dc <= right_shift; ++dc, ++c) { for (int dc = -left_shift, c = 0; dc <= right_shift; ++dc, ++c) {
d.at<float>(r, c) = -(dr*dr + dc*dc); d.at<float>(r, c) = (float)-(dr*dr + dc*dc);
} }
} }
d *= 1.0 / (2.0 * sigma * sigma); d *= 1.0 / (2.0 * sigma * sigma);
...@@ -134,11 +134,11 @@ static void crossBilateralFilter(const Mat& image, const Mat& edge_image, const ...@@ -134,11 +134,11 @@ static void crossBilateralFilter(const Mat& image, const Mat& edge_image, const
multiply(weights, confidence_extended(window_rows, window_cols), weights); multiply(weights, confidence_extended(window_rows, window_cols), weights);
multiply(weights, weights_space, weights); multiply(weights, weights_space, weights);
float weights_sum = sum(weights)[0]; float weights_sum = (float)sum(weights)[0];
for (int ch = 0; ch < 2; ++ch) { for (int ch = 0; ch < 2; ++ch) {
multiply(weights, image_extended_channels[ch](window_rows, window_cols), weighted_sum); multiply(weights, image_extended_channels[ch](window_rows, window_cols), weighted_sum);
float total_sum = sum(weighted_sum)[0]; float total_sum = (float)sum(weighted_sum)[0];
dst.at<Vec2f>(row, col)[ch] = (flag && fabs(weights_sum) < 1e-9) dst.at<Vec2f>(row, col)[ch] = (flag && fabs(weights_sum) < 1e-9)
? image.at<float>(row, col) ? image.at<float>(row, col)
...@@ -164,7 +164,7 @@ static void calcOpticalFlowSingleScaleSF(const Mat& prev, ...@@ -164,7 +164,7 @@ static void calcOpticalFlowSingleScaleSF(const Mat& prev,
Mat diff_storage(averaging_radius*2 + 1, averaging_radius*2 + 1, CV_32F); Mat diff_storage(averaging_radius*2 + 1, averaging_radius*2 + 1, CV_32F);
Mat w_full_window(averaging_radius*2 + 1, averaging_radius*2 + 1, CV_32F); Mat w_full_window(averaging_radius*2 + 1, averaging_radius*2 + 1, CV_32F);
Mat wd_full_window(averaging_radius*2 + 1, averaging_radius*2 + 1, CV_32F); Mat wd_full_window(averaging_radius*2 + 1, averaging_radius*2 + 1, CV_32F);
float w_full_window_sum = 1e-9; float w_full_window_sum = 1e-9f;
Mat prev_extended; Mat prev_extended;
copyMakeBorder(prev, prev_extended, copyMakeBorder(prev, prev_extended,
...@@ -176,10 +176,10 @@ static void calcOpticalFlowSingleScaleSF(const Mat& prev, ...@@ -176,10 +176,10 @@ static void calcOpticalFlowSingleScaleSF(const Mat& prev,
for (int r0 = 0; r0 < rows; ++r0) { for (int r0 = 0; r0 < rows; ++r0) {
for (int c0 = 0; c0 < cols; ++c0) { for (int c0 = 0; c0 < cols; ++c0) {
Vec2f flow_at_point = flow.at<Vec2f>(r0, c0); Vec2f flow_at_point = flow.at<Vec2f>(r0, c0);
int u0 = floor(flow_at_point[0] + 0.5); int u0 = cvRound(flow_at_point[0]);
if (r0 + u0 < 0) { u0 = -r0; } if (r0 + u0 < 0) { u0 = -r0; }
if (r0 + u0 >= rows) { u0 = rows - 1 - r0; } if (r0 + u0 >= rows) { u0 = rows - 1 - r0; }
int v0 = floor(flow_at_point[1] + 0.5); int v0 = cvRound(flow_at_point[1]);
if (c0 + v0 < 0) { v0 = -c0; } if (c0 + v0 < 0) { v0 = -c0; }
if (c0 + v0 >= cols) { v0 = cols - 1 - c0; } if (c0 + v0 >= cols) { v0 = cols - 1 - c0; }
...@@ -188,13 +188,13 @@ static void calcOpticalFlowSingleScaleSF(const Mat& prev, ...@@ -188,13 +188,13 @@ static void calcOpticalFlowSingleScaleSF(const Mat& prev,
const int min_col_shift = -min(c0 + v0, max_flow); const int min_col_shift = -min(c0 + v0, max_flow);
const int max_col_shift = min(cols - 1 - (c0 + v0), max_flow); const int max_col_shift = min(cols - 1 - (c0 + v0), max_flow);
float min_cost = DBL_MAX, best_u = u0, best_v = v0; float min_cost = FLT_MAX, best_u = (float)u0, best_v = (float)v0;
if (mask.at<uchar>(r0, c0)) { if (mask.at<uchar>(r0, c0)) {
wc(prev_extended, w_full_window, r0 + averaging_radius, c0 + averaging_radius, wc(prev_extended, w_full_window, r0 + averaging_radius, c0 + averaging_radius,
averaging_radius, averaging_radius, averaging_radius, averaging_radius, sigma_color); averaging_radius, averaging_radius, averaging_radius, averaging_radius, sigma_color);
multiply(w_full_window, wd_full_window, w_full_window); multiply(w_full_window, wd_full_window, w_full_window);
w_full_window_sum = sum(w_full_window)[0]; w_full_window_sum = (float)sum(w_full_window)[0];
} }
bool first_flow_iteration = true; bool first_flow_iteration = true;
...@@ -255,15 +255,15 @@ static void calcOpticalFlowSingleScaleSF(const Mat& prev, ...@@ -255,15 +255,15 @@ static void calcOpticalFlowSingleScaleSF(const Mat& prev,
averaging_radius + 1 + window_bottom_shift), averaging_radius + 1 + window_bottom_shift),
Range(averaging_radius - window_left_shift, Range(averaging_radius - window_left_shift,
averaging_radius + 1 + window_right_shift)); averaging_radius + 1 + window_right_shift));
w_sum = sum(w)[0]; w_sum = (float)sum(w)[0];
} }
multiply(diff2, w, diff2); multiply(diff2, w, diff2);
const float cost = sum(diff2)[0] / w_sum; const float cost = (float)(sum(diff2)[0] / w_sum);
if (cost < min_cost) { if (cost < min_cost) {
min_cost = cost; min_cost = cost;
best_u = u + u0; best_u = (float)(u + u0);
best_v = v + v0; best_v = (float)(v + v0);
} }
} }
} }
...@@ -371,7 +371,7 @@ static void selectPointsToRecalcFlow(const Mat& flow, ...@@ -371,7 +371,7 @@ static void selectPointsToRecalcFlow(const Mat& flow,
mask.at<uchar>(curr_bottom, curr_right) = MASK_TRUE_VALUE; mask.at<uchar>(curr_bottom, curr_right) = MASK_TRUE_VALUE;
for (int rr = curr_top; rr <= curr_bottom; ++rr) { for (int rr = curr_top; rr <= curr_bottom; ++rr) {
for (int cc = curr_left; cc <= curr_right; ++cc) { for (int cc = curr_left; cc <= curr_right; ++cc) {
speed_up.at<uchar>(rr, cc) = speed_up_at_this_point + 1; speed_up.at<uchar>(rr, cc) = (uchar)(speed_up_at_this_point + 1);
} }
} }
} else { } else {
...@@ -408,9 +408,9 @@ static inline float extrapolateValueInRect(int height, int width, ...@@ -408,9 +408,9 @@ static inline float extrapolateValueInRect(int height, int width,
if (r == height && c == width) { return v22;} if (r == height && c == width) { return v22;}
float qr = float(r) / height; float qr = float(r) / height;
float pr = 1.0 - qr; float pr = 1.0f - qr;
float qc = float(c) / width; float qc = float(c) / width;
float pc = 1.0 - qc; float pc = 1.0f - qc;
return v11*pr*pc + v12*pr*qc + v21*qr*pc + v22*qc*qr; return v11*pr*pc + v12*pr*qc + v21*qr*pc + v22*qc*qr;
} }
...@@ -517,8 +517,8 @@ void calcOpticalFlowSF(Mat& from, ...@@ -517,8 +517,8 @@ void calcOpticalFlowSF(Mat& from,
confidence, confidence,
averaging_block_size, averaging_block_size,
max_flow, max_flow,
sigma_dist, (float)sigma_dist,
sigma_color); (float)sigma_color);
calcOpticalFlowSingleScaleSF(first_to_image, calcOpticalFlowSingleScaleSF(first_to_image,
first_from_image, first_from_image,
...@@ -527,17 +527,17 @@ void calcOpticalFlowSF(Mat& from, ...@@ -527,17 +527,17 @@ void calcOpticalFlowSF(Mat& from,
confidence_inv, confidence_inv,
averaging_block_size, averaging_block_size,
max_flow, max_flow,
sigma_dist, (float)sigma_dist,
sigma_color); (float)sigma_color);
removeOcclusions(flow, removeOcclusions(flow,
flow_inv, flow_inv,
occ_thr, (float)occ_thr,
confidence); confidence);
removeOcclusions(flow_inv, removeOcclusions(flow_inv,
flow, flow,
occ_thr, (float)occ_thr,
confidence_inv); confidence_inv);
Mat speed_up = Mat::zeros(first_from_image.rows, first_from_image.cols, CV_8U); Mat speed_up = Mat::zeros(first_from_image.rows, first_from_image.cols, CV_8U);
...@@ -556,7 +556,7 @@ void calcOpticalFlowSF(Mat& from, ...@@ -556,7 +556,7 @@ void calcOpticalFlowSF(Mat& from,
selectPointsToRecalcFlow(flow, selectPointsToRecalcFlow(flow,
averaging_block_size, averaging_block_size,
speed_up_thr, (int)speed_up_thr,
curr_rows, curr_rows,
curr_cols, curr_cols,
speed_up, speed_up,
...@@ -565,7 +565,7 @@ void calcOpticalFlowSF(Mat& from, ...@@ -565,7 +565,7 @@ void calcOpticalFlowSF(Mat& from,
selectPointsToRecalcFlow(flow_inv, selectPointsToRecalcFlow(flow_inv,
averaging_block_size, averaging_block_size,
speed_up_thr, (int)speed_up_thr,
curr_rows, curr_rows,
curr_cols, curr_cols,
speed_up_inv, speed_up_inv,
...@@ -581,8 +581,8 @@ void calcOpticalFlowSF(Mat& from, ...@@ -581,8 +581,8 @@ void calcOpticalFlowSF(Mat& from,
confidence, confidence,
flow, flow,
upscale_averaging_radius, upscale_averaging_radius,
upscale_sigma_dist, (float)upscale_sigma_dist,
upscale_sigma_color); (float)upscale_sigma_color);
flow_inv = upscaleOpticalFlow(curr_rows, flow_inv = upscaleOpticalFlow(curr_rows,
curr_cols, curr_cols,
...@@ -590,8 +590,8 @@ void calcOpticalFlowSF(Mat& from, ...@@ -590,8 +590,8 @@ void calcOpticalFlowSF(Mat& from,
confidence_inv, confidence_inv,
flow_inv, flow_inv,
upscale_averaging_radius, upscale_averaging_radius,
upscale_sigma_dist, (float)upscale_sigma_dist,
upscale_sigma_color); (float)upscale_sigma_color);
calcOpticalFlowSingleScaleSF(curr_from, calcOpticalFlowSingleScaleSF(curr_from,
curr_to, curr_to,
...@@ -600,8 +600,8 @@ void calcOpticalFlowSF(Mat& from, ...@@ -600,8 +600,8 @@ void calcOpticalFlowSF(Mat& from,
confidence, confidence,
averaging_block_size, averaging_block_size,
max_flow, max_flow,
sigma_dist, (float)sigma_dist,
sigma_color); (float)sigma_color);
calcOpticalFlowSingleScaleSF(curr_to, calcOpticalFlowSingleScaleSF(curr_to,
curr_from, curr_from,
...@@ -610,18 +610,18 @@ void calcOpticalFlowSF(Mat& from, ...@@ -610,18 +610,18 @@ void calcOpticalFlowSF(Mat& from,
confidence_inv, confidence_inv,
averaging_block_size, averaging_block_size,
max_flow, max_flow,
sigma_dist, (float)sigma_dist,
sigma_color); (float)sigma_color);
extrapolateFlow(flow, speed_up); extrapolateFlow(flow, speed_up);
extrapolateFlow(flow_inv, speed_up_inv); extrapolateFlow(flow_inv, speed_up_inv);
removeOcclusions(flow, flow_inv, occ_thr, confidence); removeOcclusions(flow, flow_inv, (float)occ_thr, confidence);
removeOcclusions(flow_inv, flow, occ_thr, confidence_inv); removeOcclusions(flow_inv, flow, (float)occ_thr, confidence_inv);
} }
crossBilateralFilter(flow, pyr_from_images[0], confidence, flow, crossBilateralFilter(flow, pyr_from_images[0], confidence, flow,
postprocess_window, sigma_color_fix, sigma_dist_fix); postprocess_window, (float)sigma_color_fix, (float)sigma_dist_fix);
GaussianBlur(flow, flow, Size(3, 3), 5); GaussianBlur(flow, flow, Size(3, 3), 5);
......
...@@ -53,9 +53,9 @@ using namespace std; ...@@ -53,9 +53,9 @@ using namespace std;
namespace cv { namespace cv {
inline static float dist(const Vec3b& p1, const Vec3b& p2) { inline static float dist(const Vec3b& p1, const Vec3b& p2) {
return (p1[0] - p2[0]) * (p1[0] - p2[0]) + return (float)((p1[0] - p2[0]) * (p1[0] - p2[0]) +
(p1[1] - p2[1]) * (p1[1] - p2[1]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
(p1[2] - p2[2]) * (p1[2] - p2[2]); (p1[2] - p2[2]) * (p1[2] - p2[2]));
} }
inline static float dist(const Vec2f& p1, const Vec2f& p2) { inline static float dist(const Vec2f& p1, const Vec2f& p2) {
......
...@@ -87,7 +87,7 @@ static bool readOpticalFlowFromFile(FILE* file, cv::Mat& flow) { ...@@ -87,7 +87,7 @@ static bool readOpticalFlowFromFile(FILE* file, cv::Mat& flow) {
} }
static bool isFlowCorrect(float u) { static bool isFlowCorrect(float u) {
return !isnan(u) && (fabs(u) < 1e9); return !cvIsNaN(u) && (fabs(u) < 1e9);
} }
static float calc_rmse(cv::Mat flow1, cv::Mat flow2) { static float calc_rmse(cv::Mat flow1, cv::Mat flow2) {
...@@ -112,11 +112,11 @@ static float calc_rmse(cv::Mat flow1, cv::Mat flow2) { ...@@ -112,11 +112,11 @@ static float calc_rmse(cv::Mat flow1, cv::Mat flow2) {
} }
} }
} }
return sqrt(sum / (1e-9 + counter)); return (float)sqrt(sum / (1e-9 + counter));
} }
void CV_SimpleFlowTest::run(int) { void CV_SimpleFlowTest::run(int) {
const float MAX_RMSE = 0.6; const float MAX_RMSE = 0.6f;
const string frame1_path = ts->get_data_path() + "optflow/RubberWhale1.png"; const string frame1_path = ts->get_data_path() + "optflow/RubberWhale1.png";
const string frame2_path = ts->get_data_path() + "optflow/RubberWhale2.png"; const string frame2_path = ts->get_data_path() + "optflow/RubberWhale2.png";
const string gt_flow_path = ts->get_data_path() + "optflow/RubberWhale.flo"; const string gt_flow_path = ts->get_data_path() + "optflow/RubberWhale.flo";
......
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