Skip to content

Commit

Permalink
Merge pull request stereolabs#3 from stereolabs/update_from_3.3.0
Browse files Browse the repository at this point in the history
Update from 3.3.0
  • Loading branch information
adujardin authored Oct 28, 2020
2 parents a4d180e + 8a569b5 commit 3180232
Show file tree
Hide file tree
Showing 76 changed files with 5,197 additions and 3,554 deletions.
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.1)
PROJECT(SamplesAndTutos)

OPTION(INSTALL_SAMPLES "Once build, deploy samples into bin" ON)

SET(SAMPLE_LIST "")
add_subdirectory("camera control/cpp")
add_subdirectory("camera streaming/receiver/cpp")
add_subdirectory("camera streaming/sender/cpp")
add_subdirectory("depth sensing/cpp")
add_subdirectory("object detection/image viewer/cpp")
add_subdirectory("object detection/birds eye viewer/cpp")
add_subdirectory("body tracking/cpp")
add_subdirectory("plane detection/cpp")
add_subdirectory("positional tracking/cpp")
add_subdirectory("spatial mapping/advanced point cloud mapping/cpp")
add_subdirectory("spatial mapping/basic/cpp")
add_subdirectory("svo recording/export/cpp")
add_subdirectory("svo recording/playback/cpp")
add_subdirectory("svo recording/recording/cpp")
add_subdirectory("other/cuda refocus")
add_subdirectory("other/opengl gpu interop")
add_subdirectory("other/multi camera/cpp")
add_subdirectory("tutorials")

if(${INSTALL_SAMPLES})
INSTALL(TARGETS ${SAMPLE_LIST} RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin)
endif()
3 changes: 3 additions & 0 deletions body tracking/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ target_link_libraries(${PROJECT_NAME}
${OPENGL_LIBRARIES}
${GLUT_LIBRARY}
${GLEW_LIBRARIES})

LIST(APPEND SAMPLE_LIST ${PROJECT_NAME})
SET(SAMPLE_LIST "${SAMPLE_LIST}" PARENT_SCOPE)
253 changes: 129 additions & 124 deletions body tracking/cpp/include/GLViewer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,177 +26,182 @@
class Shader {
public:

Shader() {}
Shader(GLchar* vs, GLchar* fs);
~Shader();
GLuint getProgramId();

static const GLint ATTRIB_VERTICES_POS = 0;
static const GLint ATTRIB_COLOR_POS = 1;
Shader() {}
Shader(GLchar* vs, GLchar* fs);
~Shader();
GLuint getProgramId();

static const GLint ATTRIB_VERTICES_POS = 0;
static const GLint ATTRIB_COLOR_POS = 1;
static const GLint ATTRIB_NORMAL = 2;
private:
bool compile(GLuint &shaderId, GLenum type, GLchar* src);
GLuint verterxId_;
GLuint fragmentId_;
GLuint programId_;
bool compile(GLuint &shaderId, GLenum type, GLchar* src);
GLuint verterxId_;
GLuint fragmentId_;
GLuint programId_;
};

struct ShaderData {
Shader it;
GLuint MVP_Mat;
Shader it;
GLuint MVP_Mat;
};

class Simple3DObject {
public:

Simple3DObject();
~Simple3DObject();
Simple3DObject();
~Simple3DObject();

void init();
bool isInit();
void addPoints(std::vector<sl::float3> pts,sl::float4 base_clr);
void addBoundingBox(std::vector<sl::float3> bbox,sl::float4 base_clr);
void addLine(sl::float3 p1, sl::float3 p2, sl::float3 clr);
void pushToGPU();
void clear();
void init();
bool isInit();
void addPt(sl::float3 pt);
void addClr(sl::float4 clr);
void addNormal(sl::float3 normal);
void addPoints(std::vector<sl::float3> pts, sl::float4 base_clr);
void addBoundingBox(std::vector<sl::float3> bbox, sl::float4 base_clr);
void addPoint(sl::float3 pt, sl::float4 clr);
void addLine(sl::float3 p1, sl::float3 p2, sl::float3 clr);
void addCylinder(sl::float3 startPosition, sl::float3 endPosition, sl::float4 clr);
void addSphere(sl::float3 position, sl::float4 clr);
void pushToGPU();
void clear();

void setDrawingType(GLenum type);
void setDrawingType(GLenum type);

void draw();
void draw();

void translate(const sl::Translation& t);
void setPosition(const sl::Translation& p);
void translate(const sl::Translation& t);
void setPosition(const sl::Translation& p);

void setRT(const sl::Transform& mRT);
void setRT(const sl::Transform& mRT);

void rotate(const sl::Orientation& rot);
void rotate(const sl::Rotation& m);
void setRotation(const sl::Orientation& rot);
void setRotation(const sl::Rotation& m);
void rotate(const sl::Orientation& rot);
void rotate(const sl::Rotation& m);
void setRotation(const sl::Orientation& rot);
void setRotation(const sl::Rotation& m);

const sl::Translation& getPosition() const;
const sl::Translation& getPosition() const;

sl::Transform getModelMatrix() const;
sl::Transform getModelMatrix() const;

private:
std::vector<float> vertices_;
std::vector<float> colors_;
std::vector<unsigned int> indices_;

bool isStatic_;
bool is_init;

GLenum drawingType_;

GLuint vaoID_;
/*
Vertex buffer IDs:
- [0]: Vertices coordinates;
- [1]: Indices;
*/
GLuint vboID_[2];

ShaderData shader;

sl::Translation position_;
sl::Orientation rotation_;
std::vector<float> vertices_;
std::vector<float> colors_;
std::vector<unsigned int> indices_;
std::vector<float> normals_;

bool isStatic_;
bool is_init;
bool can_draw;

GLenum drawingType_;

GLuint vaoID_;
/*
Vertex buffer IDs:
- [0]: Vertices coordinates;
- [1]: Colors;
- [2]: Indices;
- [3]: Normals
*/
GLuint vboID_[4];

sl::Translation position_;
sl::Orientation rotation_;
};

class ImageHandler {
public:
ImageHandler();
~ImageHandler();

// Initialize Opengl and Cuda buffers
bool initialize(sl::Resolution res);
// Push a new Image + Z buffer and transform into a point cloud
void pushNewImage(sl::Mat &image);
// Draw the Image
void draw();
// Close (disable update)
void close();
ImageHandler();
~ImageHandler();

// Initialize Opengl and Cuda buffers
bool initialize(sl::Resolution res);
// Push a new Image + Z buffer and transform into a point cloud
void pushNewImage(sl::Mat &image);
// Draw the Image
void draw();
// Close (disable update)
void close();

private:
GLuint texID;
GLuint imageTex;
cudaGraphicsResource* cuda_gl_ressource;//cuda GL resource
ShaderData shaderImage;
GLuint quad_vb;
GLuint texID;
GLuint imageTex;
cudaGraphicsResource* cuda_gl_ressource;//cuda GL resource
Shader shader;
GLuint quad_vb;
};

struct ObjectClassName {
sl::float3 position;
std::string name_lineA;
std::string name_lineB;
sl::float4 color;
sl::float3 position;
std::string name_lineA;
std::string name_lineB;
sl::float4 color;
};

// This class manages input events, window and Opengl rendering pipeline
class GLViewer {
public:
GLViewer();
~GLViewer();
bool isAvailable();
void init(int argc, char **argv, sl::CameraParameters param);
void updateView(sl::Mat image, sl::Objects &obj);
void exit();
void setFloorPlaneEquation(sl::float4 eq);
GLViewer();
~GLViewer();
bool isAvailable();
void init(int argc, char **argv, sl::CameraParameters param);
void updateView(sl::Mat image, sl::Objects &obj);
void exit();
void setFloorPlaneEquation(sl::float4 eq);

private:
void render();
void update();
void draw();
void clearInputs();
void setRenderCameraProjection(sl::CameraParameters params,float znear, float zfar);

void printText();

// Glut functions callbacks
static void drawCallback();
static void reshapeCallback(int width, int height);
static void keyPressedCallback(unsigned char c, int x, int y);
static void keyReleasedCallback(unsigned char c, int x, int y);
static void idle();
void render();
void update();
void draw();
void clearInputs();
void setRenderCameraProjection(sl::CameraParameters params, float znear, float zfar);

bool available;
void printText();

enum MOUSE_BUTTON {
LEFT = 0,
MIDDLE = 1,
RIGHT = 2,
WHEEL_UP = 3,
WHEEL_DOWN = 4
};
// Glut functions callbacks
static void drawCallback();
static void reshapeCallback(int width, int height);
static void keyPressedCallback(unsigned char c, int x, int y);
static void keyReleasedCallback(unsigned char c, int x, int y);
static void idle();

enum KEY_STATE {
UP = 'u',
DOWN = 'd',
FREE = 'f'
};
bool available;
bool drawBbox = false;

enum MOUSE_BUTTON {
LEFT = 0,
MIDDLE = 1,
RIGHT = 2,
WHEEL_UP = 3,
WHEEL_DOWN = 4
};

KEY_STATE keyStates_[256];
enum KEY_STATE {
UP = 'u',
DOWN = 'd',
FREE = 'f'
};

std::mutex mtx;
KEY_STATE keyStates_[256];

sl::Transform projection_;
std::mutex mtx;

ImageHandler image_handler;
ShaderData shaderBasic;
ShaderData shaderSK;

ShaderData shader;
sl::float3 bckgrnd_clr;
sl::Transform projection_;
ImageHandler image_handler;
sl::float3 bckgrnd_clr;

std::vector<ObjectClassName> objectsName;
std::vector<ObjectClassName> objectsName;

Simple3DObject BBox_obj;
Simple3DObject skeletons_obj;
Simple3DObject BBox_obj;
Simple3DObject bones;
Simple3DObject joints;

bool g_showBox=true;
bool g_showLabel=true;
int f_count = 0;
bool floor_plane_set = false;
sl::float4 floor_plane_eq;
sl::Timestamp last_send_message_ts = 0;
bool message_ready_to_be_sent = true;
bool floor_plane_set = false;
sl::float4 floor_plane_eq;

};

Expand Down
Loading

0 comments on commit 3180232

Please sign in to comment.