applying a mask flips or rotate the image!

edited February 2016 in Kinect

Hi. I'm developing in Eclipse. With a kinect (depth sensor).

Currently, I'm trying to mask images. But for some reason as soon I apply a filter, the image flips (or rotates 180º). And I just can't get them back to the current position.

This happens not only with mask() method, but also with other filters (with filter method itself or the blend() one)

I'm giving you an example code:

PGraphics mappingZone;
.. mappingZone = applet.createGraphics(kinect.width, kinect.height, PApplet.P2D);
.. filteredImg = applet.createImage(kinect.width, kinect.height, PApplet.P2D); ...

  mappingZone.image(mappingTexture, 0, 0);

  applet.image(mappingZone, 0, 0, applet.width, applet.height);

I tried several things to flip the image to the correct position, like: mappingZone.scale(-1, -1);

But nothing works. However, applying a second filter usually return the image to the correct position. Any clue?



  • edited February 2016

    I don't see where applet is defined. But since you're invoking Processing API methods from it, it is a PApplet object for sure. My only guess is just maybe that's outside the "Animation" Thread? :-/

  • edited February 2016

    Well, yes, applet is a PApplet. From inside my window I just do this: new Mapping(this)

    Anyway, that's not the problem at all. I have many sketches running in Eclipse and this is the first time I have this issue.

    See, there are three layers involved. The dots background. The stripes texture. And the silhouette.

    The strips image is just a background image. It has no orientation. And the mask is the one I'm attaching now. I've just printed this capture adding this line at the very bottom of the code:

    applet.image(filteredImg, 0, 0, applet.width, applet.height);

    As you can see, it has the right orientation. However it gets upside down when using mask() method or any other filter.


    Annoying thing is that I just can't reverse it back. Rotate method does nothing.

  • edited February 2016

    Hey, I don't know why this thread was moved to kinect forum. Indeed I use a kinect, but issue is general. And I feel nobody will answer this here :/

    See, I found an old thread talking about the same think:

    Applying a mask in P2D renderer flips the image upside down.

    Does anybody knows if this is considered a bug or not? Maybe @zeroisnan?

    By the way, I solved it following that mentioned thread solution:

    background = applet.createGraphics(kinect.width, kinect.height, PApplet.P2D);
    mappingZone = applet.createGraphics(kinect.width, kinect.height, PApplet.P2D);

    Meaning, I'm using default renderer instead of P2D. Thanks.

  • what about

    scale(0, -1);
  • I tried several things to flip the image to the correct position, like: mappingZone.scale(-1, -1);

    I tried that with no results. It just do nothing. Maybe because of the renderer?

    Anyway, this is solved. I'm just wondering if I should report the issue as a bug.

  • Answer ✓

    I forget the details, but there was a Java bug that caused flipped output under some circumstances. It's fixed in Processing 3.02.

  • For the record, this was the Processing GitHub issue:

Sign In or Register to comment.