KINECT-Playing a movie inside user's silhoutte

edited November 2014 in Kinect

Hello Processing Community,

I have created a sketch with kinect , in which The background is black and , simple image is displayed inside the user's silhouette. My question is that, is it possible to play a movie inside the user's silhouette? If yes, then please give me your useful suggestions...

I'm trying my best for this stuff, but if I"ll get any help, it would be great....

regards...

Tagged:

Answers

  • Answer ✓

    Hello !

    It's possible And it's actually not very hard since you know how to put an image inside the silhouette.

    You just have to draw your video in an image and use that image in your silhouette :)

  • edited December 2014

    Hi, Yes, I have tried that as you suggest me @tlecoz, ...

    This is the code to display the image inside the user's silhoutte

        depthValues=kinect.depthMap();
        userMap = kinect.userMap();
        for (int i =0; i < kinect.depthHeight(); i++) {
          for (int j = 0; j < kinect.depthWidth(); j++) {
            int index=j+i*640;
    
          if (userMap[index] != 0) {
    
           c = rgbImage.pixels[index];
           userImage.pixels[index]=color(c);
    
          }
          else{
          userImage.pixels[index]=color(0);
          }
         }      
        }    
        userImage.updatePixels();
    

    But, when I tried to place an image of movie inside the user's silhoutte, the sketch has stop running.

  • Answer ✓

    hmmm it's very weird !

    Try to draw your video inside the image "userImage" and use the exact same code, it should work.

    "I tried to place an image of movie inside the user's silhoutte" Can you show us your code

  • edited December 2014

    Yes , @tlecoz

    Here is the code:

          if (userMap[index] != 0) {
    
           c = rgbImage.pixels[index];
           userImage.pixels[index]=color(c);
    
          }
          else{
          userImage.pixels[index]=color(0);
          }
         }      
        }    
    
  • edited December 2014
    c=movie.pixels[index];
    usreImage.pixels[index]=color(c);
    

    Then ,it gives an ArrayIndexOutOfboundException...

  • Answer ✓

    Hello !

    As I said 2 times already... You need to draw your video inside the image you're using....

    Right now, your video has not the same dimension of your image, then you get an outOfBoundException. If you draw your video in the image, there will be no problem anymore because there will be no dimension problem anymore.

    Then... just draw your video in your picture with PImage.copy, and use your image without change anything.

  • edited November 2014

    Hi,

    As you told me that why , an array ewxception is thrown , that I understand , but You are saying that, draw the movie in the user image, Sorry , but seriously I don't know how to draw a movie inside the user image with the help of PImage.copy method.

  • Answer ✓

    something like that

    image.copy(video,0,0,videoWidth,videoHeight,0,0,imageWidth,imageHeight);

  • edited November 2014

    hi @tlecoz,

    with the help of yours , the userImage is displayed like this:

    ()Screen Shot 2014-11-21 at 1.54.24 PM

    Movie is running inside the user Image, but , b'coz of the black lines in the user'silhoutte, we can not see the movie properly.

    Is it bcoz of interlace of the movie, or bcoz of the user's depth image?

  • Hmmm.... I think - but not sure - it's because your video is scaled to fit in your picture. Then, the height of each pixel is bigger than it should be

    try to apply the copy like that and tell me if it works

    int videoW; //<- put the width of the video in it
    int videoH; //<- put the heightof the video in it
    int imageW; //<- put the width of the image in it
    int imageH; //<- put the heightof the image in it
    
    float ratioH = parseFloat(imageH) / parseFloat(videoH);
    videoW *= ratioH;
    videoH *= ratioH;
    
    float px = -(imageW - videoW)/2;
    px *= 1/ratioH;
    
    image.copy(video,px,0,imageW,imageH,0,0,imageW,imageH);
    

    The code should (I don't test it) scale your video to have the same height than the image, center the video in the image (and then crop the left/right border).

    I think it should be better now

  • edited November 2014

    Hi, @tlecoz, It gives the same result. . .

  • Can you send the whole code ?

  • edited December 2014

    Yes @tlecoz,

    This is the updated code:

          if (userMap[index] != 0) {
    
           c = movie.pixels[index];
           userImage.pixels[index]=color(c);
    
          }
          else{
          userImage.pixels[index]=color(0);
          }
         }      
        }    
    
       imageW=640;
       imageH=480;
    
       float ratioH=parseFloat(imageH)/parseFloat(videoH);
       videoW*=ratioH;
       videoH*=ratioH;
    
       int px=-(imageW-videoW)/2;
       px*=1/ratioH;
    
       userImage.copy(px,0,imageW,imageH,0,0,imageW,imageH);
       userImage.updatePixels();
    
  • edited November 2014

    Hi @tlecoz,

    Movie is playing inside the user's silhoutte, I have just used 640x480 movie.

  • Sorry I don't know...

    I met that problem not so long time ago with a kinect project too, but I can't remember how I made or even if I successed...

  • edited November 2014

    Hey, @tlecoz

    please don't be sorry, you helped me to draw the movie inside the user's image.. In fact, Thank you for helping me.

  • hi @tlecoz , Is it possible to assign different images or videos to the different user's silhouettes ?

    e.g, 1st user's silhouette will get 1st image, 2nd user's silhouette will get 2nd image, 3rd user's silhouette will get 3rd image, 4th user's silhouette will get 4th image ...

    and so on ...

  • edited November 2014 Answer ✓

    Hello

    It's possible :)

    In a first time you need to know what color are used for the silhouette. Once you get it, you only have to add a condition

     c = userMap[index];
    
    if(c== firstColor) userImage.pixels[index]=firstMovie[index];
    else if (c== secondColor) userImage.pixels[index]=secondMovie[index];
    else if (c== thirdColor) userImage.pixels[index] = thirdMovie[index];
    
  • Hi @tleccoz, You mean to say that, First I create an array of color, n try to see that, which user get which colour, n then apply your logic?

  • Can we have the full code?

Sign In or Register to comment.