diff --git a/.gitignore b/.gitignore index 225d38d4..58b9fbd7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ build/ *.iml/ .idea/ gradle.properties -/ShaderError.txt +/hs_err_pid*.log +/gui-parameters/ +/ShaderError.glsl diff --git a/README.md b/README.md index 515beef7..c011557d 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ A growing library of assorted data structures, algorithms and utilities. | [`orx-temporal-blur`](orx-temporal-blur/) | Post-processing temporal-blur video effect. CPU intense, therefore not intended for use with the `ScreenRecorder` extension or other real-time uses. | | [`orx-time-operators`](orx-time-operators/) | A collection of time-sensitive functions aimed at controlling raw data over-time, such as Envelope and LFO. | | [`orx-timer`](orx-timer/) | Simple timer functionality providing `repeat`, to run code with a given interval and `timeOut`, to run code once after a given delay. | +| [`orx-depth-camera`](orx-depth-camera/) | Common API for various depth cameras like Kinect 1 and 2. | ## JVM only diff --git a/build.gradle b/build.gradle index 212d7cfd..81f5ae83 100644 --- a/build.gradle +++ b/build.gradle @@ -35,8 +35,8 @@ def multiplatformModules = [ "orx-shader-phrases", "orx-shapes", "orx-quadtree", - "orx-hash-grid" - + "orx-hash-grid", + "orx-depth-camera" ] def doNotPublish = ["openrndr-demos"] diff --git a/orx-color/src/commonMain/kotlin/Color.kt b/orx-color/src/commonMain/kotlin/Color.kt new file mode 100644 index 00000000..91eaf885 --- /dev/null +++ b/orx-color/src/commonMain/kotlin/Color.kt @@ -0,0 +1,5 @@ +// keeping this file here will stop IntelliJ from showing warning in nested relative packages +/** + * orx-color + */ +package org.openrndr.extra.color diff --git a/orx-depth-camera/build.gradle.kts b/orx-depth-camera/build.gradle.kts new file mode 100644 index 00000000..206c42b3 --- /dev/null +++ b/orx-depth-camera/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + kotlin("multiplatform") +} + +kotlin { + jvm { + testRuns["test"].executionTask.configure { + useJUnitPlatform() + } + } + js(IR) { + browser() + nodejs() + } + + sourceSets { + @Suppress("UNUSED_VARIABLE") + val commonMain by getting { + dependencies { + implementation(libs.openrndr.application) + implementation(libs.openrndr.math) + } + } + } + +} diff --git a/orx-depth-camera/src/commonMain/kotlin/DepthCamera.kt b/orx-depth-camera/src/commonMain/kotlin/DepthCamera.kt new file mode 100644 index 00000000..07452b88 --- /dev/null +++ b/orx-depth-camera/src/commonMain/kotlin/DepthCamera.kt @@ -0,0 +1,72 @@ +package org.openrndr.extra.depth.camera + +import org.openrndr.draw.ColorBuffer +import org.openrndr.math.IntVector2 + +/** + * Defines how pixel values encoded in depth [ColorBuffer] will be interpreted. + */ +enum class DepthMeasurement { + + /** + * Raw values, but normalized to the range 0-1. + * Useful for debugging, because full range of captured values can be rendered + * as a texture. Therefore it's a default setting. + */ + RAW_NORMALIZED, + + /** + * Raw values, exactly as they are provided by the device. + * Note: it might imply that [ColorBuffer] of the depth camera frame + * is provided in integer-based format (for example in case of Kinect devices). + */ + RAW, + + /** + * Expressed in meters. + * It is using floating point numbers. + * Note: values above `1.0` will not be visible if displayed as a texture. + */ + METERS, + +} + +/** + * General API of any depth camera. + */ +interface DepthCamera { + + /** + * Current operating resolution. + */ + val resolution: IntVector2 + + /** + * The units/mapping in which depth is expressed on received frames. + */ + var depthMeasurement: DepthMeasurement + + /** + * Flips source depth data image in horizontal axis (mirror). + */ + var flipH: Boolean + + /** + * Flips source depth data image in vertical axis (upside-down). + */ + var flipV: Boolean + + /** + * The most recent frame received from the depth camera. + */ + val currentFrame: ColorBuffer + + /** + * Will execute the supplied block of code with each most recent frame + * from the depth camera as an input. + * + * @param block the code to execute when the new frame is received. + */ + fun onFrameReceived(block: (frame: ColorBuffer) -> Unit) + +} diff --git a/orx-fx/README.md b/orx-fx/README.md index c42da676..487a5da9 100644 --- a/orx-fx/README.md +++ b/orx-fx/README.md @@ -167,6 +167,25 @@ fun main() = application { } ``` +### Colormap + +Colormap filters operate only on the RED color channel. For example +depth maps from +[orx-depth-camera](https://github.com/openrndr/orx/tree/master/orx-depth-camera). + +They allow selection of `min` / `max` value range and applying exponential +shaping `curve` within this range: + +- `GrayscaleColormap` - maps to gray tones +- `SpectralZucconiColormap` - maps to natural light dispersion spectrum as described + by Alan Zucconi in the + [Improving the Rainbow](https://www.alanzucconi.com/2017/07/15/improving-the-rainbow/) + article. +- `TurboColormap` - maps to Turbo Colormap according to + [Turbo, An Improved Rainbow Colormap for Visualization](https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html) + by Google. + +