Exemple #1
0
void DepthExporter::exportCloud(string filename, int width, int height, const bool* mask, const float* depth,  const unsigned char* color) {
	string extension = getExtension(filename);
	if (extension == "obj") {
		exportObjCloud(filename, width, height, mask, depth, color);
	} else if (extension == "ply") {
		exportPlyCloud(filename, width, height, mask, depth, color);
	}
}
void testApp::update() {
	kinect.update();
	if(kinect.isFrameNew()) {
		int width = kinect.getWidth();
		int height = kinect.getHeight();
		float* distancePixels = kinect.getDistancePixels(); // distance in centimeters
		cloud.clear();
		cloud.setMode(OF_PRIMITIVE_POINTS);
		for(int y = 0; y < height; y++) {
			for(int x = 0; x < width; x++) {
				int i = y * width + x;
				float z = distancePixels[i];
				if(z != 0) { // ignore empty depth pixels
					cloud.addVertex(ConvertProjectiveToRealWorld(x, y, z));
				}
			}
		}
	}
	if(exportPly) {
		exportPlyCloud("cloud.ply", cloud);
		exportPly = false;
	}
}