Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ gson = "2.9.0"
antlr = "4.10.1"
tensorflow = "0.4.1"
jarchivelib = "1.2.0"
logbackClassic = "1.2.11"
minim = "2.2.2"
netty = "4.1.79.Final"
rabbitcontrol = "0.3.29"
Expand Down Expand Up @@ -64,7 +63,6 @@ boofcv = { group = "org.boofcv", name = "boofcv-core", version.ref = "boofcv" }
libfreenect = { group = "org.bytedeco", name = "libfreenect", version.ref = "libfreenect" }
librealsense = { group = "org.bytedeco", name = "librealsense2", version.ref = "librealsense" }
jarchivelib = { group = "org.rauschig", name = "jarchivelib", version.ref = "jarchivelib" }
logback-classic = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logbackClassic" }
minim = { group = "net.compartmental.code", name = "minim", version.ref = "minim" }
netty-all = { group = "io.netty", name = "netty-all", version.ref = "netty" }
rabbitcontrol-rcp = { group = "cc.rabbitcontrol", name = "rcp", version.ref = "rabbitcontrol" }
Expand Down
47 changes: 47 additions & 0 deletions orx-depth-camera/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# orx-depth-camera

General [DepthCamera](src/commonMain/kotlin/DepthCamera.kt) API for obtaining the signal from any type of
depth camera.

It offers selection of `DepthMeasurement` units (`METERS`, `RAW_NORMALIZED`, `RAW`), and allows
to flip the image horizontally and vertically.

Depth camera provides current resolution, current frame, as well as
an asynchronous hook to react to the latest received depth frame.

Note: Implementations will guarantee that the `onFrameReceived` hook is executed in coroutine of
the main drawer thread.

## Usage

Even though the API is generic, it can be used only with specific provider. The only one working at the moment:

* [orx-kinect-v1](https://github.com/openrndr/orx/tree/master/orx-jvm/orx-kinect-v1)

```kotlin
import org.openrndr.application
import org.openrndr.extra.kinect.v1.Kinect1

/**
* Basic use case showing stream of depth camera frames.
*
* Note: kinect depth map is stored only on the RED color channel,
* therefore depth map is displayed only in the red tones.
*/
fun main() = application {
configure { // default resolution of the Kinect v1 depth camera
width = 640
height = 480
}
program {
val kinect = extend(Kinect1())
val device = kinect.openDevice()
device.depthCamera.flipH = true // to make a mirror
camera.depthMeasurement = DepthMeasurement.METERS
device.depthCamera.enabled = true
extend {
drawer.image(device.depthCamera.currentFrame)
}
}
}
```
3 changes: 3 additions & 0 deletions orx-jvm/orx-depth-camera-calibrator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# orx-depth-camera-calibrator

Allows calibration of the depth camera.
5 changes: 4 additions & 1 deletion orx-jvm/orx-depth-camera-calibrator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ dependencies {
implementation(project(":orx-fx"))
api(project(":orx-depth-camera"))
api(project(":orx-jvm:orx-gui"))
}
demoImplementation(project(":orx-jvm:orx-kinect-v1"))
demoRuntimeOnly(project(":orx-jvm:orx-kinect-v1-${(gradle as ExtensionAware).extra["openrndrClassifier"]}"))
demoRuntimeOnly(libs.slf4j.simple)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openrndr.extra.kinect.v1.demo

import org.openrndr.Fullscreen
import org.openrndr.application
import org.openrndr.draw.Filter
Expand All @@ -11,9 +9,6 @@ import org.openrndr.extra.depth.camera.calibrator.isolatedWithCalibration
import org.openrndr.extra.gui.GUI
import org.openrndr.extra.kinect.v1.Kinect1

/**
* How to use [DepthCameraCalibrator] with [Kinect1]?
*/
fun main() = application {
configure {
fullscreen = Fullscreen.CURRENT_DISPLAY_MODE
Expand All @@ -33,7 +28,23 @@ fun main() = application {
)

// simple visual effect applied to kinect data
val spaceRangeExtractor = SpaceRangeExtractor()
val spaceRangeExtractor = object : Filter(filterShaderFromCode("""
uniform sampler2D tex0; // kinect raw
uniform float minDepth;
uniform float maxDepth;
out vec4 o_color;
void main() {
ivec2 uv = ivec2(gl_FragCoord.xy);
float depth = texelFetch(tex0, uv, 0).r;
float luma = ((depth >= minDepth) && (depth <= maxDepth)) ? 1.0 : 0.0;
o_color = vec4(vec3(luma), 1.0);
}
""".trimIndent(),
"space range extractor"
)) {
var minDepth: Double by parameters
var maxDepth: Double by parameters
}
camera.onFrameReceived { frame ->
spaceRangeExtractor.apply(frame, outputBuffer)
}
Expand Down Expand Up @@ -91,27 +102,3 @@ fun main() = application {
}

}

/**
* A visual effect applied to kinect data in this demonstration.
* Everything is black, except for the white pixels within the range
* of 2 virtual walls positioned at [minDepth] at front of the
* viewer and [maxDepth] behind the viewer.
*/
class SpaceRangeExtractor : Filter(filterShaderFromCode("""
uniform sampler2D tex0; // kinect raw
uniform float minDepth;
uniform float maxDepth;
out vec4 o_color;
void main() {
ivec2 uv = ivec2(gl_FragCoord.xy);
float depth = texelFetch(tex0, uv, 0).r;
float luma = ((depth >= minDepth) && (depth <= maxDepth)) ? 1.0 : 0.0;
o_color = vec4(vec3(luma), 1.0);
}
""".trimIndent(),
"space range extractor"
)) {
var minDepth: Double by parameters
var maxDepth: Double by parameters
}
5 changes: 5 additions & 0 deletions orx-jvm/orx-kinect-common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# orx-kinect-common

Common base code for all the kinect versions.

Note: This extension is an internal library, not intended to be used directly.
15 changes: 0 additions & 15 deletions orx-jvm/orx-kinect-v1-demo/build.gradle.kts

This file was deleted.

13 changes: 0 additions & 13 deletions orx-jvm/orx-kinect-v1-demo/src/main/resources/logback.xml

This file was deleted.

22 changes: 1 addition & 21 deletions orx-jvm/orx-kinect-v1/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
# orx-kinect-v1

Support for the Kinect V1 RGB+Depth camera.

## Example usage

```
fun main() = application {
configure {
fullscreen = Fullscreen.CURRENT_DISPLAY_MODE
}
program {
val kinects = getKinectsV1()
val kinect = kinects.startDevice()
kinect.depthCamera.enabled = true
kinect.depthCamera.mirror = true
extend(kinect)
extend {
drawer.image(kinect.depthCamera.currentFrame)
}
}
}
```
Support for the Kinect V1 depth camera.
8 changes: 7 additions & 1 deletion orx-jvm/orx-kinect-v1/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ dependencies {
implementation(libs.kotlin.coroutines)
api(project(":orx-jvm:orx-kinect-common"))
api(libs.libfreenect)
}
demoImplementation(project(":orx-jvm:orx-kinect-v1"))
demoImplementation(project(":orx-jvm:orx-depth-camera-calibrator"))
demoImplementation(project(":orx-fx"))
demoImplementation(project(":orx-jvm:orx-gui"))
demoRuntimeOnly(project(":orx-jvm:orx-kinect-v1-${(gradle as ExtensionAware).extra["openrndrClassifier"]}"))
demoRuntimeOnly(libs.slf4j.simple)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openrndr.extra.kinect.v1.demo

import org.openrndr.application
import org.openrndr.extra.kinect.v1.Kinect1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openrndr.extra.kinect.v1.demo

import org.openrndr.application
import org.openrndr.draw.colorBuffer
import org.openrndr.extra.depth.camera.DepthMeasurement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openrndr.extra.kinect.v1.demo

import org.openrndr.application
import org.openrndr.draw.ColorFormat
import org.openrndr.draw.colorBuffer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openrndr.extra.kinect.v1.demo

import org.bytedeco.libfreenect.global.freenect
import org.openrndr.application
import org.openrndr.extra.kinect.v1.Kinect1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openrndr.extra.kinect.v1.demo

import org.openrndr.application
import org.openrndr.extra.kinect.v1.Kinect1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openrndr.extra.kinect.v1.demo

import org.bytedeco.libfreenect.global.freenect
import org.bytedeco.libfreenect.global.freenect.*
import org.openrndr.application
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openrndr.extra.kinect.v1.demo

import org.openrndr.application
import org.openrndr.extra.kinect.v1.Kinect1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openrndr.extra.kinect.v1.demo

import org.openrndr.application
import org.openrndr.draw.Filter
import org.openrndr.draw.colorBuffer
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ include(
"orx-jvm:orx-kinect-v1-natives-linux-x64",
"orx-jvm:orx-kinect-v1-natives-macos",
"orx-jvm:orx-kinect-v1-natives-windows",
"orx-jvm:orx-kinect-v1-demo",
"orx-jvm:orx-video-profiles",
"orx-depth-camera",
"orx-jvm:orx-depth-camera-calibrator"
Expand Down