Skip to content

Commit

Permalink
added loading from json feature
Browse files Browse the repository at this point in the history
  • Loading branch information
cansik committed Feb 11, 2020
1 parent 9953603 commit eb883ec
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 197 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,21 @@ camera.addUnitsTransform();
camera.addZeroOrderInvalidationFilter();
```

### Configuration
It is possible to load a predefined `JSON` file which contains a custom configuration. These configurations can be created in the RealSense Viewer app provided by Intel. To apply a `JSON` configuration, the camera has to be running alreay:

```java
// load json config from file
String jsonConfig = String.join("\n", loadStrings("RawStereoConfig.json"));

// enable an example stream and start camera
camera.enableColorStream();
camera.start();

// load a json cofiguration as a string
camera.setJsonConfiguration(jsonConfig);
```

### Advanced
For more advanced topics, the wrapper allows you to use the underlaying Java API through following getter methods.

Expand Down
92 changes: 1 addition & 91 deletions data/RawStereoConfig.json
Original file line number Diff line number Diff line change
@@ -1,95 +1,5 @@
{
"aux-param-autoexposure-setpoint": "400",
"aux-param-colorcorrection1": "0.461914",
"aux-param-colorcorrection10": "-0.553711",
"aux-param-colorcorrection11": "-0.553711",
"aux-param-colorcorrection12": "0.0458984",
"aux-param-colorcorrection2": "0.540039",
"aux-param-colorcorrection3": "0.540039",
"aux-param-colorcorrection4": "0.208008",
"aux-param-colorcorrection5": "-0.332031",
"aux-param-colorcorrection6": "-0.212891",
"aux-param-colorcorrection7": "-0.212891",
"aux-param-colorcorrection8": "0.68457",
"aux-param-colorcorrection9": "0.930664",
"aux-param-depthclampmax": "65536",
"aux-param-depthclampmin": "0",
"aux-param-disparityshift": "0",
"controls-autoexposure-auto": "False",
"controls-autoexposure-manual": "10837",
"controls-color-autoexposure-auto": "True",
"controls-color-autoexposure-manual": "166",
"controls-color-backlight-compensation": "0",
"controls-color-brightness": "0",
"controls-color-contrast": "50",
"controls-color-gain": "64",
"controls-color-gamma": "300",
"controls-color-hue": "0",
"controls-color-power-line-frequency": "3",
"controls-color-saturation": "64",
"controls-color-sharpness": "50",
"controls-color-white-balance-auto": "True",
"controls-color-white-balance-manual": "4600",
"controls-depth-gain": "16",
"controls-depth-white-balance-auto": "False",
"controls-laserpower": "360",
"controls-laserstate": "off",
"ignoreSAD": "0",
"param-amplitude-factor": "0",
"param-autoexposure-setpoint": "400",
"param-censusenablereg-udiameter": "9",
"param-censusenablereg-vdiameter": "9",
"param-censususize": "9",
"param-censusvsize": "9",
"param-depthclampmax": "65536",
"param-depthclampmin": "0",
"param-depthunits": "100",
"param-disableraucolor": "0",
"param-disablesadcolor": "0",
"param-disablesadnormalize": "0",
"param-disablesloleftcolor": "0",
"param-disableslorightcolor": "0",
"param-disparitymode": "0",
"param-disparityshift": "0",
"param-lambdaad": "800",
"param-lambdacensus": "26",
"param-leftrightthreshold": "24",
"param-maxscorethreshb": "2047",
"param-medianthreshold": "500",
"param-minscorethresha": "1",
"param-neighborthresh": "7",
"param-raumine": "1",
"param-rauminn": "1",
"param-rauminnssum": "3",
"param-raumins": "1",
"param-rauminw": "1",
"param-rauminwesum": "3",
"param-regioncolorthresholdb": "0.0499022",
"param-regioncolorthresholdg": "0.0499022",
"param-regioncolorthresholdr": "0.0499022",
"param-regionshrinku": "3",
"param-regionshrinkv": "1",
"param-robbinsmonrodecrement": "10",
"param-robbinsmonroincrement": "10",
"param-rsmdiffthreshold": "4",
"param-rsmrauslodiffthreshold": "1",
"param-rsmremovethreshold": "0.375",
"param-scanlineedgetaub": "72",
"param-scanlineedgetaug": "72",
"param-scanlineedgetaur": "72",
"param-scanlinep1": "60",
"param-scanlinep1onediscon": "105",
"param-scanlinep1twodiscon": "70",
"param-scanlinep2": "342",
"param-scanlinep2onediscon": "190",
"param-scanlinep2twodiscon": "130",
"param-secondpeakdelta": "325",
"param-texturecountthresh": "0",
"param-texturedifferencethresh": "0",
"param-usersm": "1",
"param-zunits": "100",
"stream-depth-format": "Z16",
"stream-fps": "30",
"stream-fps": "60",
"stream-height": "720",
"stream-width": "1280"
}
14 changes: 5 additions & 9 deletions examples/UseJsonConfig/UseJsonConfig.pde
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@ void setup()
// load json config from file
String jsonConfig = String.join("\n", loadStrings("RawStereoConfig.json"));

// get first device and load configuration
AdvancedDevice device = camera.getAdvancedDevice();
device.setAdvancedModeEnabled(true);
device.setJsonConfiguration(jsonConfig);

// enable color & depth stream
camera.enableColorStream();
camera.enableDepthStream();

// add colorizer
camera.enableColorizer(ColorScheme.Bio);
camera.enableColorizer(ColorScheme.Warm);

// align the streams
camera.enableAlign();

camera.start(device);
camera.start();
camera.setJsonConfiguration(jsonConfig);
}

void draw()
Expand All @@ -38,9 +34,9 @@ void draw()
camera.readFrames();

// show color images
tint(255, 255);
blendMode(BLEND);
image(camera.getColorImage(), 0, 0);

tint(255, 100);
blendMode(MULTIPLY);
image(camera.getDepthImage(), 0, 0);
}
92 changes: 1 addition & 91 deletions examples/UseJsonConfig/data/RawStereoConfig.json
Original file line number Diff line number Diff line change
@@ -1,95 +1,5 @@
{
"aux-param-autoexposure-setpoint": "400",
"aux-param-colorcorrection1": "0.461914",
"aux-param-colorcorrection10": "-0.553711",
"aux-param-colorcorrection11": "-0.553711",
"aux-param-colorcorrection12": "0.0458984",
"aux-param-colorcorrection2": "0.540039",
"aux-param-colorcorrection3": "0.540039",
"aux-param-colorcorrection4": "0.208008",
"aux-param-colorcorrection5": "-0.332031",
"aux-param-colorcorrection6": "-0.212891",
"aux-param-colorcorrection7": "-0.212891",
"aux-param-colorcorrection8": "0.68457",
"aux-param-colorcorrection9": "0.930664",
"aux-param-depthclampmax": "65536",
"aux-param-depthclampmin": "0",
"aux-param-disparityshift": "0",
"controls-autoexposure-auto": "False",
"controls-autoexposure-manual": "10837",
"controls-color-autoexposure-auto": "True",
"controls-color-autoexposure-manual": "166",
"controls-color-backlight-compensation": "0",
"controls-color-brightness": "0",
"controls-color-contrast": "50",
"controls-color-gain": "64",
"controls-color-gamma": "300",
"controls-color-hue": "0",
"controls-color-power-line-frequency": "3",
"controls-color-saturation": "64",
"controls-color-sharpness": "50",
"controls-color-white-balance-auto": "True",
"controls-color-white-balance-manual": "4600",
"controls-depth-gain": "16",
"controls-depth-white-balance-auto": "False",
"controls-laserpower": "360",
"controls-laserstate": "off",
"ignoreSAD": "0",
"param-amplitude-factor": "0",
"param-autoexposure-setpoint": "400",
"param-censusenablereg-udiameter": "9",
"param-censusenablereg-vdiameter": "9",
"param-censususize": "9",
"param-censusvsize": "9",
"param-depthclampmax": "65536",
"param-depthclampmin": "0",
"param-depthunits": "100",
"param-disableraucolor": "0",
"param-disablesadcolor": "0",
"param-disablesadnormalize": "0",
"param-disablesloleftcolor": "0",
"param-disableslorightcolor": "0",
"param-disparitymode": "0",
"param-disparityshift": "0",
"param-lambdaad": "800",
"param-lambdacensus": "26",
"param-leftrightthreshold": "24",
"param-maxscorethreshb": "2047",
"param-medianthreshold": "500",
"param-minscorethresha": "1",
"param-neighborthresh": "7",
"param-raumine": "1",
"param-rauminn": "1",
"param-rauminnssum": "3",
"param-raumins": "1",
"param-rauminw": "1",
"param-rauminwesum": "3",
"param-regioncolorthresholdb": "0.0499022",
"param-regioncolorthresholdg": "0.0499022",
"param-regioncolorthresholdr": "0.0499022",
"param-regionshrinku": "3",
"param-regionshrinkv": "1",
"param-robbinsmonrodecrement": "10",
"param-robbinsmonroincrement": "10",
"param-rsmdiffthreshold": "4",
"param-rsmrauslodiffthreshold": "1",
"param-rsmremovethreshold": "0.375",
"param-scanlineedgetaub": "72",
"param-scanlineedgetaug": "72",
"param-scanlineedgetaur": "72",
"param-scanlinep1": "60",
"param-scanlinep1onediscon": "105",
"param-scanlinep1twodiscon": "70",
"param-scanlinep2": "342",
"param-scanlinep2onediscon": "190",
"param-scanlinep2twodiscon": "130",
"param-secondpeakdelta": "325",
"param-texturecountthresh": "0",
"param-texturedifferencethresh": "0",
"param-usersm": "1",
"param-zunits": "100",
"stream-depth-format": "Z16",
"stream-fps": "30",
"stream-fps": "60",
"stream-height": "720",
"stream-width": "1280"
}
8 changes: 2 additions & 6 deletions src/test/java/ch/bildspur/realsense/test/JsonConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,14 @@ public void setup() {
// read configuration
String jsonConfig = String.join("\n", loadStrings("RawStereoConfig.json")).trim();

// get device
AdvancedDevice device = camera.getAdvancedDevice();
device.setAdvancedModeEnabled(true);
device.setJsonConfiguration(jsonConfig);

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

camera.enableAlign();
camera.enableColorizer(ColorScheme.Cold);

camera.start(device);
camera.start();
camera.setJsonConfiguration(jsonConfig);
}

public void draw() {
Expand Down

0 comments on commit eb883ec

Please sign in to comment.