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

Merge branch 'displays' into 'develop'

Displays

Closes #1, #4, and #3

See merge request !3
parents 4cf7080d e28d6b87
Loading
Loading
Loading
Loading
+13 −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();
@@ -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(x, y));
		}
	}
}
@@ -71,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));
@@ -80,7 +90,7 @@ void PointCloudManager::createPointCloudIfNotExist(glm::vec2 dim)
		pointCloud.addVertices(p);

		vector<ofFloatColor> c;
		c.assign(size, ofFloatColor(0, 0, 0, 0.9));
		c.assign(size, ofFloatColor(0, 0, 0, 1));
		pointCloud.addColors(c);
	}
}
+5 −2
Original line number Diff line number Diff line
@@ -19,12 +19,15 @@ private:

	ofVboMesh pointCloud;

	const int skip = 2;
	const int skip = 4;

	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);

+7 −9
Original line number Diff line number Diff line
@@ -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();