4 Commits
1.0.0 ... 1.1.1

Author SHA1 Message Date
5758bc9bb3 Removed unused variable 2026-06-04 17:32:08 +01:00
8e95850105 Removed timeouts in OSC server / client (something something Windows is a bitch baby) 2026-06-04 17:28:25 +01:00
aedbd87480 Fixed #3 2026-06-04 17:26:06 +01:00
1b1cbf5aa4 Fixed #4 2026-06-04 17:17:50 +01:00
2 changed files with 21 additions and 14 deletions

View File

@ -41,16 +41,7 @@ class NewPictureHandler(watchdog.events.FileSystemEventHandler):
if not isinstance(event, watchdog.events.FileCreatedEvent): if not isinstance(event, watchdog.events.FileCreatedEvent):
return return
# Ignore multi layer images # Update last closed (can't use on_closed(), see #4).
for layer in ['_Environment', '_Player', '_UI']:
if layer in os.path.basename(event.src_path):
return
timeGap = time.perf_counter() - self._lastPicture
Thread(target=self._callback, args=(event.src_path, timeGap)).start()
self._lastPicture = time.perf_counter()
def on_closed(self, event: watchdog.events.FileSystemEvent) -> None:
exExt = '.'.join(event.src_path.split('.')[:-1]) exExt = '.'.join(event.src_path.split('.')[:-1])
if exExt.endswith('_Environment'): if exExt.endswith('_Environment'):
@ -64,6 +55,15 @@ class NewPictureHandler(watchdog.events.FileSystemEventHandler):
self.lastClosedTime = time.perf_counter() self.lastClosedTime = time.perf_counter()
# Ignore multi layer images
for layer in ['_Environment', '_Player', '_UI']:
if layer in os.path.basename(event.src_path):
return
timeGap = time.perf_counter() - self._lastPicture
Thread(target=self._callback, args=(event.src_path, timeGap)).start()
self._lastPicture = time.perf_counter()
def createNewPictureObserver(callback: callable) -> Observer: def createNewPictureObserver(callback: callable) -> Observer:
""" """
Creates an Observer that watches the VRChat pictures folder and calls callback Creates an Observer that watches the VRChat pictures folder and calls callback
@ -168,7 +168,7 @@ class Camera:
if time.perf_counter() - st > timeout: if time.perf_counter() - st > timeout:
raise TimeoutError() raise TimeoutError()
def _newPicture(self, _, timeGap: float): def _newPicture(self, *_):
self.lastPicture = time.perf_counter() self.lastPicture = time.perf_counter()
if self._multiPictureOngoing: if self._multiPictureOngoing:
@ -188,13 +188,20 @@ class Camera:
# Wait until the camera is ready # Wait until the camera is ready
self._waitForCameraReady() self._waitForCameraReady()
time.sleep(0.75) time.sleep(0.75)
# Check the camera mode, and see if it's disabled
if self._lastMode == 0:
# If so, break out of the loop.
print('Camera disabled. Bailing out.')
break
# Take a new picture # Take a new picture
self.oscClient.send_message('/usercamera/Capture', True) self.oscClient.send_message('/usercamera/Capture', True)
# Reset the lastPicture time, the set that happens at the start of this # Reset the lastPicture time, the set that happens at the start of this
# function is not fast enough and causes race conditions. # function is not fast enough and causes race conditions.
self.lastPicture = time.perf_counter() self.lastPicture = time.perf_counter()
# Wait for the camera to be ready one last time to prevent a cycle # Wait for the camera to be ready one last time to prevent a cycle
self._waitForCameraReady() # but only if the camera is still enabled.
if self._lastMode != 0:
self._waitForCameraReady()
except TimeoutError: except TimeoutError:
print('WARNING: Timeout occured during multishot. Bailing out.') print('WARNING: Timeout occured during multishot. Bailing out.')

View File

@ -37,12 +37,12 @@ with open('cameraOverrides.json', 'r', encoding='utf-8') as f:
clientIP = os.environ.get('VRCCO_OSCClientBind', '127.0.0.1') clientIP = os.environ.get('VRCCO_OSCClientBind', '127.0.0.1')
clientPort = int(os.environ.get('VRCCO_OSCClientPort', 9000)) clientPort = int(os.environ.get('VRCCO_OSCClientPort', 9000))
client = udp_client.SimpleUDPClient(clientIP, clientPort, timeout=2.5) client = udp_client.SimpleUDPClient(clientIP, clientPort)
dispatcher = Dispatcher() dispatcher = Dispatcher()
serverIP = os.environ.get('VRCCO_OSCServerBind', '127.0.0.1') serverIP = os.environ.get('VRCCO_OSCServerBind', '127.0.0.1')
serverPort = int(os.environ.get('VRCCO_OSCServerPort', 9001)) serverPort = int(os.environ.get('VRCCO_OSCServerPort', 9001))
server = osc_server.ThreadingOSCUDPServer((serverIP, serverPort), dispatcher, timeout=2.5) server = osc_server.ThreadingOSCUDPServer((serverIP, serverPort), dispatcher)
camera = Camera(dispatcher, client, onCameraEnabled) camera = Camera(dispatcher, client, onCameraEnabled)
camera.additionalPictures = 2 camera.additionalPictures = 2