Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: thomas <diewald@student.tugraz.at>
- Loading branch information
thomas
committed
Mar 31, 2012
1 parent
c8caf0c
commit fc001ae
Showing
91 changed files
with
1,054 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
...eenect/examples/kinect_basic_frames_customDepthmap/kinect_basic_frames_customDepthmap.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
//--------------------------------------------- | ||
// | ||
// author: thomas diewald | ||
// date: 30.03.2012 | ||
// | ||
// desc: basic example to get video/depth from a kinect | ||
// modified example, to generate a custom depth map | ||
//--------------------------------------------- | ||
|
||
import dLibs.freenect.toolbox.*; | ||
import dLibs.freenect.constants.*; | ||
import dLibs.freenect.interfaces.*; | ||
import dLibs.freenect.*; | ||
|
||
//------------------------------------------------------------------- | ||
Kinect kinect_; | ||
KinectFrameVideo kinect_video_; | ||
KinectFrameDepth kinect_depth_; | ||
|
||
int kinectFrame_size_x = VIDEO_FORMAT._RGB_.getWidth(); | ||
int kinectFrame_size_y = VIDEO_FORMAT._RGB_.getHeight(); | ||
|
||
PImage video_frame_, depth_frame_; // images | ||
|
||
// raw depth values of the kinect depth camera ( copy by reference or deep copy) | ||
int[] raw_depth; | ||
|
||
//------------------------------------------------------------------- | ||
void setup(){ | ||
size(kinectFrame_size_x, kinectFrame_size_y*2); | ||
|
||
kinect_ = new Kinect(0); | ||
|
||
kinect_video_ = new KinectFrameVideo(VIDEO_FORMAT._RGB_ ); | ||
kinect_depth_ = new KinectFrameDepth(DEPTH_FORMAT._11BIT_); | ||
kinect_depth_.setColorMode(2); // no generation of depth-map by default | ||
|
||
kinect_video_.setFrameRate(30); | ||
kinect_depth_.setFrameRate(30); | ||
|
||
kinect_video_.connect(kinect_); | ||
kinect_depth_.connect(kinect_); | ||
|
||
// create a PImage for video/depth | ||
video_frame_ = createImage(VIDEO_FORMAT._RGB_ .getWidth(), VIDEO_FORMAT._RGB_ .getHeight(), RGB); | ||
depth_frame_ = createImage(DEPTH_FORMAT._11BIT_.getWidth(), DEPTH_FORMAT._11BIT_.getHeight(), RGB); | ||
|
||
// hint: allocate the arraysize, if the values should be copied for every frame (deep copy) | ||
//raw_depth = new int[depth_frame_.pixels.length]; | ||
} | ||
|
||
|
||
|
||
|
||
//------------------------------------------------------------------- | ||
void draw(){ | ||
println(frameRate); | ||
|
||
|
||
//--------------------------------------- | ||
// DEPTH VALUES | ||
//--------------------------------------- | ||
// hint: use System.arraycopy(), if a deep-copy is | ||
// needed! ... uncomment array allocation in setup | ||
// System.arraycopy(kinect_depth_.getRawDepth(), 0, raw_depth, 0, raw_depth.length); | ||
raw_depth = kinect_depth_.getRawDepth(); // just copy by reference | ||
|
||
// custom mapping from raw-depth values, to a gray depthmap | ||
depth_frame_.loadPixels(); | ||
for (int i = 0; i < raw_depth.length; i++){ | ||
// 2047 is the depth-value-"code" for kinect-shadows | ||
if( raw_depth[i] == 2047) { | ||
// set blue color for shadows, ... or any other color | ||
depth_frame_.pixels[i] = 0xFF0000AA; | ||
} else { // valid depth values | ||
// raw depth values have a range of ~330 to ~1150 | ||
// and are mapped to a gray-values from 255 to 0 | ||
// TODO: custom mapping values | ||
int gray = ((int) map(raw_depth[i], 330, 1150, 255, 0)) & 0xFF ; | ||
depth_frame_.pixels[i] = 0xFF000000 | gray<<16 | gray<<8 | gray<<0 ; | ||
} | ||
} | ||
depth_frame_.updatePixels(); | ||
|
||
|
||
|
||
//--------------------------------------- | ||
// VIDEO VALUES | ||
//--------------------------------------- | ||
// copy rgb-video-pixels to image (by reference!!) | ||
video_frame_.loadPixels(); | ||
video_frame_.pixels = kinect_video_.getPixels(); | ||
video_frame_.updatePixels(); | ||
|
||
|
||
|
||
// display images | ||
image(video_frame_, 0, 0); | ||
image(depth_frame_, 0, DEPTH_FORMAT._11BIT_.getHeight()); | ||
} | ||
|
||
|
||
|
||
void dispose(){ | ||
Kinect.shutDown(); | ||
super.dispose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# More on this file here: http://code.google.com/p/processing/wiki/LibraryBasics | ||
# UTF-8 supported. | ||
|
||
# The name of your library as you want it formatted | ||
name = dLibs_freenect | ||
|
||
# List of authors. Links can be provided using the syntax [author name](url) | ||
authorList = [Thomas Diewald](http://www.thomasdiewald.com) | ||
|
||
# A web page for your library, NOT a direct link to where to download it | ||
url = http://thomasdiewald.com/processing/libraries/dLibs_freenect/ | ||
|
||
# The category of your library, must be one (or many) of the following: | ||
# "3D" "Animation" "Compilations" "Data" | ||
# "Fabrication" "Geometry" "GUI" "Hardware" | ||
# "I/O" "Language" "Math" "Simulation" | ||
# "Sound" "Utilities" "Typography" "Video & Vision" | ||
# | ||
# If a value other than those listed is used, your library will listed as "Other." | ||
category = Video & Vision | ||
|
||
# A short sentence (or fragment) to summarize the library's function. This will be | ||
# shown from inside the PDE when the library is being installed. Avoid repeating | ||
# the name of your library here. Also, avoid saying anything redundant like | ||
# mentioning that its a library. This should start with a capitalized letter, and | ||
# end with a period. | ||
sentence = a kinect library based on the libfreenect-software. | ||
|
||
# Additional information suitable for the Processing website. The value of | ||
# 'sentence' always will be prepended, so you should start by writing the | ||
# second sentence here. If your library only works on certain operating systems, | ||
# mention it here. | ||
paragraph = | ||
|
||
# Links in the 'sentence' and 'paragraph' attributes can be inserted using the | ||
# same syntax as for authors. That is, [here is a link to Processing](http://processing.org/) | ||
|
||
|
||
# A version number that increments once with each release. This | ||
# is used to compare different versions of the same library, and | ||
# check if an update is available. You should think of it as a | ||
# counter, counting the total number of releases you've had. | ||
version = 12 # This must be parsable as an int | ||
|
||
# The version as the user will see it. If blank, the version attribute will be used here | ||
prettyVersion = 2.95 # This is treated as a String |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.