Skip to content

Commit

Permalink
Merge pull request #4 from hsp-iit/impl/sicad_devel
Browse files Browse the repository at this point in the history
Use devel branch of superimpose-mesh-lib.
  • Loading branch information
xEnVrE authored Oct 9, 2022
2 parents 1a1b014 + 5af1e3b commit d3e72d9
Show file tree
Hide file tree
Showing 17 changed files with 3,174 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ jobs:
cmake --build . --config ${{ matrix.build_type }} --target install
cd ${GITHUB_WORKSPACE}
git clone https://github.com/xenvre/superimpose-mesh-lib
git clone https://github.com/robotology/superimpose-mesh-lib
cd superimpose-mesh-lib
git checkout of-aided-tracking
git checkout devel
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE} ..
Expand Down
4 changes: 2 additions & 2 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ RUN git clone https://github.com/robotology/ycm && \
cd ycm && mkdir build && cd build && \
cmake .. && \
make install
RUN git clone https://github.com/xenvre/superimpose-mesh-lib && \
cd superimpose-mesh-lib && git checkout of-aided-tracking && mkdir build && cd build && \
RUN git clone https://github.com/robotology/superimpose-mesh-lib && \
cd superimpose-mesh-lib && git checkout devel && mkdir build && cd build && \
cmake .. && \
make install

Expand Down
13 changes: 13 additions & 0 deletions src/roft-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ set(${LIBRARY_TARGET_NAME}_HDR
include/ROFT/QuaternionModel.h
include/ROFT/ROFTFilter.h
include/ROFT/SpatialVelocityModel.h
include/ROFT/SICAD.h
include/ROFT/SICADModel.h
include/ROFT/SICADShader.h
include/ROFT/SKFCorrection.h
include/ROFT/UKFCorrection.h
)
Expand All @@ -74,6 +77,9 @@ set(${LIBRARY_TARGET_NAME}_SRC
src/QuaternionModel.cpp
src/ROFTFilter.cpp
src/SpatialVelocityModel.cpp
src/SICAD.cpp
src/SICADModel.cpp
src/SICADShader.cpp
src/SKFCorrection.cpp
src/UKFCorrection.cpp
)
Expand Down Expand Up @@ -101,6 +107,13 @@ cmrc_add_resource_library(${LIBRARY_TARGET_NAME}_Resources
meshes/DOPE/009_gelatin_box.obj
meshes/DOPE/010_potted_meat_can.obj
meshes/DOPE/021_bleach_cleanser.obj
shader/shader_background.frag
shader/shader_background.vert
shader/shader_frame.frag
shader/shader_frame.vert
shader/shader_model.frag
shader/shader_model_texture.frag
shader/shader_model.vert
)

# Add library
Expand Down
5 changes: 2 additions & 3 deletions src/roft-lib/include/ROFT/ROFTFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
#include <ROFT/ImageSegmentationMeasurement.h>
#include <ROFT/ImageSegmentationSource.h>
#include <ROFT/ModelParameters.h>
#include <ROFT/SICAD.h>

#include <RobotsIO/Camera/Camera.h>
#include <RobotsIO/Utils/ProbeContainer.h>
#include <RobotsIO/Utils/SpatialVelocityBuffer.h>
#include <RobotsIO/Utils/Transform.h>

#include <SuperimposeMesh/SICAD.h>

#include <opencv2/opencv.hpp>

namespace ROFT {
Expand Down Expand Up @@ -151,7 +150,7 @@ class ROFT::ROFTFilter : public bfl::FilteringAlgorithm,

RobotsIO::Camera::CameraParameters camera_parameters_;

std::unique_ptr<SICAD> renderer_;
std::unique_ptr<ROFT::SICAD> renderer_;

const bool outlier_rejection_;

Expand Down
506 changes: 506 additions & 0 deletions src/roft-lib/include/ROFT/SICAD.h

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions src/roft-lib/include/ROFT/SICADModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT)
*
* This software may be modified and distributed under the terms of the
* GPL-2+ license. See the accompanying LICENSE file for details.
*
*
* Part of this code is taken from https://github.com/robotology/superimpose-mesh-lib/commits/impl/depth
*
* This is the original BSD 3-Clause LICENSE the original code was provided with:
*
* Copyright (c) 2016-2019, Istituto Italiano di Tecnologia (IIT) All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CLAUDIO FANTACCI BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef ROFT_SICAD_MODEL_H
#define ROFT_SICAD_MODEL_H

#include <SuperimposeMesh/Model.h>

#include <ROFT/SICADShader.h>

#include <istream>

namespace ROFT {
class SICADModel;
}


class ROFT::SICADModel
{
public:
SICADModel(const GLchar* path);

SICADModel(const std::basic_istream<char>* model_stream);

void Draw(ROFT::SICADShader shader);

bool has_texture();

protected:
void loadModel(std::string path);

void loadModel(const std::basic_istream<char>* model_stream);

void processNode(aiNode* node, const aiScene* scene);

Mesh processMesh(aiMesh* mesh, const aiScene* scene);

GLint TextureFromFile(const char* path, std::string directory);

std::vector<Mesh::Texture> loadMaterialTextures(aiMaterial* mat, aiTextureType type, std::string typeName);

private:
std::vector<Mesh> meshes_;

std::string directory_;

std::vector<Mesh::Texture> textures_loaded_;
};

#endif /* ROFT_SICAD_MODEL_H */
72 changes: 72 additions & 0 deletions src/roft-lib/include/ROFT/SICADShader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT)
*
* This software may be modified and distributed under the terms of the
* GPL-2+ license. See the accompanying LICENSE file for details.
*
*
* Part of this code is taken from https://github.com/robotology/superimpose-mesh-lib/commits/impl/depth
*
* This is the original BSD 3-Clause LICENSE the original code was provided with:
*
* Copyright (c) 2016-2019, Istituto Italiano di Tecnologia (IIT) All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CLAUDIO FANTACCI BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef ROFT_SICAD_SHADER_H
#define ROFT_SICAD_SHADER_H

#include <exception>
#include <string>

#include <GL/glew.h>

namespace ROFT {
class SICADShader;
}


class ROFT::SICADShader
{
public:
/**
* Create a shader program with given vertex and fragment shader paths.
*/
SICADShader(const std::string& vertex_shader_path, const std::string& fragment_shader_path);

/**
* Activate the shader program.
*/
void install();

/**
* Deactivate the shader program.
*/
void uninstall();


inline const GLuint get_program()
{
return shader_program_id_;
}

private:
/**
* The program ID.
*/
GLuint shader_program_id_;
};

#endif /* ROFT_SICAD_SHADER_H */
40 changes: 40 additions & 0 deletions src/roft-lib/shader/shader_background.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT)
*
* This software may be modified and distributed under the terms of the
* GPL-2+ license. See the accompanying LICENSE file for details.
*
*
* Part of this code is taken from https://github.com/robotology/superimpose-mesh-lib/commits/impl/depth
*
* This is the original BSD 3-Clause LICENSE the original code was provided with:
*
* Copyright (c) 2016-2019, Istituto Italiano di Tecnologia (IIT) All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CLAUDIO FANTACCI BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#version 330 core

in vec3 ourColor;
in vec2 TexCoord;

out vec4 color;

uniform sampler2D ourTexture;

void main()
{
color = texture(ourTexture, TexCoord);
}
44 changes: 44 additions & 0 deletions src/roft-lib/shader/shader_background.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT)
*
* This software may be modified and distributed under the terms of the
* GPL-2+ license. See the accompanying LICENSE file for details.
*
*
* Part of this code is taken from https://github.com/robotology/superimpose-mesh-lib/commits/impl/depth
*
* This is the original BSD 3-Clause LICENSE the original code was provided with:
*
* Copyright (c) 2016-2019, Istituto Italiano di Tecnologia (IIT) All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CLAUDIO FANTACCI BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#version 330 core

layout (location = 0) in vec2 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;

out vec3 ourColor;
out vec2 TexCoord;

uniform mat4 projection;

void main()
{
gl_Position = projection * vec4(position, -99999.99, 1.0f);
ourColor = color;
TexCoord = vec2(texCoord.x, 1.0f - texCoord.y);
}
37 changes: 37 additions & 0 deletions src/roft-lib/shader/shader_frame.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT)
*
* This software may be modified and distributed under the terms of the
* GPL-2+ license. See the accompanying LICENSE file for details.
*
*
* Part of this code is taken from https://github.com/robotology/superimpose-mesh-lib/commits/impl/depth
*
* This is the original BSD 3-Clause LICENSE the original code was provided with:
*
* Copyright (c) 2016-2019, Istituto Italiano di Tecnologia (IIT) All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CLAUDIO FANTACCI BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#version 330 core

in vec3 vert_color;

out vec4 frag_color;

void main()
{
frag_color = vec4(vert_color, 1.0f);
}
43 changes: 43 additions & 0 deletions src/roft-lib/shader/shader_frame.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT)
*
* This software may be modified and distributed under the terms of the
* GPL-2+ license. See the accompanying LICENSE file for details.
*
*
* Part of this code is taken from https://github.com/robotology/superimpose-mesh-lib/commits/impl/depth
*
* This is the original BSD 3-Clause LICENSE the original code was provided with:
*
* Copyright (c) 2016-2019, Istituto Italiano di Tecnologia (IIT) All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CLAUDIO FANTACCI BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;

out vec3 vert_color;

uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

void main()
{
gl_Position = projection * view * model * vec4(position, 1.0f);
vert_color = color;
}
Loading

0 comments on commit d3e72d9

Please sign in to comment.