Skip to content

Commit

Permalink
Merge pull request gameoverhack#8 from obviousjim/develop
Browse files Browse the repository at this point in the history
IR Pixel copy was messed up
  • Loading branch information
gameoverhack committed Jan 6, 2012
2 parents 51951ec + 8023f91 commit 2a4f8a2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/ofxHardwareDriver.cpp
Expand Up @@ -10,7 +10,7 @@ ofxHardwareDriver::~ofxHardwareDriver() {

void ofxHardwareDriver::setup(int index)
{
libusb_context *ctx;
//libusb_context *ctx;
libusb_init(&ctx);
libusb_device **devs; //pointer to pointer of device, used to retrieve a list of devices
ssize_t cnt = libusb_get_device_list (ctx, &devs); //get the list of devices
Expand Down Expand Up @@ -135,5 +135,5 @@ void ofxHardwareDriver::shutDown() {
// strange behaviour if the kinect is tilted in between
// application starts eg., the angle continues to be set
// even when app not running...which is odd...
libusb_exit(0);
libusb_exit(ctx);
}
2 changes: 2 additions & 0 deletions src/ofxHardwareDriver.h
Expand Up @@ -67,6 +67,8 @@ class ofxHardwareDriver {
int tilt_angle;

void shutDown();

libusb_context *ctx;

private:

Expand Down
11 changes: 4 additions & 7 deletions src/ofxIRGenerator.cpp
Expand Up @@ -12,15 +12,12 @@ void ofxIRGenerator::generateTexture() {

xn::IRMetaData ird;
ir_generator.GetMetaData(ird);
const XnUInt8* pImage = (XnUInt8*)ird.Data();
const XnIRPixel* pImage = ird.Data();

int j = 0;

for (int i = 0; i < ird.XRes() * ird.YRes()*2; i+=2, j++) { // Don't ask me why ;-)
ir_pixels[j] = pImage[i];
for (int i = 0; i < ird.XRes() * ird.YRes(); i++) {
ir_pixels[i] = pImage[i]/4;
}

//memcpy(ir_pixels, pImage, sizeof(unsigned char) * ird.XRes() * ird.YRes());

ir_texture.loadData(ir_pixels, ird.XRes(), ird.YRes(), GL_LUMINANCE);

}
Expand Down
4 changes: 3 additions & 1 deletion src/ofxTrackedUser.h
Expand Up @@ -75,7 +75,9 @@ class ofxTrackedUser {
ofxLimb hip;
XnUserID id;


bool skeletonTracking, skeletonCalibrating, skeletonCalibrated;
XnPoint3D center;

private:

ofxTrackedUser(ofxOpenNIContext* pContext);
Expand Down
16 changes: 11 additions & 5 deletions src/ofxUserGenerator.cpp
Expand Up @@ -134,15 +134,17 @@ bool ofxUserGenerator::setup( ofxOpenNIContext* pContext) {
useMaskPixels = false;

// setup mask pixels array TODO: clean this up on closing or dtor
for (int user = 0; user < MAX_NUMBER_USERS; user++) {
//including 0 as all users
for (int user = 0; user <= MAX_NUMBER_USERS; user++) {
maskPixels[user] = new unsigned char[width * height];
}

// set update cloud points default to false
useCloudPoints = false;

// setup cloud points array TODO: clean this up on closing or dtor
for (int user = 0; user < MAX_NUMBER_USERS; user++) {
//including 0 as all users
for (int user = 0; user <= MAX_NUMBER_USERS; user++) {
cloudPoints[user] = new ofPoint[width * height];
cloudColors[user] = new ofColor[width * height];
}
Expand Down Expand Up @@ -282,7 +284,11 @@ void ofxUserGenerator::update() {
for(int i = 0; i < found_users; ++i) {
if(user_generator.GetSkeletonCap().IsTracking(users[i])) {
tracked_users[i]->id = users[i];
tracked_users[i]->updateBonePositions();
user_generator.GetCoM(users[i], tracked_users[i]->center);
tracked_users[i]->skeletonTracking = user_generator.GetSkeletonCap().IsTracking(users[i]);
tracked_users[i]->skeletonCalibrating = user_generator.GetSkeletonCap().IsCalibrating(users[i]);
tracked_users[i]->skeletonCalibrated = user_generator.GetSkeletonCap().IsCalibrated(users[i]);
if(tracked_users[i]->skeletonTracking) tracked_users[i]->updateBonePositions();
}
}

Expand Down Expand Up @@ -409,13 +415,13 @@ void ofxUserGenerator::updateCloudPoints() {

ofPoint ofxUserGenerator::getWorldCoordinateAt(int x, int y, int userID) {

return cloudPoints[userID][y * height + x];
return cloudPoints[userID][y * width + x];

}

ofColor ofxUserGenerator::getWorldColorAt(int x, int y, int userID) {

return cloudColors[userID][y * height + x];
return cloudColors[userID][y * width + x];

}

Expand Down
6 changes: 3 additions & 3 deletions src/ofxUserGenerator.h
Expand Up @@ -65,9 +65,9 @@ class ofxUserGenerator {

// vars for cloud point and masking
XnUInt16 width, height;
unsigned char * maskPixels[MAX_NUMBER_USERS];
ofPoint * cloudPoints[MAX_NUMBER_USERS];
ofColor * cloudColors[MAX_NUMBER_USERS];
unsigned char * maskPixels[MAX_NUMBER_USERS+1];//including 0 as all users
ofPoint * cloudPoints[MAX_NUMBER_USERS+1];//including 0 as all users
ofColor * cloudColors[MAX_NUMBER_USERS+1];//including 0 as all users
bool useMaskPixels, useCloudPoints;

float smoothing_factor;
Expand Down

0 comments on commit 2a4f8a2

Please sign in to comment.