Skip to content

Commit

Permalink
Nuitrack v0.38.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuitrack-Bot committed Feb 2, 2025
1 parent b9937f2 commit 8754904
Show file tree
Hide file tree
Showing 114 changed files with 389 additions and 541 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Release v0.38.1

**Release Date**: 3 Feb 2025
**Nuitrack Runtime version**: 0.38.1
**Nuitrack SDK version**: 1.14.1

* Femto Mega - added initial support
* Femto Bolt and other Orbbec sensors - Depth/RGB syncronization issue handling
* Nuitrack.exe - proper support for portrait mode

# Release v0.38.0

**Release Date**: 8 Jan 2025
Expand Down
14 changes: 14 additions & 0 deletions Examples/cmake/DetectPlatform.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(PLATFORM_DIR linux_arm)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch")
set(PLATFORM_DIR linux_arm64)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
set(PLATFORM_DIR linux64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(PLATFORM_DIR "win32")
set(FREEGLUT_ARCH "")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLATFORM_DIR "win64")
set(FREEGLUT_ARCH "x64")
endif()
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace tdv::nuitrack;

NuitrackGLSample::NuitrackGLSample() :
_textureID(0),
_textureBuffer(0),
_textureBuffer(nullptr),
_width(640),
_height(480),
_viewMode(DEPTH_SEGMENT_MODE),
Expand All @@ -27,7 +27,7 @@ NuitrackGLSample::~NuitrackGLSample()
{
Nuitrack::release();
}
catch (const Exception& e)
catch (const Exception&)
{
// Do nothing
}
Expand Down Expand Up @@ -69,8 +69,8 @@ void NuitrackGLSample::init(const std::string& config)
_userTracker = UserTracker::create();
// Binds to user tracker events
_userTracker->connectOnUpdate(std::bind(&NuitrackGLSample::onUserUpdateCallback, this, std::placeholders::_1));
_userTracker->connectOnNewUser(std::bind(&NuitrackGLSample::onNewUserCallback, this, std::placeholders::_1));
_userTracker->connectOnLostUser(std::bind(&NuitrackGLSample::onLostUserCallback, this, std::placeholders::_1));
_userTracker->connectOnNewUser(&NuitrackGLSample::onNewUserCallback);
_userTracker->connectOnLostUser(&NuitrackGLSample::onLostUserCallback);

_skeletonTracker = SkeletonTracker::create();
// Bind to event update skeleton tracker
Expand All @@ -81,7 +81,7 @@ void NuitrackGLSample::init(const std::string& config)
_handTracker->connectOnUpdate(std::bind(&NuitrackGLSample::onHandUpdate, this, std::placeholders::_1));

_gestureRecognizer = GestureRecognizer::create();
_gestureRecognizer->connectOnNewGestures(std::bind(&NuitrackGLSample::onNewGesture, this, std::placeholders::_1));
_gestureRecognizer->connectOnNewGestures(&NuitrackGLSample::onNewGesture);

_onIssuesUpdateHandler = Nuitrack::connectOnIssuesUpdate(std::bind(&NuitrackGLSample::onIssuesUpdate,
this, std::placeholders::_1));
Expand Down Expand Up @@ -151,7 +151,7 @@ void NuitrackGLSample::release()
if (_textureBuffer)
{
delete[] _textureBuffer;
_textureBuffer = 0;
_textureBuffer = nullptr;
}
}

Expand All @@ -164,8 +164,8 @@ void NuitrackGLSample::onNewDepthFrame(DepthFrame::Ptr frame)
uint8_t* texturePtr = _textureBuffer;
const uint16_t* depthPtr = frame->getData();

float wStep = (float)_width / frame->getCols();
float hStep = (float)_height / frame->getRows();
float wStep = float(_width) / frame->getCols();
float hStep = float(_height) / frame->getRows();

float nextVerticalBorder = hStep;

Expand All @@ -189,10 +189,8 @@ void NuitrackGLSample::onNewDepthFrame(DepthFrame::Ptr frame)
nextHorizontalBorder += wStep;
depthValue = *(depthPtr + col) >> 5;
}

texturePtr[0] = depthValue;
texturePtr[1] = depthValue;
texturePtr[2] = depthValue;

texturePtr[0] = texturePtr[1] = texturePtr[2] = uint8_t(depthValue);
}
}
#if defined(ANDROID) || defined(__ANDROID__)
Expand Down Expand Up @@ -264,26 +262,20 @@ void NuitrackGLSample::onUserUpdateCallback(UserFrame::Ptr frame)

std::vector<uint8_t> labelIssueState(MAX_LABELS, 0);
for (uint16_t label = 0; label < MAX_LABELS; ++label)
{
labelIssueState[label] = 0;
if (_issuesData)
{
FrameBorderIssue::Ptr frameBorderIssue = _issuesData->getUserIssue<FrameBorderIssue>(label);
labelIssueState[label] = (frameBorderIssue != 0);
}
}

labelIssueState[label] = _issuesData->getUserIssue<FrameBorderIssue>(label) != nullptr;

uint8_t* texturePtr = _textureBuffer;
const uint16_t* labelPtr = frame->getData();

float wStep = (float)_width / frame->getCols();
float hStep = (float)_height / frame->getRows();
float wStep = float(_width) / frame->getCols();
float hStep = float(_height) / frame->getRows();

float nextVerticalBorder = hStep;

for (size_t i = 0; i < _height; ++i)
{
if (i == (int)nextVerticalBorder)
if (i == int(nextVerticalBorder))
{
nextVerticalBorder += hStep;
labelPtr += frame->getCols();
Expand All @@ -295,7 +287,7 @@ void NuitrackGLSample::onUserUpdateCallback(UserFrame::Ptr frame)

for (size_t j = 0; j < _width; ++j, texturePtr += 3)
{
if (j == (int)nextHorizontalBorder)
if (j == int(nextHorizontalBorder))
{
++col;
nextHorizontalBorder += wStep;
Expand All @@ -305,11 +297,11 @@ void NuitrackGLSample::onUserUpdateCallback(UserFrame::Ptr frame)
if (!label)
continue;

for (int i = 0; i < 3; ++i)
for (int k = 0; k < 3; ++k)
{
texturePtr[i] = colors[label & 7][i];
texturePtr[k] = colors[label & 7][k];
if (labelIssueState[label])
texturePtr[i] /= 2;
texturePtr[k] /= 2;
}
}
}
Expand All @@ -328,19 +320,17 @@ void NuitrackGLSample::onNewUserCallback(int id)
}

// Prepare visualization of skeletons, received from Nuitrack
void NuitrackGLSample::onSkeletonUpdate(SkeletonData::Ptr userSkeletons)
void NuitrackGLSample::onSkeletonUpdate(const SkeletonData::Ptr &userSkeletons)
{
_lines.clear();

auto skeletons = userSkeletons->getSkeletons();
for (auto skeleton: skeletons)
{
drawSkeleton(skeleton.joints);
}
}

// Prepare visualization of tracked hands
void NuitrackGLSample::onHandUpdate(HandTrackerData::Ptr handData)
void NuitrackGLSample::onHandUpdate(const HandTrackerData::Ptr &handData)
{
_leftHandPointers.clear();
_rightHandPointers.clear();
Expand Down Expand Up @@ -372,16 +362,13 @@ void NuitrackGLSample::onHandUpdate(HandTrackerData::Ptr handData)
}

// Display information about gestures in the console
void NuitrackGLSample::onNewGesture(GestureData::Ptr gestureData)
void NuitrackGLSample::onNewGesture(const GestureData::Ptr &gestureData)
{
_userGestures = gestureData->getGestures();
for (int i = 0; i < _userGestures.size(); ++i)
{
printf("Recognized %d from %d\n", _userGestures[i].type, _userGestures[i].userId);
}
for (auto gesture : gestureData->getGestures())
printf("Recognized %d from %d\n", gesture.type, gesture.userId);
}

void NuitrackGLSample::onIssuesUpdate(IssuesData::Ptr issuesData)
void NuitrackGLSample::onIssuesUpdate(const IssuesData::Ptr &issuesData)
{
_issuesData = issuesData;
}
Expand Down Expand Up @@ -451,15 +438,15 @@ void NuitrackGLSample::renderTexture()

int NuitrackGLSample::power2(int n)
{
unsigned int m = 2;
int m = 2;
while (m < n)
m <<= 1;

return m;
}

// Visualize bones, joints and hand positions
void NuitrackGLSample::renderLines()
void NuitrackGLSample::renderLines() const
{
if (_lines.empty())
return;
Expand All @@ -471,15 +458,15 @@ void NuitrackGLSample::renderLines()
glLineWidth(6);

glVertexPointer(2, GL_FLOAT, 0, _lines.data());
glDrawArrays(GL_LINES, 0, _lines.size() / 2);
glDrawArrays(GL_LINES, 0, GLsizei(_lines.size()) / 2);

glLineWidth(1);

glEnable(GL_POINT_SMOOTH);
glPointSize(16);

glVertexPointer(2, GL_FLOAT, 0, _lines.data());
glDrawArrays(GL_POINTS, 0, _lines.size() / 2);
glDrawArrays(GL_POINTS, 0, GLsizei(_lines.size()) / 2);

if (!_leftHandPointers.empty())
{
Expand Down Expand Up @@ -522,37 +509,36 @@ void NuitrackGLSample::initTexture(int width, int height)

width = power2(width);
height = power2(height);

if (_textureBuffer != 0)
delete[] _textureBuffer;

delete[] _textureBuffer; // just in case - deleting nullptr doesn't have an effect

_textureBuffer = new uint8_t[width * height * 3];
memset(_textureBuffer, 0, sizeof(uint8_t) * width * height * 3);

glBindTexture(GL_TEXTURE_2D, _textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

// Set texture coordinates [0, 1] and vertexes position
{
_textureCoords[0] = (float) _width / width;
_textureCoords[1] = (float) _height / height;
_textureCoords[2] = (float) _width / width;
_textureCoords[0] = float(_width) / width;
_textureCoords[1] = float(_height) / height;
_textureCoords[2] = float(_width) / width;
_textureCoords[3] = 0.0;
_textureCoords[4] = 0.0;
_textureCoords[5] = 0.0;
_textureCoords[6] = 0.0;
_textureCoords[7] = (float) _height / height;
_textureCoords[7] = float(_height) / height;

_vertexes[0] = _width;
_vertexes[1] = _height;
_vertexes[2] = _width;
_vertexes[0] = GLfloat(_width);
_vertexes[1] = GLfloat(_height);
_vertexes[2] = GLfloat(_width);
_vertexes[3] = 0.0;
_vertexes[4] = 0.0;
_vertexes[5] = 0.0;
_vertexes[6] = 0.0;
_vertexes[7] = _height;
_vertexes[7] = GLfloat(_height);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef NUITRACKGLSAMPLE_H_
#define NUITRACKGLSAMPLE_H_
#pragma once

#include <nuitrack/Nuitrack.h>

Expand Down Expand Up @@ -45,7 +44,7 @@ class NuitrackGLSample final

void nextViewMode()
{
_viewMode = (ViewMode)(((uint32_t)_viewMode + 1) % _modesNumber);
_viewMode = ViewMode((uint32_t(_viewMode) + 1) % _modesNumber);
}

tdv::nuitrack::OutputMode getOutputMode() const
Expand Down Expand Up @@ -88,23 +87,21 @@ class NuitrackGLSample final
void onNewDepthFrame(tdv::nuitrack::DepthFrame::Ptr frame);
void onNewRGBFrame(tdv::nuitrack::RGBFrame::Ptr frame);
void onUserUpdateCallback(tdv::nuitrack::UserFrame::Ptr frame);
void onLostUserCallback(int id);
void onNewUserCallback(int id);
void onSkeletonUpdate(tdv::nuitrack::SkeletonData::Ptr userSkeletons);
void onHandUpdate(tdv::nuitrack::HandTrackerData::Ptr handData);
void onNewGesture(tdv::nuitrack::GestureData::Ptr gestureData);
void onIssuesUpdate(tdv::nuitrack::IssuesData::Ptr issuesData);
static void onNewUserCallback(int id);
static void onLostUserCallback(int id);
void onSkeletonUpdate(const tdv::nuitrack::SkeletonData::Ptr &userSkeletons);
void onHandUpdate(const tdv::nuitrack::HandTrackerData::Ptr &handData);
void onIssuesUpdate(const tdv::nuitrack::IssuesData::Ptr &issuesData);
static void onNewGesture(const tdv::nuitrack::GestureData::Ptr &gestureData);

/**
* Draw methods
*/
void drawSkeleton(const std::vector<tdv::nuitrack::Joint>& joints);
void drawBone(const tdv::nuitrack::Joint& j1, const tdv::nuitrack::Joint& j2);
void renderTexture();
void renderLines();
int power2(int n);
void renderLines() const;

static int power2(int n);
void initTexture(int width, int height);
};

#endif /* NUITRACKGLSAMPLE_H_ */
39 changes: 7 additions & 32 deletions Examples/nuitrack_console_sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,15 @@ cmake_minimum_required(VERSION 2.8)
set(PROJECT_NAME nuitrack_console_sample)
project(${PROJECT_NAME})

add_definitions(-std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0)
set(CMAKE_CXX_STANDARD 11)

set(NUITRACK_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../Nuitrack/include ${CMAKE_CURRENT_LIST_DIR}/../../Nuitrack/include/middleware)

if(UNIX)
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(PLATFORM_DIR linux_arm)
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch")
set(PLATFORM_DIR linux_arm64)
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
set(PLATFORM_DIR linux64)
ENDIF()
elseif(WIN32)
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(PLATFORM_DIR win32)
ELSEIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLATFORM_DIR win64)
ENDIF()
endif()

set(NUITRACK_LIBRARY_PATH ${CMAKE_CURRENT_LIST_DIR}/../../Nuitrack/lib/${PLATFORM_DIR})
include(../cmake/DetectPlatform.cmake)

include_directories(
.
${NUITRACK_INCLUDE_PATH}
)

link_directories(${NUITRACK_LIBRARY_PATH})

set(SOURCES
src/main.cpp)

add_executable(${PROJECT_NAME} ${SOURCES})
${CMAKE_CURRENT_LIST_DIR}/../../Nuitrack/include
${CMAKE_CURRENT_LIST_DIR}/../../Nuitrack/include/middleware)

set(LIBS nuitrack)
link_directories(${CMAKE_CURRENT_LIST_DIR}/../../Nuitrack/lib/${PLATFORM_DIR})
add_executable(${PROJECT_NAME} src/main.cpp)

target_link_libraries(${PROJECT_NAME} ${LIBS})
target_link_libraries(${PROJECT_NAME} nuitrack)
Loading

0 comments on commit 8754904

Please sign in to comment.