diff --git a/src/ofxRealSense2/Device.cpp b/src/ofxRealSense2/Device.cpp index 0c9a166..988c65e 100644 --- a/src/ofxRealSense2/Device.cpp +++ b/src/ofxRealSense2/Device.cpp @@ -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; diff --git a/src/ofxRealSense2/Device.h b/src/ofxRealSense2/Device.h index 0bbbe25..5227029 100644 --- a/src/ofxRealSense2/Device.h +++ b/src/ofxRealSense2/Device.h @@ -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;