Skip to content

Commit

Permalink
scaling parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
badgeek committed Oct 21, 2011
1 parent 5e9653a commit 2218d9a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
17 changes: 14 additions & 3 deletions fux_kinect.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -171,16 +171,27 @@ void fux_kinect::depth_cb(freenect_device *dev, void *v_depth, uint32_t timestam
uint16_t *depth = (uint16_t*)v_depth; uint16_t *depth = (uint16_t*)v_depth;


pthread_mutex_lock(gl_backbuf_mutex); pthread_mutex_lock(gl_backbuf_mutex);


int depth_range = kinect_max - kinect_min;


for (i=0; i<640*480; i++) { for (i=0; i<640*480; i++) {
//global_depth[i] = depth[i]; //global_depth[i] = depth[i];
//depth_mid[i] = depth[i]; //depth_mid[i] = depth[i];


int pval; int pval;


if(depth[i] > (float)kinect_min && depth[i] < (float)kinect_max ) if(depth[i] > (float)kinect_min)
{ {
pval = ceil((1-(depth[i]/(float)kinect_max))*255.f);
if (depth[i] > (float)kinect_max)
{
pval = 0;
}else{
//depth[i] - kinect_max
pval = (1 - (depth[i] - (float)kinect_min)/(float)depth_range) * 255.f;//ceil((1-(depth[i]/(float)kinect_max))*255.f);
}

}else{ }else{
pval = 0; pval = 0;
} }
Expand Down
17 changes: 14 additions & 3 deletions kinect.pd
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
#N canvas 833 136 450 300 10; #N canvas 903 209 450 300 10;
#X msg 36 18 create; #X msg 36 18 create;
#X obj 49 39 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1 #X obj 49 39 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1
; ;
Expand All @@ -7,20 +7,31 @@
#X obj 240 91 fux_kinect; #X obj 240 91 fux_kinect;
#X obj 240 68 gemhead; #X obj 240 68 gemhead;
#X obj 240 113 pix_texture; #X obj 240 113 pix_texture;
#X obj 240 135 rectangle 4 3; #X obj 234 215 rectangle 4 3;
#X msg 98 15 dimen 800 600; #X msg 98 15 dimen 800 600;
#X text 299 50 Elevation; #X text 299 50 Elevation;
#X obj 49 152 loadbang; #X obj 49 152 loadbang;
#X msg 50 195 1; #X msg 50 195 1;
#X msg 111 61 destroy; #X msg 111 61 destroy;
#X floatatom 264 25 5 0 0 0 - - -;
#X floatatom 335 22 5 0 0 0 - - -;
#X text 384 18 MIN;
#X text 277 7 MAX;
#X obj 246 162 scaleXYZ;
#X floatatom 372 113 5 0 0 0 - - -;
#X connect 0 0 3 0; #X connect 0 0 3 0;
#X connect 1 0 3 0; #X connect 1 0 3 0;
#X connect 2 0 4 1; #X connect 2 0 4 1;
#X connect 4 0 6 0; #X connect 4 0 6 0;
#X connect 5 0 4 0; #X connect 5 0 4 0;
#X connect 6 0 7 0; #X connect 6 0 17 0;
#X connect 8 0 3 0; #X connect 8 0 3 0;
#X connect 10 0 0 0; #X connect 10 0 0 0;
#X connect 10 0 11 0; #X connect 10 0 11 0;
#X connect 11 0 1 0; #X connect 11 0 1 0;
#X connect 12 0 3 0; #X connect 12 0 3 0;
#X connect 13 0 4 2;
#X connect 14 0 4 3;
#X connect 17 0 7 0;
#X connect 18 0 17 1;
#X connect 18 0 17 2;

0 comments on commit 2218d9a

Please sign in to comment.