depth to color map filters as a part of kinect common support

This commit is contained in:
Kazik Pogoda
2019-08-24 00:33:20 +02:00
parent 6318891502
commit 40b919edd2
4 changed files with 152 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package org.openrndr.extra.kinect
import org.openrndr.Extension
import org.openrndr.draw.*
import org.openrndr.resourceUrl
import java.lang.RuntimeException
/**
@@ -10,11 +11,13 @@ import java.lang.RuntimeException
* @param <CTX> data needed to make low level kinect support calls.
*/
interface Kinects<CTX> {
fun countDevices(): Int
/**
* Starts kinect device of a given number.
*
* @param num the kinect device index.
* @throws KinectException if device of such a number does not exist,
* better to count them first.
* @see countDevices
@@ -24,7 +27,8 @@ interface Kinects<CTX> {
/**
* Executes low level Kinect commands in the kinect thread.
*/
fun execute(commands: (CTX) -> Any) : Any
fun <T> execute(commands: (CTX) -> T) : T
}
/**
@@ -38,7 +42,7 @@ interface KinectDevice<CTX> : Extension {
/**
* Executes low level Kinect commands in the kinect thread in the context of this device.
*/
fun execute(commands: (CTX) -> Any): Any
fun <T> execute(commands: (CTX) -> T): T
}
interface KinectCamera {
@@ -55,3 +59,31 @@ interface KinectDepthCamera : KinectCamera {
}
class KinectException(msg: String) : RuntimeException(msg)
/**
* Maps depth values to grayscale.
*/
class DepthToGrayscaleMapper : Filter(
filterShaderFromUrl(resourceUrl("depth-to-grayscale.frag", Kinects::class.java))
)
/**
* Maps depth values to 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.
*/
class DepthToColorsZucconi6Mapper : Filter(
filterShaderFromUrl(resourceUrl("depth-to-colors-zucconi6.frag", Kinects::class.java))
)
/**
* Maps depth values to 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.
*/
class DepthToColorsTurboMapper : Filter(
filterShaderFromUrl(resourceUrl("depth-to-colors-turbo.frag", Kinects::class.java))
)