|
| 1 | +package ch.bildspur.realsense.test; |
| 2 | + |
| 3 | + |
| 4 | +import ch.bildspur.realsense.RealSenseCamera; |
| 5 | +import ch.bildspur.realsense.processing.RSFilterBlock; |
| 6 | +import ch.bildspur.realsense.type.ColorScheme; |
| 7 | +import org.intel.rs.processing.ThresholdFilter; |
| 8 | +import org.intel.rs.types.Option; |
| 9 | +import processing.core.PApplet; |
| 10 | +import processing.opengl.PJOGL; |
| 11 | + |
| 12 | +/** |
| 13 | + * Created by cansik on 21.03.17. |
| 14 | + */ |
| 15 | +public class SimpleFilterTest extends PApplet { |
| 16 | + public final static int OUTPUT_WIDTH = 1280; |
| 17 | + public final static int OUTPUT_HEIGHT = 500; |
| 18 | + |
| 19 | + public final static int VIEW_WIDTH = 640; |
| 20 | + public final static int VIEW_HEIGHT = 480; |
| 21 | + |
| 22 | + public final static int FRAME_RATE = 30; |
| 23 | + |
| 24 | + RealSenseCamera camera = new RealSenseCamera(this); |
| 25 | + |
| 26 | + public static void main(String... args) { |
| 27 | + SimpleFilterTest sketch = new SimpleFilterTest(); |
| 28 | + sketch.runSketch(); |
| 29 | + } |
| 30 | + |
| 31 | + public void settings() { |
| 32 | + size(OUTPUT_WIDTH, OUTPUT_HEIGHT, FX2D); |
| 33 | + PJOGL.profile = 1; |
| 34 | + } |
| 35 | + |
| 36 | + public void setup() { |
| 37 | + frameRate(FRAME_RATE); |
| 38 | + |
| 39 | + if(camera.isCameraAvailable()) { |
| 40 | + println("Camera found!"); |
| 41 | + } |
| 42 | + else { |
| 43 | + println("No camera available!"); |
| 44 | + exit(); |
| 45 | + } |
| 46 | + |
| 47 | + camera.enableDepthStream(); |
| 48 | + camera.enableColorStream(); |
| 49 | + |
| 50 | + camera.enableColorizer(ColorScheme.Classic); |
| 51 | + camera.addThresholdFilter(0.0f, 1.0f); |
| 52 | + |
| 53 | + camera.start(); |
| 54 | + } |
| 55 | + |
| 56 | + public void draw() { |
| 57 | + // clear screen |
| 58 | + background(55); |
| 59 | + |
| 60 | + camera.readFrames(); |
| 61 | + |
| 62 | + // show both streams |
| 63 | + image(camera.getDepthImage(), 0, 0, VIEW_WIDTH, VIEW_HEIGHT); |
| 64 | + image(camera.getColorImage(), VIEW_WIDTH, 0, VIEW_WIDTH, VIEW_HEIGHT); |
| 65 | + |
| 66 | + fill(255, 255, 255); |
| 67 | + textAlign(LEFT, CENTER); |
| 68 | + text("Depth Stream", 20, VIEW_HEIGHT + 8); |
| 69 | + text("Color Stream", VIEW_WIDTH + 20, VIEW_HEIGHT + 8); |
| 70 | + surface.setTitle("RealSense Processing - FPS: " + Math.round(frameRate)); |
| 71 | + } |
| 72 | +} |
0 commit comments