mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-05 16:22:32 -08:00
Block AutoBone with high error values (#1185)
Co-authored-by: lucas lelievre <[email protected]>
This commit is contained in:
1 parent
449c6f80dc
commit
1a6560a9cf
6 files changed
+48
-77
No files matched your search
@@ -167,7 +167,7 @@ class AutoBone(server: VRServer) {
|
||||
// Otherwise if there is no skeleton available, attempt to get the
|
||||
// max HMD height from the recording
|
||||
val hmdHeight = frames.maxHmdHeight
|
||||
if (hmdHeight <= 0.4f) {
|
||||
if (hmdHeight <= MIN_HEIGHT) {
|
||||
LogManager
|
||||
.warning(
|
||||
"[AutoBone] Max headset height detected (Value seems too low, did you not stand up straight while measuring?): $hmdHeight",
|
||||
@@ -195,6 +195,9 @@ class AutoBone(server: VRServer) {
|
||||
config: AutoBoneConfig = globalConfig,
|
||||
epochCallback: Consumer<Epoch>? = null,
|
||||
): AutoBoneResults {
|
||||
check(frames.frameHolders.isNotEmpty()) { "Recording has no trackers." }
|
||||
check(frames.maxFrameCount > 0) { "Recording has no frames." }
|
||||
|
||||
// Load current values for adjustable configs
|
||||
loadConfigValues()
|
||||
|
||||
@@ -209,6 +212,7 @@ class AutoBone(server: VRServer) {
|
||||
} else {
|
||||
targetHmdHeight / BodyProportionError.eyeHeightToHeightRatio
|
||||
}
|
||||
check(targetHmdHeight > MIN_HEIGHT) { "Configured height ($targetHmdHeight) is too small (<= $MIN_HEIGHT)." }
|
||||
|
||||
// Set up the current state, making all required players and setting up the
|
||||
// skeletons appropriately
|
||||
@@ -316,6 +320,9 @@ class AutoBone(server: VRServer) {
|
||||
.info(
|
||||
"[AutoBone] Target height: ${trainingStep.targetHmdHeight}, Final height: $estimatedHeight",
|
||||
)
|
||||
if (trainingStep.errorStats.mean > config.maxFinalError) {
|
||||
throw AutoBoneException("The final epoch error value (${trainingStep.errorStats.mean}) has exceeded the maximum allowed value (${config.maxFinalError}).")
|
||||
}
|
||||
|
||||
return AutoBoneResults(
|
||||
estimatedHeight,
|
||||
@@ -746,6 +753,7 @@ class AutoBone(server: VRServer) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val MIN_HEIGHT = 0.4f
|
||||
const val AUTOBONE_FOLDER = "AutoBone Recordings"
|
||||
const val LOADAUTOBONE_FOLDER = "Load AutoBone Recordings"
|
||||
|
||||
|
||||
@@ -189,8 +189,8 @@ class AutoBoneHandler(private val server: VRServer) {
|
||||
if (framesFuture != null) {
|
||||
announceProcessStatus(AutoBoneProcessType.SAVE, "Waiting for recording...")
|
||||
val frames = framesFuture.get()
|
||||
check(frames.frameHolders.isNotEmpty()) { "Recording has no trackers" }
|
||||
check(frames.maxFrameCount > 0) { "Recording has no frames" }
|
||||
check(frames.frameHolders.isNotEmpty()) { "Recording has no trackers." }
|
||||
check(frames.maxFrameCount > 0) { "Recording has no frames." }
|
||||
announceProcessStatus(AutoBoneProcessType.SAVE, "Saving recording...")
|
||||
autoBone.saveRecording(frames)
|
||||
announceProcessStatus(
|
||||
@@ -243,8 +243,6 @@ class AutoBoneHandler(private val server: VRServer) {
|
||||
if (framesFuture != null) {
|
||||
announceProcessStatus(AutoBoneProcessType.PROCESS, "Waiting for recording...")
|
||||
val frames = framesFuture.get()
|
||||
check(frames.frameHolders.isNotEmpty()) { "Recording has no trackers" }
|
||||
check(frames.maxFrameCount > 0) { "Recording has no frames" }
|
||||
frameRecordings.add(Pair.of("<Recording>", frames))
|
||||
} else {
|
||||
announceProcessStatus(
|
||||
|
||||
@@ -26,4 +26,5 @@ class AutoBoneConfig {
|
||||
var useSkeletonHeight = false
|
||||
var randSeed = 4L
|
||||
var useFrameFiltering = false
|
||||
var maxFinalError = 0.03f
|
||||
}
|
||||
@@ -73,30 +73,26 @@ object PoseFrameIO {
|
||||
}
|
||||
}
|
||||
|
||||
fun tryWriteFrames(outputStream: DataOutputStream, frames: PoseFrames): Boolean {
|
||||
try {
|
||||
writeFrames(outputStream, frames)
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Error writing frame to stream", e)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
fun tryWriteFrames(outputStream: DataOutputStream, frames: PoseFrames): Boolean = try {
|
||||
writeFrames(outputStream, frames)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Error writing frame to stream.", e)
|
||||
false
|
||||
}
|
||||
|
||||
fun writeToFile(file: File, frames: PoseFrames) {
|
||||
DataOutputStream(
|
||||
BufferedOutputStream(FileOutputStream(file)),
|
||||
).use { outputStream -> writeFrames(outputStream, frames) }
|
||||
).use { writeFrames(it, frames) }
|
||||
}
|
||||
|
||||
fun tryWriteToFile(file: File, frames: PoseFrames): Boolean {
|
||||
try {
|
||||
writeToFile(file, frames)
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Error writing frames to file", e)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
fun tryWriteToFile(file: File, frames: PoseFrames): Boolean = try {
|
||||
writeToFile(file, frames)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Error writing frames to file.", e)
|
||||
false
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
@@ -166,27 +162,20 @@ object PoseFrameIO {
|
||||
return PoseFrames(trackers)
|
||||
}
|
||||
|
||||
fun tryReadFrames(inputStream: DataInputStream): PoseFrames? {
|
||||
return try {
|
||||
return readFrames(inputStream)
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Error reading frames from stream", e)
|
||||
null
|
||||
}
|
||||
fun tryReadFrames(inputStream: DataInputStream): PoseFrames? = try {
|
||||
readFrames(inputStream)
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Error reading frames from stream.", e)
|
||||
null
|
||||
}
|
||||
|
||||
fun readFromFile(file: File): PoseFrames = readFrames(
|
||||
DataInputStream(BufferedInputStream(FileInputStream(file))),
|
||||
)
|
||||
fun readFromFile(file: File): PoseFrames =
|
||||
DataInputStream(BufferedInputStream(FileInputStream(file))).use { readFrames(it) }
|
||||
|
||||
fun tryReadFromFile(file: File): PoseFrames? {
|
||||
return try {
|
||||
return readFrames(
|
||||
DataInputStream(BufferedInputStream(FileInputStream(file))),
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Error reading frames from file", e)
|
||||
null
|
||||
}
|
||||
fun tryReadFromFile(file: File): PoseFrames? = try {
|
||||
readFromFile(file)
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Error reading frames from file.", e)
|
||||
null
|
||||
}
|
||||
}
|
||||
@@ -83,12 +83,11 @@ class PoseRecorder(private val server: VRServer) {
|
||||
trackers: List<Tracker?> = server.allTrackers,
|
||||
frameCallback: Consumer<RecordingProgress>? = null,
|
||||
): Future<PoseFrames> {
|
||||
require(numFrames >= 1) { "numFrames must at least have a value of 1" }
|
||||
require(intervalMs >= 1) { "intervalMs must at least have a value of 1" }
|
||||
require(trackers.isNotEmpty()) { "trackers must have at least one entry" }
|
||||
check(isReadyToRecord) { "PoseRecorder isn't ready to record!" }
|
||||
require(numFrames >= 1) { "numFrames must at least have a value of 1." }
|
||||
require(intervalMs >= 1) { "intervalMs must at least have a value of 1." }
|
||||
require(trackers.isNotEmpty()) { "trackers must have at least one entry." }
|
||||
cancelFrameRecording()
|
||||
poseFrame = PoseFrames(trackers.size)
|
||||
val poseFrame = PoseFrames(trackers.size)
|
||||
|
||||
// Update tracker list
|
||||
this.trackers.ensureCapacity(trackers.size)
|
||||
@@ -100,12 +99,14 @@ class PoseRecorder(private val server: VRServer) {
|
||||
|
||||
// Create a tracker recording
|
||||
val trackerFrames = TrackerFrames(tracker, numFrames)
|
||||
poseFrame?.frameHolders?.add(trackerFrames)
|
||||
poseFrame.frameHolders.add(trackerFrames)
|
||||
|
||||
// Pair tracker with recording
|
||||
this.trackers.add(Pair.of(tracker, trackerFrames))
|
||||
}
|
||||
require(this.trackers.isNotEmpty()) { "trackers must have at least one valid tracker." }
|
||||
|
||||
this.poseFrame = poseFrame
|
||||
frameCursor = 0
|
||||
this.numFrames = numFrames
|
||||
frameRecordingInterval = intervalMs
|
||||
|
||||
Reference in new issue
Block a user