From 3707657085ca9ef95694c637012c2f24a66b5945 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Mon, 9 Mar 2020 09:23:16 +0200 Subject: [PATCH] WIP fix warning as error problems --- CMakeLists.txt | 6 +++--- applications/calibration/src/lens.cpp | 4 ++-- applications/vision/CMakeLists.txt | 2 +- applications/vision/src/main.cpp | 2 +- components/calibration/src/parameters.cpp | 2 +- components/common/cpp/include/ftl/configurable.hpp | 3 +++ components/common/cpp/include/ftl/cuda_texture.hpp | 12 ++++++------ components/common/cpp/src/timer.cpp | 1 - components/net/cpp/src/universe.cpp | 4 ++-- components/net/cpp/test/net_integration.cpp | 2 ++ components/renderers/cpp/src/CUDARender.cpp | 14 ++------------ components/renderers/cpp/src/overlay.cpp | 5 +++++ components/rgbd-sources/include/ftl/rgbd/frame.hpp | 6 +++--- 13 files changed, 31 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f60dd1cd2..bc61a7a67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,9 +328,9 @@ if (WIN32) # TODO(nick) Should do based upon compiler (VS) set(OS_LIBS "") else() add_definitions(-DUNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -msse3 -Werror") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -pg -Wall") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wall -mfpmath=sse") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -msse3 -Werror -Wall") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -pg") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -mfpmath=sse") set(OS_LIBS "dl") endif() diff --git a/applications/calibration/src/lens.cpp b/applications/calibration/src/lens.cpp index ffa3cd078..72694ebac 100644 --- a/applications/calibration/src/lens.cpp +++ b/applications/calibration/src/lens.cpp @@ -193,7 +193,7 @@ void ftl::calibration::intrinsic(map<string, string> &opt) { cv::destroyAllWindows(); - bool calib_ok = true; + //bool calib_ok = true; for (int c = 0; c < n_cameras; c++) { LOG(INFO) << "Calculating intrinsic paramters for camera " << std::to_string(c); @@ -219,7 +219,7 @@ void ftl::calibration::intrinsic(map<string, string> &opt) { continue; } - calib_ok = true; + //calib_ok = true; calibrate_flags &= ~cv::CALIB_FIX_K1 & ~cv::CALIB_FIX_K2 & ~cv::CALIB_FIX_K3; double fovx, fovy, focal_length, aspect_ratio; diff --git a/applications/vision/CMakeLists.txt b/applications/vision/CMakeLists.txt index 78d4bb28c..a40126b95 100644 --- a/applications/vision/CMakeLists.txt +++ b/applications/vision/CMakeLists.txt @@ -6,7 +6,7 @@ set(CVNODESRC src/main.cpp - src/middlebury.cpp + #src/middlebury.cpp ) add_executable(ftl-vision ${CVNODESRC}) diff --git a/applications/vision/src/main.cpp b/applications/vision/src/main.cpp index 06c352b25..2dfabcc42 100644 --- a/applications/vision/src/main.cpp +++ b/applications/vision/src/main.cpp @@ -17,7 +17,7 @@ #include <opencv2/opencv.hpp> #include <ftl/rgbd.hpp> -#include <ftl/middlebury.hpp> +//#include <ftl/middlebury.hpp> #include <ftl/net/universe.hpp> #include <ftl/master.hpp> #include <nlohmann/json.hpp> diff --git a/components/calibration/src/parameters.cpp b/components/calibration/src/parameters.cpp index ef352b8a1..d0e20aa63 100644 --- a/components/calibration/src/parameters.cpp +++ b/components/calibration/src/parameters.cpp @@ -206,7 +206,7 @@ bool ftl::calibration::validate::distortionCoefficients(const Mat &D, Size size) (D.total() == 8) || (D.total() == 12))) { return false; } - for (int i = 0; i < D.total(); i++) { + for (size_t i = 0; i < D.total(); i++) { if (!std::isfinite(D.at<double>(i))) { return false; } } diff --git a/components/common/cpp/include/ftl/configurable.hpp b/components/common/cpp/include/ftl/configurable.hpp index dfe84dc13..1c157ba60 100644 --- a/components/common/cpp/include/ftl/configurable.hpp +++ b/components/common/cpp/include/ftl/configurable.hpp @@ -15,6 +15,9 @@ #define REQUIRED(...) required(__func__, __VA_ARGS__) +// TODO: Find a better place for this +#define UNUSED(A) (void)(A) + namespace ftl { class Configurable; diff --git a/components/common/cpp/include/ftl/cuda_texture.hpp b/components/common/cpp/include/ftl/cuda_texture.hpp index 8edf9c3fe..6f710d9b7 100644 --- a/components/common/cpp/include/ftl/cuda_texture.hpp +++ b/components/common/cpp/include/ftl/cuda_texture.hpp @@ -53,8 +53,8 @@ class TextureObjectBase { inline size_t pixelPitch() const { return pitch2_; } inline uchar *devicePtr() const { return ptr_; }; __host__ __device__ inline uchar *devicePtr(int v) const { return &ptr_[v*pitch_]; } - __host__ __device__ inline int width() const { return width_; } - __host__ __device__ inline int height() const { return height_; } + __host__ __device__ inline size_t width() const { return width_; } + __host__ __device__ inline size_t height() const { return height_; } __host__ __device__ inline cudaTextureObject_t cudaTexture() const { return texobj_; } cv::cuda::GpuMat to_gpumat() const; @@ -72,8 +72,8 @@ class TextureObjectBase { cudaTextureObject_t texobj_; size_t pitch_; size_t pitch2_; // in T units - int width_; - int height_; + size_t width_; + size_t height_; uchar *ptr_; // Device memory pointer bool needsfree_; // We manage memory, so free it bool needsdestroy_; // The texture object needs to be destroyed @@ -107,7 +107,7 @@ class TextureObject : public TextureObjectBase { operator cv::cuda::GpuMat(); void create(const cv::Size &); - void create(int w, int h); + void create(size_t w, size_t h); __host__ __device__ T *devicePtr() const { return (T*)(ptr_); }; __host__ __device__ T *devicePtr(int v) const { return &(T*)(ptr_)[v*pitch2_]; } @@ -292,7 +292,7 @@ void TextureObject<T>::create(const cv::Size &s) { } template <typename T> -void TextureObject<T>::create(int w, int h) { +void TextureObject<T>::create(size_t w, size_t h) { if (width_ != w || height_ != h) { *this = std::move(TextureObject<T>(w, h)); } diff --git a/components/common/cpp/src/timer.cpp b/components/common/cpp/src/timer.cpp index 79fb8720b..7d1cc2b5f 100644 --- a/components/common/cpp/src/timer.cpp +++ b/components/common/cpp/src/timer.cpp @@ -54,7 +54,6 @@ double ftl::timer::get_time_seconds() { } static void waitTimePoint() { - auto start = high_resolution_clock::now(); int64_t now = get_time(); int64_t target = now / mspf; int64_t msdelay = mspf - (now % mspf); diff --git a/components/net/cpp/src/universe.cpp b/components/net/cpp/src/universe.cpp index d3b4d1f32..d5aeb743a 100644 --- a/components/net/cpp/src/universe.cpp +++ b/components/net/cpp/src/universe.cpp @@ -46,8 +46,8 @@ callback_t ftl::net::Universe::cbid__ = 0; Universe::Universe() : Configurable(), active_(true), - impl_(new ftl::net::NetImplDetail), this_peer(ftl::net::this_peer), + impl_(new ftl::net::NetImplDetail), phase_(0), send_size_(TCP_SEND_BUFFER_SIZE), recv_size_(TCP_RECEIVE_BUFFER_SIZE), @@ -62,8 +62,8 @@ Universe::Universe() : Universe::Universe(nlohmann::json &config) : Configurable(config), active_(true), - impl_(new ftl::net::NetImplDetail), this_peer(ftl::net::this_peer), + impl_(new ftl::net::NetImplDetail), phase_(0), send_size_(value("tcp_send_buffer",TCP_SEND_BUFFER_SIZE)), recv_size_(value("tcp_recv_buffer",TCP_RECEIVE_BUFFER_SIZE)), diff --git a/components/net/cpp/test/net_integration.cpp b/components/net/cpp/test/net_integration.cpp index 200e3c5f9..3f43ceb27 100644 --- a/components/net/cpp/test/net_integration.cpp +++ b/components/net/cpp/test/net_integration.cpp @@ -286,6 +286,7 @@ TEST_CASE("Peer::call() __ping__", "") { for (int i=0; i<100; ++i) { ftl::pool.push([&count, p](int id) { int64_t res = p->call<int64_t>("__ping__"); + REQUIRE( res > 0 ); count++; }); } @@ -297,6 +298,7 @@ TEST_CASE("Peer::call() __ping__", "") { bool errored = false; try { int64_t res = p->call<int64_t>("__ping2__"); + REQUIRE( res > 0 ); // Not called or required actually } catch (const ftl::exception &e) { errored = true; } diff --git a/components/renderers/cpp/src/CUDARender.cpp b/components/renderers/cpp/src/CUDARender.cpp index a3fb4cdd2..9fb3c045c 100644 --- a/components/renderers/cpp/src/CUDARender.cpp +++ b/components/renderers/cpp/src/CUDARender.cpp @@ -31,16 +31,6 @@ using ftl::cuda::Mask; using ftl::render::parseCUDAColour; using ftl::render::parseCVColour; -static Eigen::Affine3d create_rotation_matrix(float ax, float ay, float az) { - Eigen::Affine3d rx = - Eigen::Affine3d(Eigen::AngleAxisd(ax, Eigen::Vector3d(1, 0, 0))); - Eigen::Affine3d ry = - Eigen::Affine3d(Eigen::AngleAxisd(ay, Eigen::Vector3d(0, 1, 0))); - Eigen::Affine3d rz = - Eigen::Affine3d(Eigen::AngleAxisd(az, Eigen::Vector3d(0, 0, 1))); - return rz * rx * ry; -} - CUDARender::CUDARender(nlohmann::json &config) : ftl::render::Renderer(config), scene_(nullptr) { /*if (config["clipping"].is_object()) { auto &c = config["clipping"]; @@ -208,7 +198,7 @@ void CUDARender::_adjustDepthThresholds(const ftl::rgbd::Camera &fcam) { ftl::cuda::TextureObject<float> &CUDARender::_getDepthBuffer(const cv::Size &size) { for (auto *b : depth_buffers_) { - if (b->width() == size.width && b->height() == size.height) return *b; + if (b->width() == static_cast<size_t>(size.width) && b->height() == static_cast<size_t>(size.height)) return *b; } auto *nb = new ftl::cuda::TextureObject<float>(size.width, size.height); depth_buffers_.push_back(nb); @@ -217,7 +207,7 @@ ftl::cuda::TextureObject<float> &CUDARender::_getDepthBuffer(const cv::Size &siz ftl::cuda::TextureObject<short2> &CUDARender::_getScreenBuffer(const cv::Size &size) { for (auto *b : screen_buffers_) { - if (b->width() == size.width && b->height() == size.height) return *b; + if (b->width() == static_cast<size_t>(size.width) && b->height() == static_cast<size_t>(size.height)) return *b; } auto *nb = new ftl::cuda::TextureObject<short2>(size.width, size.height); screen_buffers_.push_back(nb); diff --git a/components/renderers/cpp/src/overlay.cpp b/components/renderers/cpp/src/overlay.cpp index 78e6645c7..9ea3af5ed 100644 --- a/components/renderers/cpp/src/overlay.cpp +++ b/components/renderers/cpp/src/overlay.cpp @@ -177,6 +177,8 @@ void Overlay::_drawFilledShape(Shape shape, const Eigen::Matrix4d &pose, float s Eigen::Matrix4f mv = pose.cast<float>(); auto [offset,count, loffset, lcount] = shapes_[shape]; + UNUSED(loffset); + UNUSED(lcount); oShader.setUniform("scale", scale); oShader.setUniform("pose", mv); oShader.setUniform("blockColour", Eigen::Vector4f(float(c.x)/255.0f,float(c.y)/255.0f,float(c.z)/255.0f,float(c.w)/255.0f)); @@ -215,6 +217,9 @@ void Overlay::_drawAxis(const Eigen::Matrix4d &pose, const Eigen::Vector3f &scal Eigen::Matrix4f mv = pose.cast<float>(); auto [offset,count,loffset,lcount] = shapes_[Shape::AXIS]; + UNUSED(offset); + UNUSED(count); + UNUSED(lcount); oShader.setUniform("scale", scale); oShader.setUniform("pose", mv); diff --git a/components/rgbd-sources/include/ftl/rgbd/frame.hpp b/components/rgbd-sources/include/ftl/rgbd/frame.hpp index 688e5fed2..6cbfcec55 100644 --- a/components/rgbd-sources/include/ftl/rgbd/frame.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/frame.hpp @@ -210,7 +210,7 @@ ftl::cuda::TextureObject<T> &Frame::getTexture(ftl::codecs::Channel c) { auto &m = getData(c); if (!m.isgpu) throw FTL_Error("Texture channel is not on GPU"); - if (m.tex.cvType() != ftl::traits::OpenCVType<T>::value || m.tex.width() != m.gpu.cols || m.tex.height() != m.gpu.rows || m.gpu.type() != m.tex.cvType()) { + if (m.tex.cvType() != ftl::traits::OpenCVType<T>::value || m.tex.width() != static_cast<size_t>(m.gpu.cols) || m.tex.height() != static_cast<size_t>(m.gpu.rows) || m.gpu.type() != m.tex.cvType()) { throw FTL_Error("Texture has not been created properly for this channel: " << (int)c); } @@ -240,7 +240,7 @@ ftl::cuda::TextureObject<T> &Frame::createTexture(ftl::codecs::Channel c, const if (m.tex.devicePtr() == nullptr) { //LOG(INFO) << "Creating texture object"; m.tex = ftl::cuda::TextureObject<T>(m.gpu, interpolated); - } else if (m.tex.cvType() != ftl::traits::OpenCVType<T>::value || m.tex.width() != m.gpu.cols || m.tex.height() != m.gpu.rows) { + } else if (m.tex.cvType() != ftl::traits::OpenCVType<T>::value || m.tex.width() != static_cast<size_t>(m.gpu.cols) || m.tex.height() != static_cast<size_t>(m.gpu.rows)) { //LOG(INFO) << "Recreating texture object for '" << ftl::codecs::name(c) << "'"; m.tex.free(); m.tex = ftl::cuda::TextureObject<T>(m.gpu, interpolated); @@ -272,7 +272,7 @@ ftl::cuda::TextureObject<T> &Frame::createTexture(ftl::codecs::Channel c, bool i if (m.tex.devicePtr() == nullptr) { //LOG(INFO) << "Creating texture object"; m.tex = ftl::cuda::TextureObject<T>(m.gpu, interpolated); - } else if (m.tex.cvType() != ftl::traits::OpenCVType<T>::value || m.tex.width() != m.gpu.cols || m.tex.height() != m.gpu.rows || m.tex.devicePtr() != m.gpu.data) { + } else if (m.tex.cvType() != ftl::traits::OpenCVType<T>::value || m.tex.width() != static_cast<size_t>(m.gpu.cols) || m.tex.height() != static_cast<size_t>(m.gpu.rows) || m.tex.devicePtr() != m.gpu.data) { //LOG(INFO) << "Recreating texture object for '" << ftl::codecs::name(c) << "'."; m.tex.free(); m.tex = ftl::cuda::TextureObject<T>(m.gpu, interpolated); -- GitLab