Skip to content

Commit

Permalink
Migrate to C++17
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuzhny007 committed Oct 13, 2020
1 parent e076afe commit 2700194
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ if (OPENMP_FOUND)
list(APPEND CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic-errors -std=c++14" CACHE STRING COMPILE_FLAGS FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic-errors" CACHE STRING COMPILE_FLAGS FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -march=native -mtune=native -funroll-loops -Wall -DNDEBUG -DBOOST_DISABLE_ASSERTS" CACHE STRING COMPILE_FLAGS FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -march=native -mtune=native -Wall -DDEBUG" CACHE STRING COMPILE_FLAGS FORCE)
elseif (MSVC)
Expand Down
3 changes: 1 addition & 2 deletions data/cmake.bat → data/cmake_vs2017.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ cmake.exe . .. -G "Visual Studio 15 2017 Win64" ^
-DCUDNN_LIBRARY=C:/cudnn-10.0-windows10-x64-v7.6.5.32/cuda/lib/x64/cudnn.lib ^
-DBUILD_YOLO_TENSORRT=ON ^
-DTensorRT_LIBRARY=C:/TensorRT-5.1.5.0/lib/*.lib ^
-DTensorRT_INCLUDE_DIR=C:/TensorRT-5.1.5.0/include ^
-Dgflags_DIR=C:/work/libraries/gflags/build_x64
-DTensorRT_INCLUDE_DIR=C:/TensorRT-5.1.5.0/include
cmake.exe --build . -j 6 --config Release
19 changes: 19 additions & 0 deletions data/cmake_vs2019.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cd ..
md build
cd build
cmake.exe . .. -G "Visual Studio 16 2019" -A "x64" ^
-DOpenCV_DIR=C:/work/libraries/opencv/opencv_64_cuda ^
-DUSE_OCV_BGFG=ON ^
-DUSE_OCV_KCF=ON ^
-DUSE_OCV_UKF=ON ^
-DSILENT_WORK=OFF ^
-DBUILD_EXAMPLES=ON ^
-DBUILD_ASYNC_DETECTOR=ON ^
-DBUILD_CARS_COUNTING=ON ^
-DBUILD_YOLO_LIB=ON ^
-DCUDNN_INCLUDE_DIR=C:/cudnn-10.0-windows10-x64-v7.6.5.32/cuda/include ^
-DCUDNN_LIBRARY=C:/cudnn-10.0-windows10-x64-v7.6.5.32/cuda/lib/x64/cudnn.lib ^
-DBUILD_YOLO_TENSORRT=ON ^
-DTensorRT_LIBRARY=C:/TensorRT-5.1.5.0/lib/*.lib ^
-DTensorRT_INCLUDE_DIR=C:/TensorRT-5.1.5.0/include
cmake.exe --build . -j 6 --config Release
11 changes: 7 additions & 4 deletions src/Detector/tensorrt_yolo/calibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SOFTWARE.
#include <fstream>
#include <iostream>
#include <iterator>
#include <random>

Int8EntropyCalibrator::Int8EntropyCalibrator(const uint32_t& batchSize, const std::string& calibImages,
const std::string& calibImagesPath,
Expand All @@ -44,10 +45,12 @@ Int8EntropyCalibrator::Int8EntropyCalibrator(const uint32_t& batchSize, const st
{
if (!fileExists(m_CalibTableFilePath, false))
{
m_ImageList = loadImageList(calibImages, calibImagesPath);
m_ImageList.resize(static_cast<int>(m_ImageList.size() / m_BatchSize) * m_BatchSize);
std::random_shuffle(m_ImageList.begin(), m_ImageList.end(),
[](int i) { return rand() % i; });
std::random_device rng;
std::mt19937 urng(rng());

m_ImageList = loadImageList(calibImages, calibImagesPath);
m_ImageList.resize(static_cast<int>(m_ImageList.size() / m_BatchSize) * m_BatchSize);
std::shuffle(m_ImageList.begin(), m_ImageList.end(), urng);
}

NV_CUDA_CHECK(cudaMalloc(&m_DeviceInput, m_InputCount * sizeof(float)));
Expand Down
1 change: 0 additions & 1 deletion src/Detector/tensorrt_yolo/class_yolo_detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "yolov4.h"
#include "yolov5.h"

#include <experimental/filesystem>
#include <fstream>
#include <string>
#include <chrono>
Expand Down
11 changes: 9 additions & 2 deletions src/Detector/tensorrt_yolo/ds_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ SOFTWARE.
*
*/
#include "ds_image.h"

#ifdef _WIN32
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

DsImage::DsImage() :
m_Height(0),
Expand Down Expand Up @@ -97,7 +104,7 @@ DsImage::DsImage(const std::string& path, const int& inputH, const int& inputW)
m_RNG(cv::RNG(unsigned(std::time(0)))),
m_ImageName()
{
m_ImageName = std::experimental::filesystem::path(path).stem().string();
m_ImageName = fs::path(path).stem().string();
m_OrigImage = cv::imread(path, cv::IMREAD_UNCHANGED);

if (!m_OrigImage.data || m_OrigImage.cols <= 0 || m_OrigImage.rows <= 0)
Expand Down Expand Up @@ -194,4 +201,4 @@ std::string DsImage::exportJson() const
json << "}";
}
return json.str();
}
}
10 changes: 9 additions & 1 deletion src/Detector/tensorrt_yolo/trt_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ SOFTWARE.

#include "trt_utils.h"
#include <NvInferRuntimeCommon.h>

#ifdef _WIN32
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

#include <fstream>
#include <iomanip>
using namespace nvinfer1;
Expand Down Expand Up @@ -82,7 +90,7 @@ float clamp(const float val, const float minVal, const float maxVal)

bool fileExists(const std::string fileName, bool verbose)
{
if (!std::experimental::filesystem::exists(std::experimental::filesystem::path(fileName)))
if (!fs::exists(fs::path(fileName)))
{
if (verbose) std::cout << "File does not exist : " << fileName << std::endl;
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Tracker/graph/GTL/src/bid_dijkstra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ __GTL_BEGIN_NAMESPACE
* @internal
* Binary predicate that compares two nodes according to their distance.
*/
class less_dist : public std::binary_function<node, GTL::node, bool>
class less_dist
{
public:
/**
Expand Down
2 changes: 1 addition & 1 deletion src/Tracker/graph/GTL/src/dijkstra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ __GTL_BEGIN_NAMESPACE
* @internal
* Binary predicate that compares two nodes according to their distance.
*/
class less_dist : public std::binary_function<node, GTL::node, bool>
class less_dist
{
public:
/**
Expand Down

0 comments on commit 2700194

Please sign in to comment.