Skip to content

Commit

Permalink
0.11.3
Browse files Browse the repository at this point in the history
  • Loading branch information
tattn committed Oct 26, 2023
1 parent c4181d0 commit 4f1ca14
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/xcode/Sources/VCamLocalization/Generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ public enum L10n {
public static let moveInitialPosition = LocalizedString(lookupKey: "moveInitialPosition")
/// New preset
public static let newPreset = LocalizedString(lookupKey: "newPreset")
/// New Tracking System
public static let newTrackingSystem = LocalizedString(lookupKey: "newTrackingSystem")
/// No
public static let no = LocalizedString(lookupKey: "no")
/// Nod
Expand Down Expand Up @@ -476,6 +474,8 @@ public enum L10n {
}
/// Use vowel estimation by camera
public static let useVowelEstimation = LocalizedString(lookupKey: "useVowelEstimation")
/// VCam Tracking 2.0 (New Tracking System)
public static let vcamTrackingV2 = LocalizedString(lookupKey: "vcamTrackingV2")
/// Video Capture
public static let videoCapture = LocalizedString(lookupKey: "videoCapture")
/// Video Capture Device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"experimentThanks" = "These features are available for our supporters, thank you for your supporting!";
"experimentAdvertisement" = "The supporter version of the app can be downloaded from the following link:";
"enableVSync" = "Enable VSync";
"newTrackingSystem" = "New Tracking System";
"vcamTrackingV2" = "VCam Tracking 2.0 (New Tracking System)";
"installVirtualCamera" = "Install the Virtual Camera";
"explainAboutInstallingCameraExtension" = "Installing the virtual camera.\nClick on 'Open Security Preferences' and then click 'Allow'.";
"noteEnableNewCameraExtension" = "Restart VCam once after installation.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"experimentThanks" = "これらの機能はサポーター向けに提供しています。VCamのサポート、ありがとうございます!";
"experimentAdvertisement" = "これらの機能はサポーター向けに提供しています。サポーター版は以下からDLできます。";
"enableVSync" = "VSyncを有効にする";
"newTrackingSystem" = "新しいトラッキングシステム";
"vcamTrackingV2" = "VCamトラッキング2.0 (新しいトラッキングシステム)";
"installVirtualCamera" = "仮想カメラのインストール";
"explainAboutInstallingCameraExtension" = "仮想カメラをインストールします。\n「システム設定を開く」をクリックして、「許可」をクリックしてください。";
"noteEnableNewCameraExtension" = "インストール後は一度VCamを再起動してください";
Expand Down
5 changes: 1 addition & 4 deletions app/xcode/Sources/VCamTracking/FaceTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ public final class FaceTracker {
}
}

private extension VNImageBasedRequest {
private static let expectedRegionOfInterest = CGRect(x: 0.1, y: 0.2, width: 0.8, height: 0.7)

private extension VNImageBasedRequest {
func configureForPerformance() {
regionOfInterest = Self.expectedRegionOfInterest
preferBackgroundProcessing = true
}
}
2 changes: 1 addition & 1 deletion app/xcode/Sources/VCamTracking/HeadPoseEstimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public protocol HeadPoseEstimator {
public final class VisionHeadPoseEstimator: HeadPoseEstimator {
private var size = CGSize(width: 1024, height: 512)
private var prevPos = SIMD3<Float>(repeating: 0)
private var prevPitchYawRoll = RevisedMovingAverage<SIMD3<Float>>(weight: .custom(count: 9, weight: 60))
private var prevPitchYawRoll = RevisedMovingAverage<SIMD3<Float>>(weight: .custom(count: 12, weight: 60))

public init() {}

Expand Down
13 changes: 6 additions & 7 deletions app/xcode/Sources/VCamTracking/RevisedMovingAverage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extension SIMD4<Float>: RevisedMovingAverageValue {}
public struct RevisedMovingAverage<Value: RevisedMovingAverageValue> {
private let weights: [Float]
private var previousValues: [Value]
private let count: Int

private var latestValueIndex: Int
private let valueRange: Range<Int>
Expand All @@ -32,23 +33,21 @@ public struct RevisedMovingAverage<Value: RevisedMovingAverageValue> {

public init(weight: RevisedMovingAverageWeight) {
weights = weight.weights
previousValues = Array(repeating: .zero, count: weights.count)
count = weights.count
previousValues = Array(repeating: .zero, count: count)
latestValueIndex = previousValues.count - 1
valueRange = 0..<previousValues.count
}

public mutating func appending(_ newValue: Value) -> Value {
// https://www.jstage.jst.go.jp/article/kakoronbunshu1975/24/4/24_4_686/_pdf

let nextValueIndex = (latestValueIndex + 1) % previousValues.count
defer {
latestValueIndex = nextValueIndex
}

let nextValueIndex = (latestValueIndex + 1) % count
previousValues[latestValueIndex] = newValue
latestValueIndex = nextValueIndex

return valueRange.reduce(Value.zero) { partialResult, index in
partialResult + previousValues[(nextValueIndex + index) % previousValues.count] * weights[index]
partialResult + previousValues[(nextValueIndex + index) % count] * weights[index]
}
}

Expand Down
4 changes: 3 additions & 1 deletion app/xcode/Sources/VCamTracking/VCamMotionReceiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public final class VCamMotionReceiver {
@MainActor
public func start(avatar: Avatar) async throws {
Logger.log("")
stop()

connectionStatus = .connecting
let parameters = NWParameters.udp
parameters.allowLocalEndpointReuse = true
Expand Down Expand Up @@ -74,7 +76,7 @@ public final class VCamMotionReceiver {
}

@MainActor
public func stop() async {
public func stop() {
guard let listener = listener else { return }
listener.cancel()
self.listener = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public struct VCamSettingsIntegrationView: View {
if newValue {
try await Tracking.shared.vcamMotionReceiver.start(avatar: Tracking.shared.avatar)
} else {
await Tracking.shared.vcamMotionReceiver.stop()
Tracking.shared.vcamMotionReceiver.stop()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ private extension Binding {
// The state updates with a slight delay, so wait a bit before refreshing the UI
func workaround() -> Self {
map(get: { $0 }, set: {
Task {
try? await Task.sleep(nanoseconds: NSEC_PER_MSEC * 300)
UniReload.Reloader.shared.objectWillChange.send()
}
UniReload.Reloader.shared.objectWillChange.send()
return $0
})
}
Expand Down
8 changes: 6 additions & 2 deletions app/xcode/Sources/VCamUI/VCamSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Tatsuya Tanaka on 2023/02/25.
//

import Foundation
import AppKit
import VCamAppExtension
import VCamBridge
import VCamTracking
Expand All @@ -21,7 +21,11 @@ public final class VCamSystem {
public let pasteboardObserver = PasteboardObserver()

public private(set) var isStarted = false
public var isUniVCamSystemEnabled = false
public var isUniVCamSystemEnabled = false {
didSet {
NSApp.vcamWindow?.backgroundColor = isUniVCamSystemEnabled ? .clear : .windowBackgroundColor
}
}

private init() {
ExtensionNotificationCenter.default.setObserver(for: .startCameraExtensionStream) { [weak self] in
Expand Down

0 comments on commit 4f1ca14

Please sign in to comment.