Skip to content

Commit

Permalink
fixed pixel copy when image has been decimated
Browse files Browse the repository at this point in the history
  • Loading branch information
cansik committed Feb 21, 2020
1 parent ac531e8 commit 3791805
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/ch/bildspur/realsense/stream/VideoRSStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public PImage getImage() {
}

public void copyPixels(VideoFrame frame) {

// check if image has been changed by filters
if(frame.getWidth() != image.width || frame.getHeight() != image.height) {
image = new PImage(frame.getWidth(), frame.getHeight(), PConstants.RGB);
}

switch (frame.getProfile().getFormat()) {
case Rgb8:
copyRGB8(frame);
Expand Down
69 changes: 69 additions & 0 deletions src/test/java/ch/bildspur/realsense/test/DecimationFilterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package ch.bildspur.realsense.test;


import ch.bildspur.realsense.RealSenseCamera;
import ch.bildspur.realsense.type.ColorScheme;
import processing.core.PApplet;
import processing.opengl.PJOGL;

/**
* Created by cansik on 21.03.17.
*/
public class DecimationFilterTest extends PApplet {
public final static int OUTPUT_WIDTH = 1280;
public final static int OUTPUT_HEIGHT = 500;

public final static int VIEW_WIDTH = 640;
public final static int VIEW_HEIGHT = 480;

public final static int FRAME_RATE = 30;

RealSenseCamera camera = new RealSenseCamera(this);

public static void main(String... args) {
DecimationFilterTest sketch = new DecimationFilterTest();
sketch.runSketch();
}

public void settings() {
size(OUTPUT_WIDTH, OUTPUT_HEIGHT, FX2D);
PJOGL.profile = 1;
}

public void setup() {
frameRate(FRAME_RATE);

if(camera.isDeviceAvailable()) {
println("Camera found!");
}
else {
println("No camera available!");
exit();
}

camera.enableDepthStream();
camera.enableColorStream();

camera.enableColorizer(ColorScheme.Classic);
camera.addDecimationFilter(7);

camera.start();
}

public void draw() {
// clear screen
background(55);

camera.readFrames();

// show both streams
image(camera.getDepthImage(), 0, 0, VIEW_WIDTH, VIEW_HEIGHT);
image(camera.getColorImage(), VIEW_WIDTH, 0, VIEW_WIDTH, VIEW_HEIGHT);

fill(255, 255, 255);
textAlign(LEFT, CENTER);
text("Depth Stream", 20, VIEW_HEIGHT + 8);
text("Color Stream", VIEW_WIDTH + 20, VIEW_HEIGHT + 8);
surface.setTitle("RealSense Processing - FPS: " + Math.round(frameRate));
}
}

0 comments on commit 3791805

Please sign in to comment.