diff --git a/src/data.c b/src/data.c index 89d00e56..d6f162fc 100644 --- a/src/data.c +++ b/src/data.c @@ -1076,11 +1076,11 @@ data load_data_detection(int n, char **paths, int m, int w, int h, int c, int bo pright = tmp; } - const int left_shift = min(cut_x[i], max(0, (-pleft*w / ow))); - const int top_shift = min(cut_y[i], max(0, (-ptop*h / oh))); + const int left_shift = min_val_cmp(cut_x[i], max_val_cmp(0, (-pleft*w / ow))); + const int top_shift = min_val_cmp(cut_y[i], max_val_cmp(0, (-ptop*h / oh))); - const int right_shift = min((w - cut_x[i]), max(0, (-pright*w / ow))); - const int bot_shift = min(h - cut_y[i], max(0, (-pbot*h / oh))); + const int right_shift = min_val_cmp((w - cut_x[i]), max_val_cmp(0, (-pright*w / ow))); + const int bot_shift = min_val_cmp(h - cut_y[i], max_val_cmp(0, (-pbot*h / oh))); int k, x, y; diff --git a/src/utils.h b/src/utils.h index f7730d1c..9fa05fa7 100644 --- a/src/utils.h +++ b/src/utils.h @@ -83,6 +83,9 @@ int max_int_index(int *a, int n); boxabs box_to_boxabs(const box* b, const int img_w, const int img_h, const int bounds_check); int make_directory(char *path, int mode); +#define max_val_cmp(a,b) (((a) > (b)) ? (a) : (b)) +#define min_val_cmp(a,b) (((a) < (b)) ? (a) : (b)) + #ifdef __cplusplus } #endif