Skip to content

Commit

Permalink
Add getters for world position and texture coordinate.
Browse files Browse the repository at this point in the history
  • Loading branch information
prisonerjohn committed Oct 7, 2019
1 parent b591929 commit 18d97df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/ofxRealSense2/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,28 @@ namespace ofxRealSense2
return 0.0f;
}

ofDefaultVertexType Device::getWorldPosition(int x, int y) const
{
int idx = y * this->getDepthTex().getWidth() + x;
if (idx < this->points.size())
{
auto vertices = this->points.get_vertices();
return ofDefaultVertexType(vertices[idx].x, vertices[idx].y, vertices[idx].z);
}
return ofDefaultVertexType();
}

ofDefaultTexCoordType Device::getTexCoord(int x, int y) const
{
int idx = y * this->getDepthTex().getWidth() + x;
if (idx < this->points.size())
{
auto texCoords = this->points.get_texture_coordinates();
return ofDefaultTexCoordType(texCoords[idx].u, texCoords[idx].v);
}
return ofDefaultTexCoordType();
}

const rs2::device& Device::getNativeDevice() const
{
return this->device;
Expand Down
2 changes: 2 additions & 0 deletions src/ofxRealSense2/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ namespace ofxRealSense2
const size_t getNumPoints() const;

float getDistance(int x, int y) const;
ofDefaultVertexType getWorldPosition(int x, int y) const;
ofDefaultTexCoordType getTexCoord(int x, int y) const;

const rs2::device& getNativeDevice() const;
const rs2::pipeline& getNativePipeline() const;
Expand Down

0 comments on commit 18d97df

Please sign in to comment.