You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.
So, GL_RED didn't work, but I got GL_LUMINANCE to work by massaging the data better. Closing the issue.
Here is the combo that ended up working and displaying (partial code from the KinectV2 Helper class I'm writing):
ofTexture& getDepthFrameAsTexture(DepthFrame^ depthFrame)
{
if ( !depthFrameArray.isAllocated() ) {
_depthFrameArray = ref new Platform::Array(depthFrame->FrameDescription->LengthInPixels);
}
if ( _depthFramePixels.isAllocated() ) {
_depthFramePixels.allocate(
depthFrame->FrameDescription->Width,
depthFrame->FrameDescription->Height,
OF_IMAGE_GRAYSCALE);
}
// STORE THE DEPTH FRAME INTO AN ARRAY
depthFrame->CopyFrameDataToArray(_depthFrameArray);
// IF YOU WANT TO CONVERT THE ARRAY INTO AN ofPixels, DO THIS:
for (int i = 0; i < _depthFrameArray->Length; i++)
{
_depthFramePixels.getPixels()[i] = depthValueToGreyscaleTable[
ofClamp(_depthFrameArray[i],
0,
depthValueToGreyscaleTable.size() - 1)];
}
// AND TO CONVERT THE ofPixels INTO A TEXTURE, DO THIS:
if (!_depthFrameTexture.isAllocated())
{
_depthFrameTexture.allocate(
depthFrame->FrameDescription->Width,
depthFrame->FrameDescription->Height,
GL_LUMINANCE
);
}
_depthFrameTexture.loadData(tempPixels);
return _depthFrameTexture;
}
// HERE IS THE LOOKUP TABLE THAT CONVERTS THE UINT16 DEPTH VALUE IN MM TO A MAPPED CHAR FOR GREYSCALE
void ofxKinectV2RT::updateDepthValueToGreyscaleTable()
{
unsigned char nearColor = 255;
unsigned char farColor = 0;
unsigned int maxDepthLevels = 5001;
depthValueToGreyscaleTable.resize(maxDepthLevels);
depthValueToGreyscaleTable[0] = 0;
for (unsigned int i = 1; i < maxDepthLevels; i++)
{
depthValueToGreyscaleTable[i] = ofMap(i, 500, 4000, nearColor, farColor, true);
}
}
For kinect (specifically) but in general:
If you have a LUMINANCE array ( say, from the depth camera ) that comes in as 16bits per pixel, you can store that in an ofShortPixels.
and later, load this into a texture like this:
depthTex.loadData(depthPixels.getPixels(), depthFrameDescription.width, depthFrameDescription.height, GL_LUMINANCE);
However in RT, Textures defined as GL_LUMINANCE fail to display properly.
Is this maybe an Angle thing? Or can we write up a workaround for RT?
Trying to get an ofxKinectV2RT helper class going for this weekend hackfest, thanks...
The text was updated successfully, but these errors were encountered: