Commit cb5435b6 authored by Pierre Bürki's avatar Pierre Bürki
Browse files

Add additional draw methods in point cloud manager

parent 4cf7080d
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
#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));
		}
	}
}
+4 −1
Original line number Diff line number Diff line
@@ -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);