orx-kinect-v1-demo module for testing the code and verifying use cases
This commit is contained in:
13
orx-kinect-v1-demo/build.gradle
Normal file
13
orx-kinect-v1-demo/build.gradle
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
def os = org.gradle.internal.os.OperatingSystem.current()
|
||||||
|
def openrndrOs
|
||||||
|
if (os.windows) { openrndrOs = "windows" }
|
||||||
|
else if (os.macOsX) { openrndrOs = "macos" }
|
||||||
|
else if (os.linux) { openrndrOs = "linux-x64" }
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile project(":orx-kinect-v1")
|
||||||
|
runtime project(":orx-kinect-v1-natives-$openrndrOs")
|
||||||
|
runtime "org.openrndr:openrndr-gl3:$openrndrVersion"
|
||||||
|
runtime "org.openrndr:openrndr-gl3-natives-$openrndrOs:$openrndrVersion"
|
||||||
|
runtime "ch.qos.logback:logback-classic:1.2.3"
|
||||||
|
}
|
||||||
26
orx-kinect-v1-demo/src/main/kotlin/BasicUseCaseDemo.kt
Normal file
26
orx-kinect-v1-demo/src/main/kotlin/BasicUseCaseDemo.kt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package org.openrndr.extra.kinect.v1.demo
|
||||||
|
|
||||||
|
import org.openrndr.application
|
||||||
|
import org.openrndr.extra.kinect.v1.getKinectsV1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic kinect use case showing continuous stream from the depth camera.
|
||||||
|
*
|
||||||
|
* Note: kinect depth map is stored only on the RED color channel to save
|
||||||
|
* space. 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 kinects = getKinectsV1(this)
|
||||||
|
val kinect = kinects.startDevice()
|
||||||
|
kinect.depthCamera.enabled = true
|
||||||
|
kinect.depthCamera.mirror = true
|
||||||
|
extend {
|
||||||
|
drawer.image(kinect.depthCamera.currentFrame)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
73
orx-kinect-v1-demo/src/main/kotlin/DepthToColorMapsDemo.kt
Normal file
73
orx-kinect-v1-demo/src/main/kotlin/DepthToColorMapsDemo.kt
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package org.openrndr.extra.kinect.v1.demo
|
||||||
|
|
||||||
|
import org.openrndr.application
|
||||||
|
import org.openrndr.draw.ColorBuffer
|
||||||
|
import org.openrndr.draw.ColorFormat
|
||||||
|
import org.openrndr.draw.colorBuffer
|
||||||
|
import org.openrndr.extra.kinect.*
|
||||||
|
import org.openrndr.extra.kinect.v1.getKinectsV1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows 4 different representations of the depth map.
|
||||||
|
* <ol>
|
||||||
|
* <li>the original depth map stored as RED channel values</li>
|
||||||
|
* <li>the same values expressed as gray tones</li>
|
||||||
|
* <li>
|
||||||
|
* color map according to natural light dispersion as described
|
||||||
|
* by Alan Zucconi in the
|
||||||
|
* <a href="https://www.alanzucconi.com/2017/07/15/improving-the-rainbow/">Improving the Rainbow</a>
|
||||||
|
* article.
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* color map according to
|
||||||
|
* <a href="https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html">
|
||||||
|
* Turbo, An Improved Rainbow Colormap for Visualization
|
||||||
|
* </a>
|
||||||
|
* by Google.
|
||||||
|
* </li>
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
|
* @see DepthToGrayscaleMapper
|
||||||
|
* @see DepthToColorsZucconi6Mapper
|
||||||
|
* @see DepthToColorsTurboMapper
|
||||||
|
*/
|
||||||
|
fun main() = application {
|
||||||
|
configure {
|
||||||
|
width = 2 * 640
|
||||||
|
height = 2 * 480
|
||||||
|
}
|
||||||
|
program {
|
||||||
|
val kinects = getKinectsV1(this)
|
||||||
|
val kinect = kinects.startDevice()
|
||||||
|
kinect.depthCamera.enabled = true
|
||||||
|
kinect.depthCamera.mirror = true
|
||||||
|
val camera = kinect.depthCamera
|
||||||
|
val grayscaleFilter = DepthToGrayscaleMapper()
|
||||||
|
val zucconiFilter = DepthToColorsZucconi6Mapper()
|
||||||
|
val turboFilter = DepthToColorsTurboMapper()
|
||||||
|
val grayscaleBuffer = kinectColorBuffer(camera)
|
||||||
|
val zucconiBuffer = kinectColorBuffer(camera)
|
||||||
|
val turboBuffer = kinectColorBuffer(camera)
|
||||||
|
extend {
|
||||||
|
/*
|
||||||
|
* Note: getting the latest frame this way will guarantee
|
||||||
|
* that filters are being applied only if the actual new frame
|
||||||
|
* from kinect was received. Kinect has different refresh rate
|
||||||
|
* than usual screen (30 fps).
|
||||||
|
*/
|
||||||
|
kinect.depthCamera.getLatestFrame()?.let { frame ->
|
||||||
|
grayscaleFilter.apply(frame, grayscaleBuffer)
|
||||||
|
zucconiFilter.apply(frame, zucconiBuffer)
|
||||||
|
turboFilter.apply(frame, turboBuffer)
|
||||||
|
}
|
||||||
|
drawer.image(camera.currentFrame)
|
||||||
|
drawer.image(grayscaleBuffer, camera.width.toDouble(), 0.0)
|
||||||
|
drawer.image(turboBuffer, 0.0, camera.height.toDouble())
|
||||||
|
drawer.image(zucconiBuffer, camera.width.toDouble(), camera.height.toDouble())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun kinectColorBuffer(camera: KinectCamera): ColorBuffer {
|
||||||
|
return colorBuffer(camera.width, camera.height, format = ColorFormat.RGB)
|
||||||
|
}
|
||||||
27
orx-kinect-v1-demo/src/main/kotlin/MultipleKinectsDemo.kt
Normal file
27
orx-kinect-v1-demo/src/main/kotlin/MultipleKinectsDemo.kt
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package org.openrndr.extra.kinect.v1.demo
|
||||||
|
|
||||||
|
import org.openrndr.application
|
||||||
|
import org.openrndr.extra.kinect.v1.getKinectsV1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stream from 2 kinects side by side.
|
||||||
|
*/
|
||||||
|
fun main() = application {
|
||||||
|
configure {
|
||||||
|
width = 640 * 2
|
||||||
|
height = 480
|
||||||
|
}
|
||||||
|
program {
|
||||||
|
val kinects = getKinectsV1(this)
|
||||||
|
val depthCamera1 = kinects.startDevice(0).depthCamera
|
||||||
|
val depthCamera2 = kinects.startDevice(1).depthCamera
|
||||||
|
depthCamera1.enabled = true
|
||||||
|
depthCamera1.mirror = true
|
||||||
|
depthCamera2.enabled = true
|
||||||
|
depthCamera2.mirror = true
|
||||||
|
extend {
|
||||||
|
drawer.image(depthCamera1.currentFrame)
|
||||||
|
drawer.image(depthCamera2.currentFrame, depthCamera1.width.toDouble(), 0.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package org.openrndr.extra.kinect.v1.demo
|
||||||
|
|
||||||
|
import org.bytedeco.libfreenect.global.freenect
|
||||||
|
import org.bytedeco.libfreenect.global.freenect.*
|
||||||
|
import org.openrndr.application
|
||||||
|
import org.openrndr.extra.kinect.v1.getKinectsV1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Even though this library is abstracting freenect access, it is still
|
||||||
|
* possible to call any low level kinect API through execute methods.
|
||||||
|
* The calls are executed in separate kinect runner thread but they will
|
||||||
|
* block the calling thread until the result is returned.
|
||||||
|
*/
|
||||||
|
fun main() = application {
|
||||||
|
program {
|
||||||
|
val kinects = getKinectsV1(this)
|
||||||
|
kinects.execute { ctx ->
|
||||||
|
freenect_set_log_level(ctx.fnCtx, freenect.FREENECT_LOG_FLOOD) // lots of logs
|
||||||
|
}
|
||||||
|
kinects.execute { ctx ->
|
||||||
|
// extra FREENECT_DEVICE_MOTOR gives control over tilt and LEDs
|
||||||
|
freenect_select_subdevices(ctx.fnCtx, FREENECT_DEVICE_CAMERA xor FREENECT_DEVICE_MOTOR)
|
||||||
|
}
|
||||||
|
val kinect = kinects.startDevice()
|
||||||
|
var tilt = 90.0
|
||||||
|
extend {
|
||||||
|
kinect.execute { ctx ->
|
||||||
|
freenect_set_led(ctx.fnDev, (seconds * 10).toInt() % 7) // disco
|
||||||
|
}
|
||||||
|
val currentTilt = if ((seconds % 10) < 5) -90.0 else 90.0
|
||||||
|
if (currentTilt != tilt) {
|
||||||
|
kinect.execute { ctx ->
|
||||||
|
freenect_set_tilt_degs(ctx.fnDev, currentTilt)
|
||||||
|
}
|
||||||
|
tilt = currentTilt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
orx-kinect-v1-demo/src/main/resources/logback.xml
Normal file
13
orx-kinect-v1-demo/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<configuration debug="false" scan="false" scanPeriod="10 seconds">
|
||||||
|
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
|
||||||
|
<resetJUL>true</resetJUL>
|
||||||
|
</contextListener>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
<root level="DEBUG">
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
||||||
@@ -1,22 +1,23 @@
|
|||||||
rootProject.name = 'orx'
|
rootProject.name = 'orx'
|
||||||
|
|
||||||
include 'orx-camera',
|
include 'orx-camera',
|
||||||
'orx-compositor',
|
'orx-compositor',
|
||||||
'orx-easing',
|
'orx-easing',
|
||||||
'orx-file-watcher',
|
'orx-file-watcher',
|
||||||
'orx-filter-extension',
|
'orx-filter-extension',
|
||||||
'orx-integral-image',
|
'orx-integral-image',
|
||||||
'orx-interval-tree',
|
'orx-interval-tree',
|
||||||
'orx-jumpflood',
|
'orx-jumpflood',
|
||||||
'orx-kdtree',
|
'orx-kdtree',
|
||||||
'orx-mesh-generators',
|
'orx-mesh-generators',
|
||||||
'orx-midi',
|
'orx-midi',
|
||||||
'orx-no-clear',
|
'orx-no-clear',
|
||||||
'orx-noise',
|
'orx-noise',
|
||||||
'orx-obj-loader',
|
'orx-obj-loader',
|
||||||
'orx-olive',
|
'orx-olive',
|
||||||
'orx-kinect-common',
|
'orx-kinect-common',
|
||||||
'orx-kinect-v1',
|
'orx-kinect-v1',
|
||||||
'orx-kinect-v1-natives-linux-x64',
|
'orx-kinect-v1-natives-linux-x64',
|
||||||
'orx-kinect-v1-natives-macos'
|
'orx-kinect-v1-natives-macos',
|
||||||
'orx-kinect-v1-natives-windows'
|
'orx-kinect-v1-natives-windows',
|
||||||
|
'orx-kinect-v1-demo'
|
||||||
|
|||||||
Reference in New Issue
Block a user