예제 #1
0
void ImageViewer::update()
{
	mCinderDS->update();
	mTexRgb->update(*mCinderDS->getRgbFrame());
	auto depthChannel = mCinderDS->getDepthFrame();
	auto depthSurface = Surface8u::create(mDepthDims.x, mDepthDims.y, SurfaceChannelOrder::RGB);
	auto iter = depthSurface->getIter();

	while (iter.line())
	{
		while (iter.pixel())
		{
			iter.r() = 0;
			iter.g() = 0;
			iter.b() = 0;

			// Not optimal mapping, TODO: color from histogram
			float depthValue = (float)*depthChannel->getData(iter.x(), iter.y()); 
			if (depthValue > 100 && depthValue < 1000)
			{
				int colorValue = (int)lmap<float>(depthValue, 100, 1000, 255, 0);
				iter.r() = colorValue;
				iter.g() = colorValue;
			}
		}
	}

	mTexDepth->update(*depthSurface);
}
void PointCloudApp::update()
{
	
	mCinderRS->update();
	mPoints.clear();
	Channel16u cChanDepth = mCinderRS->getDepthFrame();

	mTexRgb->update(mCinderRS->getRgbFrame());
	for (int dy = 0; dy < mDepthDims.y; ++dy)
	{
		for (int dx = 0; dx < mDepthDims.x; ++dx)
		{
			float cDepth = (float)*cChanDepth.getData(dx, dy);
			if (cDepth > 100 && cDepth < 1000)
			{
				vec3 cPos = mCinderRS->getDepthSpacePoint(vec3(dx, dy, cDepth));
				vec2 cUV = mCinderRS->getColorCoordsFromDepthImage(static_cast<float>(dx),
																	static_cast<float>(dy),
																	cDepth);
				mPoints.push_back(CloudPoint(cPos, cUV));
			}
		}
	}

	mBufferObj->bufferData(mPoints.size()*sizeof(CloudPoint), mPoints.data(), GL_DYNAMIC_DRAW);
	mMeshObj = gl::VboMesh::create(mPoints.size(), GL_POINTS, { { mAttribObj, mBufferObj } });
	mDrawObj->replaceVboMesh(mMeshObj);
}
예제 #3
0
void PTApp::update()
{
	if (frameDone)
	{
		imgTex->update(frameBuffer, GL_RGB, GL_UNSIGNED_BYTE, 0, frameBufferWidth, frameBufferHeight);
		frameDone = false;
        renderFrame = true;
		console() << "Render time: " << renderTime << "s\n";
	}
}