We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
For an interactive installation for my art study, using the kinect, I want to make a projection of the user's silhouette filled with text, like in the video here:
I have a working code to get the user's silhouette, but how can I replace it with text?
I've tried several things but it won't work.
I am working with processing 2.1 on windows 8.
My code so far:
import SimpleOpenNI.*;
SimpleOpenNI context;
PImage cam;
int[] userMap;
void setup() {
size(640, 480);
context = new SimpleOpenNI(this);
// mirror the image to be more intuitive
context.setMirror(true);
context.enableDepth();
context.enableUser();
}
void draw() {
background(0);
context.update();
if(context.getNumberOfUsers() > 0) {
userMap = context.userMap();
loadPixels();
for(int i = 0; i < userMap.length; i++) {
if (userMap[i] !=0) {
pixels[i] =color(0, 0, 255);
}
}
updatePixels();
}
}
Answers
Here is the sample code ....enjoy
I dont have kinect now so I couldn't check the code you need to check the code and may have to fix some bugs but it would work I am sure
dear blyk,
Thank you for your code. I noticed that your code doesn't work on my version of processing 2.1 and SimpleOpenNi. Functions like (SimpleOpenNI.SKEL_PROFILE_ALL) don't exist anymore. I fixed most of it, but I get stuck on the next point:
Here is the code I have until now: (with new parts I have corrected)
You can try to do this using only the Depth camera. If you want to use the userMap you must change "userMap = context.getUsersPixels(SimpleOpenNI.USERS_ALL);" to "userMap = context.userMap();". I'm using the same version than you.
I now have a code that can project something that looke like a silhouette, but I don't recognize the text in the silhouette, it's just a blurry mess... How can I fix this?
Can this code be simpler? Can, for example, the color parts be removed? I don't see the use of them...
I have written the code using older verion of simpleopenni 0.27 which was compatible with the old drivers for kinect Xbox360. Once I tried running new SimpleOpenni 1.96 version with kinect 1.6v sdk but I couldn't make it work so I was not able to test my code.
And yes you can remove that color code part which is certainly unnecessary for you. Actually I have given you a peice of my old code which had something do with that.
and don't forget to put fill(200,0,200); (you can actullly use any color) before line 59 .why? Because you need to define the text color.
@Genral thanks for giving that insight. Can you also mention that in my old post because I have started that discussion for pointing out the changes in new version of SimpleopenNI becasue there is no proper documentation other than java docs.
Post
@dragonvlame you can aslo refer to this discussion for any further problem
@blyk , So if I would simplify your code, what exactly would be removed? I'm trying all sorts of things but for example the code in line 51and 52, what does it do, and is it neccesary?
line 51 & 52 scan through all the pixles one by one and as soon as pixles matches with the userpixles " userMap[index] " it takes the pixels coordinate and put the text at that position.
Oke so that would be neccesary.. Thanks. I will try something and I will keep this up to date. Do you know why I get a blurry white mess in this code?:
how can I control the size of the font and maybe the internal space between the words?
Refer to processing website: http://www.processing.org/reference/text_.html there are some other realtive functions mentioned on the website
Thanks. So if I look at your complete code now, with // in front of all the things I can delete in your opinion, I would get this, correct?
What is the numer "255" for atline 51, blob_Array[index] ?
When I try to change something in your code, I get the error: ArrayIndexOutOfBondsException with a number behind it, which changed every time I run the sketch... Why am I getting this error?
@blyk , When I try anything different with the text, like textLeading, textSize or textAlign, I keep getting the error like above. How can I get less text so that I can see the different letters?
Thanks!
As I told you I don't have kinect now so I can't try it so you need to fix your bugs on your own I am really sorry
By using the code you send first, with 57 lines, I get the same kind of image. I understand that you can't help me fix the bugs :)I don't blame you for that at all, I am really grateful for your help! :D
I'm trying to figure out why it's all so close together, but the problem stays :)
aren't you drawing a letter at each pixel position, meaning you get a massive overlap? try using random colours for each letter so you can see the individual shapes.
i've also got to say that i hate this:
what's up with
String sampletext = "abcdefghijk";
and using charAt() to pick the letters out?or char c = (char)random('a', 'z' + 1);
(untested!)
Instead of having the y++ and the x++ in line 7 and 8 I put a y+=30 and a x+=30 and now it works fine. This thread can be closed :) Thanks all!