Skip to content

Commit 2700194

Browse files
committed
Migrate to C++17
1 parent e076afe commit 2700194

9 files changed

Lines changed: 49 additions & 14 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ if (OPENMP_FOUND)
1212
list(APPEND CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
1313
endif()
1414

15-
set(CMAKE_CXX_STANDARD 14)
15+
set(CMAKE_CXX_STANDARD 17)
1616

1717
if (CMAKE_COMPILER_IS_GNUCXX)
18-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic-errors -std=c++14" CACHE STRING COMPILE_FLAGS FORCE)
18+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic-errors" CACHE STRING COMPILE_FLAGS FORCE)
1919
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -march=native -mtune=native -funroll-loops -Wall -DNDEBUG -DBOOST_DISABLE_ASSERTS" CACHE STRING COMPILE_FLAGS FORCE)
2020
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -march=native -mtune=native -Wall -DDEBUG" CACHE STRING COMPILE_FLAGS FORCE)
2121
elseif (MSVC)

data/cmake.bat renamed to data/cmake_vs2017.bat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ cmake.exe . .. -G "Visual Studio 15 2017 Win64" ^
1515
-DCUDNN_LIBRARY=C:/cudnn-10.0-windows10-x64-v7.6.5.32/cuda/lib/x64/cudnn.lib ^
1616
-DBUILD_YOLO_TENSORRT=ON ^
1717
-DTensorRT_LIBRARY=C:/TensorRT-5.1.5.0/lib/*.lib ^
18-
-DTensorRT_INCLUDE_DIR=C:/TensorRT-5.1.5.0/include ^
19-
-Dgflags_DIR=C:/work/libraries/gflags/build_x64
18+
-DTensorRT_INCLUDE_DIR=C:/TensorRT-5.1.5.0/include
2019
cmake.exe --build . -j 6 --config Release

data/cmake_vs2019.bat

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cd ..
2+
md build
3+
cd build
4+
cmake.exe . .. -G "Visual Studio 16 2019" -A "x64" ^
5+
-DOpenCV_DIR=C:/work/libraries/opencv/opencv_64_cuda ^
6+
-DUSE_OCV_BGFG=ON ^
7+
-DUSE_OCV_KCF=ON ^
8+
-DUSE_OCV_UKF=ON ^
9+
-DSILENT_WORK=OFF ^
10+
-DBUILD_EXAMPLES=ON ^
11+
-DBUILD_ASYNC_DETECTOR=ON ^
12+
-DBUILD_CARS_COUNTING=ON ^
13+
-DBUILD_YOLO_LIB=ON ^
14+
-DCUDNN_INCLUDE_DIR=C:/cudnn-10.0-windows10-x64-v7.6.5.32/cuda/include ^
15+
-DCUDNN_LIBRARY=C:/cudnn-10.0-windows10-x64-v7.6.5.32/cuda/lib/x64/cudnn.lib ^
16+
-DBUILD_YOLO_TENSORRT=ON ^
17+
-DTensorRT_LIBRARY=C:/TensorRT-5.1.5.0/lib/*.lib ^
18+
-DTensorRT_INCLUDE_DIR=C:/TensorRT-5.1.5.0/include
19+
cmake.exe --build . -j 6 --config Release

src/Detector/tensorrt_yolo/calibrator.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SOFTWARE.
2727
#include <fstream>
2828
#include <iostream>
2929
#include <iterator>
30+
#include <random>
3031

3132
Int8EntropyCalibrator::Int8EntropyCalibrator(const uint32_t& batchSize, const std::string& calibImages,
3233
const std::string& calibImagesPath,
@@ -44,10 +45,12 @@ Int8EntropyCalibrator::Int8EntropyCalibrator(const uint32_t& batchSize, const st
4445
{
4546
if (!fileExists(m_CalibTableFilePath, false))
4647
{
47-
m_ImageList = loadImageList(calibImages, calibImagesPath);
48-
m_ImageList.resize(static_cast<int>(m_ImageList.size() / m_BatchSize) * m_BatchSize);
49-
std::random_shuffle(m_ImageList.begin(), m_ImageList.end(),
50-
[](int i) { return rand() % i; });
48+
std::random_device rng;
49+
std::mt19937 urng(rng());
50+
51+
m_ImageList = loadImageList(calibImages, calibImagesPath);
52+
m_ImageList.resize(static_cast<int>(m_ImageList.size() / m_BatchSize) * m_BatchSize);
53+
std::shuffle(m_ImageList.begin(), m_ImageList.end(), urng);
5154
}
5255

5356
NV_CUDA_CHECK(cudaMalloc(&m_DeviceInput, m_InputCount * sizeof(float)));

src/Detector/tensorrt_yolo/class_yolo_detector.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "yolov4.h"
1111
#include "yolov5.h"
1212

13-
#include <experimental/filesystem>
1413
#include <fstream>
1514
#include <string>
1615
#include <chrono>

src/Detector/tensorrt_yolo/ds_image.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ SOFTWARE.
2323
*
2424
*/
2525
#include "ds_image.h"
26+
27+
#ifdef _WIN32
28+
#include <filesystem>
29+
namespace fs = std::filesystem;
30+
#else
2631
#include <experimental/filesystem>
32+
namespace fs = std::experimental::filesystem;
33+
#endif
2734

2835
DsImage::DsImage() :
2936
m_Height(0),
@@ -97,7 +104,7 @@ DsImage::DsImage(const std::string& path, const int& inputH, const int& inputW)
97104
m_RNG(cv::RNG(unsigned(std::time(0)))),
98105
m_ImageName()
99106
{
100-
m_ImageName = std::experimental::filesystem::path(path).stem().string();
107+
m_ImageName = fs::path(path).stem().string();
101108
m_OrigImage = cv::imread(path, cv::IMREAD_UNCHANGED);
102109

103110
if (!m_OrigImage.data || m_OrigImage.cols <= 0 || m_OrigImage.rows <= 0)
@@ -194,4 +201,4 @@ std::string DsImage::exportJson() const
194201
json << "}";
195202
}
196203
return json.str();
197-
}
204+
}

src/Detector/tensorrt_yolo/trt_utils.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ SOFTWARE.
2525

2626
#include "trt_utils.h"
2727
#include <NvInferRuntimeCommon.h>
28+
29+
#ifdef _WIN32
30+
#include <filesystem>
31+
namespace fs = std::filesystem;
32+
#else
2833
#include <experimental/filesystem>
34+
namespace fs = std::experimental::filesystem;
35+
#endif
36+
2937
#include <fstream>
3038
#include <iomanip>
3139
using namespace nvinfer1;
@@ -82,7 +90,7 @@ float clamp(const float val, const float minVal, const float maxVal)
8290

8391
bool fileExists(const std::string fileName, bool verbose)
8492
{
85-
if (!std::experimental::filesystem::exists(std::experimental::filesystem::path(fileName)))
93+
if (!fs::exists(fs::path(fileName)))
8694
{
8795
if (verbose) std::cout << "File does not exist : " << fileName << std::endl;
8896
return false;

src/Tracker/graph/GTL/src/bid_dijkstra.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ __GTL_BEGIN_NAMESPACE
1919
* @internal
2020
* Binary predicate that compares two nodes according to their distance.
2121
*/
22-
class less_dist : public std::binary_function<node, GTL::node, bool>
22+
class less_dist
2323
{
2424
public:
2525
/**

src/Tracker/graph/GTL/src/dijkstra.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ __GTL_BEGIN_NAMESPACE
1919
* @internal
2020
* Binary predicate that compares two nodes according to their distance.
2121
*/
22-
class less_dist : public std::binary_function<node, GTL::node, bool>
22+
class less_dist
2323
{
2424
public:
2525
/**

0 commit comments

Comments
 (0)