Permalink
Browse files

bug fix: sadmb

  • Loading branch information...
sadmb committed Apr 27, 2012
1 parent c904875 commit 3401d29a54f36284349c024a7ad307b73f5c9ed2
View
@@ -17,6 +17,7 @@ void testApp::setup() {
ofSetLogLevel(OF_LOG_VERBOSE);
kinect.init(true, true, true, true, true, true, true, true); // enable all captures
+// kinect.init(true, true,false, true);
kinect.open(true);
// kinect.open(true); // when you want to use near mode
@@ -96,6 +97,10 @@ void testApp::draw() {
ofEnableAlphaBlending();
kinectPlayer.drawDepth(20, 340, 400, 300);
kinectPlayer.drawLabel(20, 340, 400, 300);
+
+
+ kinectPlayer.drawDepth(0, 0, 1024, 768);
+ kinectPlayer.drawLabel(0, 0, 1024, 768);
ofDisableAlphaBlending();
kinectPlayer.drawSkeleton(20, 20, 400, 300);
}
@@ -220,6 +220,10 @@ namespace kinect {
LONG Kinect::GetColorPixelCoordinatesFromDepthPixel(LONG lDepthPixel, USHORT usDepthValue)
{
LONG lDepthX, lDepthY;
+ if(lDepthPixel == 0){
+ return -1;
+ }
+
lDepthX = (LONG)(lDepthPixel % DepthStream().Width());
lDepthY = (LONG)(lDepthPixel / DepthStream().Width());
LONG plColorX = 0, plColorY = 0;
View
@@ -345,6 +345,7 @@ void ofxKinectNui::update(){
if(!kinect.IsInited() || !kinect.IsConnected() || !isOpened()){
return;
}
+
// wait and update all data
kinect.WaitAndUpdateAll();
@@ -392,7 +393,8 @@ void ofxKinectNui::update(){
}
}
}else{
- depthbit = depth(depth.Width() - x, y);
+ // update for Kinect for Windows
+ depthbit = depth(x, y) >> 3;
}
memcpy(distancePixels.getPixels() + (depth.Width() * y + x), &depthbit, sizeof(short));
if(bIsDepthNearValueWhite){
View
@@ -73,6 +73,7 @@ ofxKinectNuiPlayer::~ofxKinectNuiPlayer() {
bLoop = false;
bVideo = false;
bDepth = false;
+ bCalibratedVideo = false;
bLabel = false;
bSkeleton = false;
bAudio = false;
@@ -93,11 +94,12 @@ void ofxKinectNuiPlayer::setup( const string & file, bool useTexture /*= true*/)
unsigned char dst = 0;
fread(&dst, sizeof(char), 1, f);
- bVideo = (bool)((dst >> 4) & 0x7);
- bDepth = (bool)((dst >> 3) & 0x7);
- bLabel = (bool)((dst >> 2) & 0x7);
- bSkeleton = (bool)((dst >> 1) & 0x7);
- bAudio = (bool)((dst >> 0) & 0x7);
+ bVideo = (bool)((dst >> 5) & 0x1);
+ bDepth = (bool)((dst >> 4) & 0x1);
+ bCalibratedVideo = (bool)((dst >> 3) & 0x1);
+ bLabel = (bool)((dst >> 2) & 0x1);
+ bSkeleton = (bool)((dst >> 1) & 0x1);
+ bAudio = (bool)((dst >> 0) & 0x1);
NUI_IMAGE_RESOLUTION videoResolution;
@@ -163,19 +165,18 @@ void ofxKinectNuiPlayer::setup( const string & file, bool useTexture /*= true*/)
}
memset(depthPixels.getPixels(), 0, depthWidth * depthHeight);
}
+ if(bCalibratedVideo){
+ if(!calibratedVideoPixels.isAllocated()){
+ calibratedVideoPixels.allocate(depthWidth, depthHeight, OF_PIXELS_RGB);
+ }
+ memset(calibratedVideoPixels.getPixels(), 0, depthWidth * depthHeight * 3);
+ }
if(bLabel){
if(!labelPixels.isAllocated()){
labelPixels.allocate(depthWidth, depthHeight, OF_PIXELS_RGBA);
}
memset(labelPixels.getPixels(), 0, depthWidth * depthHeight * 4);
}
- if(bVideo && bDepth){
- if(!calibratedVideoPixels.isAllocated()){
- calibratedVideoPixels.allocate(depthWidth, depthHeight, OF_PIXELS_RGB);
- }
- memset(calibratedVideoPixels.getPixels(), 0, depthWidth * depthHeight * 3);
- }
-
if(!videoTexture.isAllocated() && bUsesTexture && bVideo){
videoTexture.allocate(width, height, GL_RGB);
}
@@ -279,7 +280,7 @@ void ofxKinectNuiPlayer::update(){
if(bDepth){
fread(distancePixels.getPixels(), sizeof(unsigned short), depthWidth * depthHeight, f);
}
- if(bVideo && bDepth){
+ if(bCalibratedVideo){
fread(calibratedVideoPixels.getPixels(), sizeof(unsigned char), depthWidth * depthHeight * 3, f);
}
if(bLabel){
View
@@ -139,6 +139,7 @@ class ofxKinectNuiPlayer: public ofxBase3DVideo{
bool bLoop; ///< is loop?
bool bVideo; ///< is video recorded?
bool bDepth; ///< is depth recorded?
+ bool bCalibratedVideo; ///< is depth recorded?
bool bLabel; ///< is label recorded?
bool bSkeleton; ///< is skeleton recorded?
bool bAudio; ///< is audio recorded?
@@ -66,7 +66,7 @@ void ofxKinectNuiRecorder::setup(ofxKinectNui& kinect, const string & filename){
skeletons = new float[kinect::nui::SkeletonFrame::SKELETON_COUNT * kinect::nui::SkeletonData::POSITION_COUNT * 3];
- unsigned char bit = ((unsigned int)mKinect->grabsVideo() << 4) | ((unsigned int)mKinect->grabsDepth() << 3) | ((unsigned int)mKinect->grabsLabel() << 2) | ((unsigned int)mKinect->grabsSkeleton() << 1) | ((unsigned int)mKinect->grabsAudio());
+ unsigned char bit = ((unsigned int)mKinect->grabsVideo() << 5) | ((unsigned int)mKinect->grabsDepth() << 4) | ((unsigned int)mKinect->grabsCalibratedVideo() << 3) | ((unsigned int)mKinect->grabsLabel() << 2) | ((unsigned int)mKinect->grabsSkeleton() << 1) | ((unsigned int)mKinect->grabsAudio());
fwrite(&bit, sizeof(char), 1, f);
int bit2 = (int)mKinect->getVideoResolution();
fwrite(&bit2, sizeof(int), 1, f);

0 comments on commit 3401d29

Please sign in to comment.