From cb5435b6a8f9bd7a8f5a39dee72a4742516424bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Fri, 29 May 2020 13:36:51 +0200 Subject: [PATCH 1/3] Add additional draw methods in point cloud manager --- src/PointCloudManager.cpp | 14 +++++++++++--- src/PointCloudManager.h | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/PointCloudManager.cpp b/src/PointCloudManager.cpp index 4127df3..4f6a48b 100644 --- a/src/PointCloudManager.cpp +++ b/src/PointCloudManager.cpp @@ -1,6 +1,6 @@ #include "PointCloudManager.h" -void PointCloudManager::draw() +void PointCloudManager::drawPointCloud() { //ofLog(OF_LOG_NOTICE) << "Drawing cloud point (" << pointCloud.getVertices().size() << ") points)"; ofPushMatrix(); @@ -17,6 +17,14 @@ void PointCloudManager::draw() ofPopMatrix(); } +void PointCloudManager::drawRGB(const ofRectangle& viewRect) { + rgbTex.draw(viewRect); +} + +void PointCloudManager::drawDepth(const ofRectangle& viewRect) { + depthTex.draw(viewRect); +} + void PointCloudManager::updateRGB(RGBFrame::Ptr data) { rgbFrameSize.x = data->getCols(); @@ -26,7 +34,7 @@ void PointCloudManager::updateRGB(RGBFrame::Ptr data) uint8_t* colorDataPtr = (uint8_t*)rgbData; ofPixels rgbPix; // Assuming the data comes from the live feed (hence BGR) - rgbPix.setFromPixels(colorDataPtr, rgbFrameSize.x, rgbFrameSize.y, OF_PIXELS_BGR); + rgbPix.setFromPixels(colorDataPtr, rgbFrameSize.x, rgbFrameSize.y, OF_PIXELS_RGB); rgbTex.loadData(rgbPix); createPointCloudIfNotExist(depthFrameSize); @@ -36,7 +44,7 @@ void PointCloudManager::updateRGB(RGBFrame::Ptr data) const int index = y * depthFrameSize.x + x; const int skippedIndex = (y / skip) * (depthFrameSize.x / skip) + (x / skip); - pointCloud.setColor(skippedIndex, 10 * rgbPix.getColor(index)); + pointCloud.setColor(skippedIndex, rgbPix.getColor(index)); } } } diff --git a/src/PointCloudManager.h b/src/PointCloudManager.h index e441e06..f154c5b 100644 --- a/src/PointCloudManager.h +++ b/src/PointCloudManager.h @@ -24,7 +24,10 @@ private: void createPointCloudIfNotExist(glm::vec2 dim); public: - void draw(); + void drawPointCloud(); + void drawRGB(const ofRectangle& viewRect); + void drawDepth(const ofRectangle& viewRect); + void updateRGB(RGBFrame::Ptr data); void updateDepth(DepthFrame::Ptr data); -- GitLab From 1a34752ff6aeeba9f84a5d90471c7445d0748f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Fri, 29 May 2020 13:37:16 +0200 Subject: [PATCH 2/3] Add previews and fullscreen streams for RGB and Depth --- src/ofApp.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ofApp.cpp b/src/ofApp.cpp index 2fe01ea..c0b72e4 100644 --- a/src/ofApp.cpp +++ b/src/ofApp.cpp @@ -561,9 +561,9 @@ void ofApp::draw(){ //ofLogNotice() << "draw next frame"; if(bShowVisuals){ //Draw viewport previews - // TODO: basic rgb & depth streams - - + pointCloudManager.drawRGB(viewGrid[0]); + pointCloudManager.drawDepth(viewGrid[1]); + // TODO: These might all be useless //skeletonFinder.grayImage.draw(viewGrid[2]); //skeletonFinder.contourFinder.draw(viewGrid[3]); //skeletonFinder.maskFbo.draw(viewGrid[4]); @@ -571,13 +571,11 @@ void ofApp::draw(){ switch (iMainCamera) { case 0: - // TODO - //realSense->drawDepthStream(viewMain); + pointCloudManager.drawRGB(viewMain); drawCalibrationPoints(); break; case 1: - // TODO - //realSense->drawInfraLeftStream(viewMain); + pointCloudManager.drawDepth(viewMain); drawCalibrationPoints(); break; case 2: @@ -668,7 +666,7 @@ void ofApp::drawPreview() { ofMultMatrix(deviceTransform); if (bPreviewPointCloud) { // TODO: what does this do - pointCloudManager.draw(); + pointCloudManager.drawPointCloud(); } ofFill(); ofSetColor(255, 0, 0); @@ -732,7 +730,7 @@ void ofApp::drawCapturePointCloud(bool _mask) { ofPushMatrix(); ofMultMatrix(deviceTransform); //realSense->draw(); - pointCloudManager.draw(); + pointCloudManager.drawPointCloud(); ofPopMatrix(); shader.end(); -- GitLab From e28d6b87a4588ee7118828e0502cbc0413f0313a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Fri, 29 May 2020 13:49:45 +0200 Subject: [PATCH 3/3] Fix missing color in point cloud --- src/PointCloudManager.cpp | 8 +++++--- src/PointCloudManager.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/PointCloudManager.cpp b/src/PointCloudManager.cpp index 4f6a48b..24ca684 100644 --- a/src/PointCloudManager.cpp +++ b/src/PointCloudManager.cpp @@ -34,7 +34,7 @@ void PointCloudManager::updateRGB(RGBFrame::Ptr data) uint8_t* colorDataPtr = (uint8_t*)rgbData; ofPixels rgbPix; // Assuming the data comes from the live feed (hence BGR) - rgbPix.setFromPixels(colorDataPtr, rgbFrameSize.x, rgbFrameSize.y, OF_PIXELS_RGB); + rgbPix.setFromPixels(colorDataPtr, rgbFrameSize.x, rgbFrameSize.y, OF_PIXELS_BGR); rgbTex.loadData(rgbPix); createPointCloudIfNotExist(depthFrameSize); @@ -44,7 +44,7 @@ void PointCloudManager::updateRGB(RGBFrame::Ptr data) const int index = y * depthFrameSize.x + x; const int skippedIndex = (y / skip) * (depthFrameSize.x / skip) + (x / skip); - pointCloud.setColor(skippedIndex, rgbPix.getColor(index)); + pointCloud.setColor(skippedIndex, rgbPix.getColor(x, y)); } } } @@ -79,6 +79,8 @@ void PointCloudManager::createPointCloudIfNotExist(glm::vec2 dim) ofLog(OF_LOG_NOTICE) << "YOU ONLY SEE THIS ONCE"; pointCloud.setMode(OF_PRIMITIVE_POINTS); + pointCloud.enableColors(); + // Allocate pointCloud.clear(); int size = ceil(((float)dim.x / skip) * ((float)dim.y / skip)); @@ -88,7 +90,7 @@ void PointCloudManager::createPointCloudIfNotExist(glm::vec2 dim) pointCloud.addVertices(p); vector c; - c.assign(size, ofFloatColor(0, 0, 0, 0.9)); + c.assign(size, ofFloatColor(0, 0, 0, 1)); pointCloud.addColors(c); } } diff --git a/src/PointCloudManager.h b/src/PointCloudManager.h index f154c5b..b056723 100644 --- a/src/PointCloudManager.h +++ b/src/PointCloudManager.h @@ -19,7 +19,7 @@ private: ofVboMesh pointCloud; - const int skip = 2; + const int skip = 4; void createPointCloudIfNotExist(glm::vec2 dim); -- GitLab