NativeFreenectCommandsDemo shows how to retrieve a value from native kinect call

This commit is contained in:
Kazik Pogoda
2019-08-26 10:09:08 +02:00
parent 2860778cb0
commit c6639611c2

View File

@@ -4,6 +4,7 @@ import org.bytedeco.libfreenect.global.freenect
import org.bytedeco.libfreenect.global.freenect.* import org.bytedeco.libfreenect.global.freenect.*
import org.openrndr.application import org.openrndr.application
import org.openrndr.extra.kinect.v1.getKinectsV1 import org.openrndr.extra.kinect.v1.getKinectsV1
import java.lang.RuntimeException
/** /**
* Even though this library is abstracting freenect access, it is still * Even though this library is abstracting freenect access, it is still
@@ -14,6 +15,9 @@ import org.openrndr.extra.kinect.v1.getKinectsV1
fun main() = application { fun main() = application {
program { program {
val kinects = getKinectsV1(this) val kinects = getKinectsV1(this)
// the same as calling kinects.countDevices(), here to show that any value might be returned from execute
val num = kinects.execute { ctx -> freenect_num_devices(ctx.fnCtx) }
if (num == 0) { throw RuntimeException("no kinect detected") }
kinects.execute { ctx -> kinects.execute { ctx ->
freenect_set_log_level(ctx.fnCtx, freenect.FREENECT_LOG_FLOOD) // lots of logs freenect_set_log_level(ctx.fnCtx, freenect.FREENECT_LOG_FLOOD) // lots of logs
} }