From 512acd8cba99c7ec21d542b32a2881671da39cba Mon Sep 17 00:00:00 2001 From: perseusdg Date: Thu, 21 Jan 2021 09:29:27 +0400 Subject: [PATCH] minor fixes --- Issues.md | 1 + demo/demo/map.cpp | 5 +++++ include/tkDNN/utils.h | 14 +++++++++++--- src/Yolo.cpp | 9 +++++---- 4 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 Issues.md diff --git a/Issues.md b/Issues.md new file mode 100644 index 0000000..4875b13 --- /dev/null +++ b/Issues.md @@ -0,0 +1 @@ +1)error C2131 @ Yolo3Detection.cpp(97) -> expression doesnt evaluate to a constant caused to read of variable outside its lifetime \ No newline at end of file diff --git a/demo/demo/map.cpp b/demo/demo/map.cpp index 356e35a..8e363ee 100644 --- a/demo/demo/map.cpp +++ b/demo/demo/map.cpp @@ -2,7 +2,12 @@ #include #include #include /* srand, rand */ +#ifdef __linux__ #include +#elif _WIN32 +#include +#endif + #include #include "utils.h" diff --git a/include/tkDNN/utils.h b/include/tkDNN/utils.h index cb3c18f..1404509 100644 --- a/include/tkDNN/utils.h +++ b/include/tkDNN/utils.h @@ -15,10 +15,12 @@ #ifdef __linux__ #include #elif _WIN32 -#include -#endif +#define NOMINMAX +#include +#endif #include +#include #define dnnType float @@ -55,7 +57,13 @@ #define TKDNN_TSTOP TKDNN_TSTOP_C(COL_CYANB, TKDNN_VERBOSE) #elif _WIN32 -#endif +#define TKDNN_TSTART auto start = std::chrono::high_resolution_clock::now(); +#define TKDNN_TSTOP auto stop = std::chrono::high_resolution_clock::now(); \ +std::chrono::duration duration = stop -start; \ +auto time_ms = std::chrono::duration_cast(duration);\ +double t_ns = time_ms.count(); +#endif + /******************************************************** * Prints the error message, and exits diff --git a/src/Yolo.cpp b/src/Yolo.cpp index 9737e74..6d0b546 100644 --- a/src/Yolo.cpp +++ b/src/Yolo.cpp @@ -9,6 +9,7 @@ #include "Layer.h" #include "kernels.h" + namespace tk { namespace dnn { Yolo::Yolo(Network *net, int classes, int num, std::string fname_weights, int n_masks, float scale_xy, double nms_thresh, nmsKind_t nsm_kind, int new_coords) : @@ -209,10 +210,10 @@ float yolo_box_iou(Yolo::box a, Yolo::box b) } void box_c(const Yolo::box a, const Yolo::box b, float& top, float& bot, float& left, float& right) { - top = std::min(a.y - a.h / 2, b.y - b.h / 2); - bot = std::max(a.y + a.h / 2, b.y + b.h / 2); - left = std::min(a.x - a.w / 2, b.x - b.w / 2); - right = std::max(a.x + a.w / 2, b.x + b.w / 2); + top = (std::min)(a.y - a.h / 2, b.y - b.h / 2); + bot = (std::max)(a.y + a.h / 2, b.y + b.h / 2); + left = (std::min)(a.x - a.w / 2, b.x - b.w / 2); + right = (std::max)(a.x + a.w / 2, b.x + b.w / 2); } // https://github.com/Zzh-tju/DIoU-darknet