Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix warnings and compilation errors #20

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ project(cofusion)
set(CMAKE_CXX_STANDARD 14)

# Warnings / Errors
add_compile_options(-Wall -Wno-unused-function -Wno-unused-variable
-Wno-unused-but-set-variable -Wno-unused-but-set-variable -Wno-write-strings
-Wno-deprecated -Wno-deprecated-declarations -Werror -Wno-unknown-pragmas)
add_compile_options(-Wall -Werror -Wno-write-strings -Wno-deprecated-declarations)

# Don't follow symlinks when FILE GLOB_RECURSE (and don't warn)
cmake_policy(SET CMP0009 NEW)
Expand Down
4 changes: 0 additions & 4 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
else(CMAKE_BUILD_TYPE MATCHES Release)
message(STATUS "Release build.")
add_compile_options(-O3)
add_compile_options(-Wno-maybe-uninitialized)
endif(CMAKE_BUILD_TYPE MATCHES Debug)

add_library(${PROJECT_NAME} SHARED
Expand Down Expand Up @@ -138,9 +137,6 @@ target_link_libraries(${PROJECT_NAME}

set_target_properties(${PROJECT_NAME} PROPERTIES INTERFACE_LINK_LIBRARIES "")

# deactivate 'class-memaccess' error for direct memcpy of list of 'Eigen::Vector4f'
target_compile_options(${PROJECT_NAME} PRIVATE "-Wno-error=class-memaccess")


target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
Expand Down
1 change: 1 addition & 0 deletions Core/CoFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ void CoFusion::savePly() {
};

for (auto& m : models) exportModelPLY(m);
for (auto& m : inactiveModels) exportModelPLY(m);
}

void CoFusion::exportPoses() {
Expand Down
1 change: 0 additions & 1 deletion Core/CoFusion.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <list>
#include <iomanip>
#include <memory>
#include <pangolin/gl/glcuda.h>

class CoFusion {
public:
Expand Down
122 changes: 48 additions & 74 deletions Core/Cuda/reduce.cu
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,6 @@
#include "convenience.cuh"
#include "operators.cuh"

#if __CUDA_ARCH__ < 300 || __CUDA_ARCH__ > 700
__inline__ __device__
float __shfl_down(float val, int offset, int width = 32)
{
static __shared__ float shared[MAX_THREADS];
int lane = threadIdx.x % 32;
shared[threadIdx.x] = val;
__syncthreads();
val = (lane + offset < width) ? shared[threadIdx.x + offset] : 0;
__syncthreads();
return val;
}

__inline__ __device__
int __shfl_down(int val, int offset, int width = 32)
{
static __shared__ int shared[MAX_THREADS];
int lane = threadIdx.x % 32;
shared[threadIdx.x] = val;
__syncthreads();
val = (lane + offset < width) ? shared[threadIdx.x + offset] : 0;
__syncthreads();
return val;
}
#endif

#if __CUDA_ARCH__ < 350
template<typename T>
__device__ __forceinline__ T __ldg(const T* ptr)
Expand All @@ -91,41 +65,41 @@ __inline__ __device__ JtJJtrSE3 warpReduceSum(JtJJtrSE3 val)
{
for(int offset = warpSize / 2; offset > 0; offset /= 2)
{
val.aa += __shfl_down(val.aa, offset);
val.ab += __shfl_down(val.ab, offset);
val.ac += __shfl_down(val.ac, offset);
val.ad += __shfl_down(val.ad, offset);
val.ae += __shfl_down(val.ae, offset);
val.af += __shfl_down(val.af, offset);
val.ag += __shfl_down(val.ag, offset);

val.bb += __shfl_down(val.bb, offset);
val.bc += __shfl_down(val.bc, offset);
val.bd += __shfl_down(val.bd, offset);
val.be += __shfl_down(val.be, offset);
val.bf += __shfl_down(val.bf, offset);
val.bg += __shfl_down(val.bg, offset);

val.cc += __shfl_down(val.cc, offset);
val.cd += __shfl_down(val.cd, offset);
val.ce += __shfl_down(val.ce, offset);
val.cf += __shfl_down(val.cf, offset);
val.cg += __shfl_down(val.cg, offset);

val.dd += __shfl_down(val.dd, offset);
val.de += __shfl_down(val.de, offset);
val.df += __shfl_down(val.df, offset);
val.dg += __shfl_down(val.dg, offset);

val.ee += __shfl_down(val.ee, offset);
val.ef += __shfl_down(val.ef, offset);
val.eg += __shfl_down(val.eg, offset);

val.ff += __shfl_down(val.ff, offset);
val.fg += __shfl_down(val.fg, offset);

val.residual += __shfl_down(val.residual, offset);
val.inliers += __shfl_down(val.inliers, offset);
val.aa += __shfl_down_sync(0xFFFFFFFF, val.aa, offset);
val.ab += __shfl_down_sync(0xFFFFFFFF, val.ab, offset);
val.ac += __shfl_down_sync(0xFFFFFFFF, val.ac, offset);
val.ad += __shfl_down_sync(0xFFFFFFFF, val.ad, offset);
val.ae += __shfl_down_sync(0xFFFFFFFF, val.ae, offset);
val.af += __shfl_down_sync(0xFFFFFFFF, val.af, offset);
val.ag += __shfl_down_sync(0xFFFFFFFF, val.ag, offset);

val.bb += __shfl_down_sync(0xFFFFFFFF, val.bb, offset);
val.bc += __shfl_down_sync(0xFFFFFFFF, val.bc, offset);
val.bd += __shfl_down_sync(0xFFFFFFFF, val.bd, offset);
val.be += __shfl_down_sync(0xFFFFFFFF, val.be, offset);
val.bf += __shfl_down_sync(0xFFFFFFFF, val.bf, offset);
val.bg += __shfl_down_sync(0xFFFFFFFF, val.bg, offset);

val.cc += __shfl_down_sync(0xFFFFFFFF, val.cc, offset);
val.cd += __shfl_down_sync(0xFFFFFFFF, val.cd, offset);
val.ce += __shfl_down_sync(0xFFFFFFFF, val.ce, offset);
val.cf += __shfl_down_sync(0xFFFFFFFF, val.cf, offset);
val.cg += __shfl_down_sync(0xFFFFFFFF, val.cg, offset);

val.dd += __shfl_down_sync(0xFFFFFFFF, val.dd, offset);
val.de += __shfl_down_sync(0xFFFFFFFF, val.de, offset);
val.df += __shfl_down_sync(0xFFFFFFFF, val.df, offset);
val.dg += __shfl_down_sync(0xFFFFFFFF, val.dg, offset);

val.ee += __shfl_down_sync(0xFFFFFFFF, val.ee, offset);
val.ef += __shfl_down_sync(0xFFFFFFFF, val.ef, offset);
val.eg += __shfl_down_sync(0xFFFFFFFF, val.eg, offset);

val.ff += __shfl_down_sync(0xFFFFFFFF, val.ff, offset);
val.fg += __shfl_down_sync(0xFFFFFFFF, val.fg, offset);

val.residual += __shfl_down_sync(0xFFFFFFFF, val.residual, offset);
val.inliers += __shfl_down_sync(0xFFFFFFFF, val.inliers, offset);
}

return val;
Expand Down Expand Up @@ -188,20 +162,20 @@ __inline__ __device__ JtJJtrSO3 warpReduceSum(JtJJtrSO3 val)
{
for(int offset = warpSize / 2; offset > 0; offset /= 2)
{
val.aa += __shfl_down(val.aa, offset);
val.ab += __shfl_down(val.ab, offset);
val.ac += __shfl_down(val.ac, offset);
val.ad += __shfl_down(val.ad, offset);
val.aa += __shfl_down_sync(0xFFFFFFFF, val.aa, offset);
val.ab += __shfl_down_sync(0xFFFFFFFF, val.ab, offset);
val.ac += __shfl_down_sync(0xFFFFFFFF, val.ac, offset);
val.ad += __shfl_down_sync(0xFFFFFFFF, val.ad, offset);

val.bb += __shfl_down(val.bb, offset);
val.bc += __shfl_down(val.bc, offset);
val.bd += __shfl_down(val.bd, offset);
val.bb += __shfl_down_sync(0xFFFFFFFF, val.bb, offset);
val.bc += __shfl_down_sync(0xFFFFFFFF, val.bc, offset);
val.bd += __shfl_down_sync(0xFFFFFFFF, val.bd, offset);

val.cc += __shfl_down(val.cc, offset);
val.cd += __shfl_down(val.cd, offset);
val.cc += __shfl_down_sync(0xFFFFFFFF, val.cc, offset);
val.cd += __shfl_down_sync(0xFFFFFFFF, val.cd, offset);

val.residual += __shfl_down(val.residual, offset);
val.inliers += __shfl_down(val.inliers, offset);
val.residual += __shfl_down_sync(0xFFFFFFFF, val.residual, offset);
val.inliers += __shfl_down_sync(0xFFFFFFFF, val.inliers, offset);
}

return val;
Expand Down Expand Up @@ -690,8 +664,8 @@ __inline__ __device__ int2 warpReduceSum(int2 val)
{
for(int offset = warpSize / 2; offset > 0; offset /= 2)
{
val.x += __shfl_down(val.x, offset);
val.y += __shfl_down(val.y, offset);
val.x += __shfl_down_sync(0xFFFFFFFF, val.x, offset);
val.y += __shfl_down_sync(0xFFFFFFFF, val.y, offset);
}

return val;
Expand Down
9 changes: 5 additions & 4 deletions Core/Ferns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ bool Ferns::addFrame(GPUTexture* imageTexture, GPUTexture* vertexTexture, GPUTex
resize.vertex(vertexTexture, verts);
resize.vertex(normalTexture, norms);

Frame* frame = new Frame(num, frames.size(), pose, srcTime, width * height, (unsigned char*)img.data, (Eigen::Vector4f*)verts.data,
(Eigen::Vector4f*)norms.data);
Frame* frame = new Frame(num, frames.size(), pose, srcTime, width * height, (unsigned char*)img.data,
std::vector<Eigen::Vector4f>(verts.data, verts.data + (width * height)),
std::vector<Eigen::Vector4f>(norms.data, norms.data + (width * height)));

int* coOccurrences = new int[frames.size()];

Expand Down Expand Up @@ -202,10 +203,10 @@ Eigen::Matrix4f Ferns::findFrame(std::vector<SurfaceConstraint>& constraints, co
if (minId != -1 && blockHDAware(frame, frames.at(minId)) > 0.3) {
Eigen::Matrix4f fernPose = frames.at(minId)->pose;

vertFern.texture->Upload(frames.at(minId)->initVerts, GL_RGBA, GL_FLOAT);
vertFern.texture->Upload(frames.at(minId)->initVerts.data(), GL_RGBA, GL_FLOAT);
vertCurrent.texture->Upload(vertSmall.data, GL_RGBA, GL_FLOAT);

normFern.texture->Upload(frames.at(minId)->initNorms, GL_RGBA, GL_FLOAT);
normFern.texture->Upload(frames.at(minId)->initNorms.data(), GL_RGBA, GL_FLOAT);
normCurrent.texture->Upload(normSmall.data, GL_RGBA, GL_FLOAT);

// colorFern.texture->Upload(frames.at(minId)->initRgb, GL_RGB, GL_UNSIGNED_BYTE);
Expand Down
22 changes: 8 additions & 14 deletions Core/Ferns.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,28 @@ class Ferns {
class Frame {
public:
Frame(int n, int id, const Eigen::Matrix4f& pose, const int srcTime, const int numPixels, unsigned char* rgb = 0,
Eigen::Vector4f* verts = 0, Eigen::Vector4f* norms = 0)
: goodCodes(0), id(id), pose(pose), srcTime(srcTime), initRgb(rgb), initVerts(verts), initNorms(norms) {
const std::vector<Eigen::Vector4f> &verts = {}, const std::vector<Eigen::Vector4f> &norms = {})
: goodCodes(0), id(id), pose(pose), srcTime(srcTime), initRgb(rgb) {
codes = new unsigned char[n];

if (rgb) {
this->initRgb = new unsigned char[numPixels * 3];
memcpy(this->initRgb, rgb, numPixels * 3);
}

if (verts) {
this->initVerts = new Eigen::Vector4f[numPixels];
memcpy(this->initVerts, verts, numPixels * sizeof(Eigen::Vector4f));
if (!verts.empty()) {
this->initVerts = verts;
}

if (norms) {
this->initNorms = new Eigen::Vector4f[numPixels];
memcpy(this->initNorms, norms, numPixels * sizeof(Eigen::Vector4f));
if (!norms.empty()) {
this->initNorms = norms;
}
}

virtual ~Frame() {
delete[] codes;

if (initRgb) delete[] initRgb;

if (initVerts) delete[] initVerts;

if (initNorms) delete[] initNorms;
}

unsigned char* codes;
Expand All @@ -99,8 +93,8 @@ class Ferns {
Eigen::Matrix4f pose;
const int srcTime;
unsigned char* initRgb;
Eigen::Vector4f* initVerts;
Eigen::Vector4f* initNorms;
std::vector<Eigen::Vector4f> initVerts;
std::vector<Eigen::Vector4f> initNorms;
};

std::vector<Frame*> frames;
Expand Down
8 changes: 2 additions & 6 deletions Core/Model/Deformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ Deformation::Deformation()
sampleProgram(loadProgramGeomFromFile("sample.vert", "sample.geom")),
bufferSize(1024), // max nodes basically
count(0),
vertices(new Eigen::Vector4f[bufferSize]),
vertices(size_t(bufferSize)),
graphPosePoints(new std::vector<Eigen::Vector3f>),
lastDeformTime(0) {
// x, y, z and init time
memset(&vertices[0], 0, bufferSize);

glGenTransformFeedbacks(1, &fid);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
Expand All @@ -51,7 +48,6 @@ Deformation::Deformation()
}

Deformation::~Deformation() {
delete[] vertices;
glDeleteTransformFeedbacks(1, &fid);
glDeleteBuffers(1, &vbo);
glDeleteQueries(1, &countQuery);
Expand Down Expand Up @@ -252,7 +248,7 @@ void Deformation::sampleGraphModel(const OutputBuffer& model) {
if ((int)count > def.k) {
glBindBuffer(GL_ARRAY_BUFFER, vbo);

glGetBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Eigen::Vector4f) * count, vertices);
glGetBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Eigen::Vector4f) * count, vertices.data());

glBindBuffer(GL_ARRAY_BUFFER, 0);

Expand Down
4 changes: 2 additions & 2 deletions Core/Model/Deformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Deformation {
/*std::vector<std::pair<unsigned long long int, Eigen::Matrix4f> > & poseGraph,*/
const bool relaxGraph, std::vector<Constraint>* newRelativeCons = 0);

Eigen::Vector4f* getVertices() { return vertices; }
Eigen::Vector4f* getVertices() { return vertices.data(); }

int getCount() { return int(count); }

Expand All @@ -96,7 +96,7 @@ class Deformation {
const int bufferSize;
GLuint countQuery;
unsigned int count;
Eigen::Vector4f* vertices;
std::vector<Eigen::Vector4f> vertices; // x, y, z and init time

std::vector<std::pair<uint64_t, Eigen::Vector3f> > poseGraphPoints;
std::vector<unsigned long long int> graphPoseTimes;
Expand Down
1 change: 0 additions & 1 deletion Core/Segmentation/Segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ SegmentationResult Segmentation::performSegmentationCRF(std::list<std::shared_pt
const unsigned lowWidth = result.lowRGB.cols;
const unsigned lowHeight = result.lowRGB.rows;
const unsigned lowTotal = result.lowRGB.total();
const unsigned fullTotal = frame.rgb.total();
const unsigned fullWidth = frame.rgb.cols;
const unsigned fullHeight = frame.rgb.rows;

Expand Down
4 changes: 2 additions & 2 deletions Core/Segmentation/Slic.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Slic {
assert(input.isContinuous());
assert(input.total() == spixelNum);

cv::Mat result = cv::Mat(slicInput->noDims[1], slicInput->noDims[0], cv::DataType<Tout>::type);
cv::Mat result = cv::Mat(slicInput->noDims[1], slicInput->noDims[0], cv::traits::Type<Tout>::value);
Tout* resData = (Tout*)result.data;
Tin* inData = (Tin*)input.data;

Expand Down Expand Up @@ -173,7 +173,7 @@ class Slic {
if (image.type() == CV_8UC3)
image.copyTo(res);
else if (image.type() == CV_8UC1)
cv::cvtColor(image, res, CV_GRAY2RGB);
cv::cvtColor(image, res, cv::COLOR_GRAY2RGB);
else
assert(0);
if (swapRedBlue) cv::cvtColor(res, res, cv::COLOR_RGB2BGR);
Expand Down
2 changes: 1 addition & 1 deletion Core/Shaders/FeedbackBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "../Utils/Resolution.h"
#include "../Utils/Intrinsics.h"
#include <pangolin/gl/gl.h>
#include <pangolin/display/opengl_render_state.h>
#include <pangolin/gl/opengl_render_state.h>

/// A feedback buffer holds one vertex per pixel (see uvo)
class FeedbackBuffer {
Expand Down
4 changes: 0 additions & 4 deletions GUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
else(CMAKE_BUILD_TYPE MATCHES Release)
message(STATUS "Release build.")
add_compile_options(-O3)
add_compile_options(-Wno-maybe-uninitialized)
endif(CMAKE_BUILD_TYPE MATCHES Debug)

add_definitions(-Dlinux=1)
Expand All @@ -62,9 +61,6 @@ target_link_libraries(CoFusion
${JPEG_LIBRARIES}
)

# deactivate 'class-memaccess' error for direct memcpy of list of 'Eigen::Vector4f'
target_compile_options(CoFusion PRIVATE "-Wno-error=class-memaccess")

add_library(CoFusionTools SHARED
${tools_srcs})

Expand Down
Loading