mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-09-26 23:09:28 +08:00

* initial changes * Mostly clean up, refactor registering listeners to make sense, backport tests * Add initial implementation of VRCFTModuleSender * Add basic GUI for the modules settings * Fix tooltip descriptions # TODO: # - there's ghosts in the machine - vrc osc is not working properly # - min/maxing will require field combinators in the modules lmao * Fix type validation bugs, fix typos # TODO: # - there's ghosts in the machine - vrc osc is not working properly # - min/maxing will require field combinators in the modules lmao * Add checkbox to switch to ETVR Module # TODO: # - there's ghosts in the machine - vrc osc is not working properly # - min/maxing will require field combinators in the modules lmao * Black stuff # TODO: # - there's ghosts in the machine - vrc osc is not working properly # - min/maxing will require field combinators in the modules lmao * Remove coverage by default # TODO: # - there's ghosts in the machine - vrc osc is not working properly # - min/maxing will require field combinators in the modules lmao * Fix timeout in tests # TODO: # - there's ghosts in the machine - vrc osc is not working properly # - min/maxing will require field combinators in the modules lmao * HEAVY WIP: Refactor native output, NOTE: I brought back the entire old OSC implementation as a live reference, this will be removed once I'm done. This also lays ground for other modes as they're pretty similar # TODO: # - there's ghosts in the machine - vrc osc is not working properly # - min/maxing will require field combinators in the modules lmao * HEAVY WIP: Refactor v1 params output, # TODO: # - min/maxing will require field combinators in the modules lmao * HEAVY WIP: Refactor v2 params output # TODO: # - min/maxing will require field combinators in the modules lmao * Finish refactoring v2 and v1, fixup tests, refactor native # TODO: # - min/maxing will require field combinators in the modules lmao * Add tests for v1 params # TODO: # - min/maxing will require field combinators in the modules lmao * Add tests for native params # TODO: # - min/maxing will require field combinators in the modules lmao * Fix OSC not getting up after config reset. Remove reset command, config sends everything changed anyway, sunset the idea of using single client and thus simplify the code a bit # TODO: # - min/maxing will require field combinators in the modules lmao * Rename gui_PortNumber to gui_VRCFTModulePort for readability # TODO: # - min/maxing will require field combinators in the modules lmao * Cleanup EyeID usage # TODO: # - min/maxing will require field combinators in the modules lmao * Cleanup osc after rebase # TODO: # - min/maxing will require field combinators in the modules lmao * Make VRChatOSCSender a bit more readable # TODO: # - min/maxing will require field combinators in the modules lmao * Remove unsued VRChatOSCReceiver, this is taken care of by generic OSCReceiver # TODO: # - min/maxing will require field combinators in the modules lmao * Commit crimes with try_convert_to_float to make osc, pysimplegui and pydantic happy * Cleanup after merge * Disable emulation by default * Fix OSCReceiver crashing on unknown addresses * Adjust VRCFT Module settings to look better in game * Fix recalibrate and recenter for OSC only working for the right eye * Fix save and restart button not restarting the tracking * Fix broken tracking on v1 params for eye_x, clean up implementation * Fix regular value being passed to OSC listeners instead of OSCMessage * Add a TODO, probably to be ignored * Add support for custom ETVR VRCFT Module listening address
83 lines
3.7 KiB
Python
83 lines
3.7 KiB
Python
"""
|
|
------------------------------------------------------------------------------------------------------
|
|
|
|
,@@@@@@
|
|
@@@@@@@@@@@ @@@
|
|
@@@@@@@@@@@@ @@@@@@@@@@@
|
|
@@@@@@@@@@@@@ @@@@@@@@@@@@@@
|
|
@@@@@@@/ ,@@@@@@@@@@@@@
|
|
/@@@@@@@@@@@@@@@ @@@@@@@@
|
|
@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@
|
|
@@@@@@@@ @@@@@
|
|
,@@@ @@@@&
|
|
@@@@@@. @@@@
|
|
@@@ @@@@@@@@@/ @@@@@
|
|
,@@@. @@@@@@((@ @@@@(
|
|
//@@@ ,, @@@@ @@@@@
|
|
@@@( @@@@@@@
|
|
@@@ @ @@@@@@@@#
|
|
@@@@@@@@@@@@@@@@@
|
|
@@@@@@@@@@@@@(
|
|
|
|
BLOB By: Prohurtz
|
|
Algorithm App Implimentations By: Prohurtz, qdot (Inital App Creator)
|
|
|
|
Copyright (c) 2023 EyeTrackVR <3
|
|
LICENSE: GNU GPLv3
|
|
------------------------------------------------------------------------------------------------------
|
|
"""
|
|
|
|
import cv2
|
|
|
|
|
|
def BLOB(self):
|
|
global cct
|
|
# define circle
|
|
_, larger_threshold = cv2.threshold(
|
|
self.current_image_gray,
|
|
int(self.settings.gui_threshold),
|
|
255,
|
|
cv2.THRESH_BINARY,
|
|
)
|
|
|
|
try:
|
|
# Try rebuilding our contours
|
|
contours, _ = cv2.findContours(
|
|
larger_threshold, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE
|
|
)
|
|
contours = sorted(contours, key=lambda x: cv2.contourArea(x), reverse=True)
|
|
|
|
# If we have no contours, we have nothing to blob track. Fail here.
|
|
if len(contours) == 0:
|
|
raise RuntimeError("No contours found for image")
|
|
except:
|
|
self.failed = self.failed + 1
|
|
pass
|
|
|
|
rows, cols = larger_threshold.shape
|
|
|
|
for cnt in contours:
|
|
(x, y, w, h) = cv2.boundingRect(cnt)
|
|
|
|
# if our blob width/height are within boundaries, call that good.
|
|
|
|
if (
|
|
not self.settings.gui_blob_minsize <= h <= self.settings.gui_blob_maxsize
|
|
or not self.settings.gui_blob_minsize <= w <= self.settings.gui_blob_maxsize
|
|
):
|
|
continue
|
|
|
|
cx = x + int(w / 2)
|
|
cy = y + int(h / 2)
|
|
|
|
cv2.drawContours(self.current_image_gray, [cnt], -1, (0, 0, 0), 3)
|
|
cv2.rectangle(self.current_image_gray, (x, y), (x + w, y + h), (0, 0, 0), 2)
|
|
|
|
# out_x, out_y = cal_osc(self, cx, cy) #filter and calibrate values
|
|
|
|
self.failed = 0
|
|
return cx, cy, larger_threshold
|
|
|
|
self.failed = self.failed + 1
|
|
return 0, 0, larger_threshold
|