mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
bug fix
This commit is contained in:
parent
404f1b13f2
commit
3f859440c0
@ -298,12 +298,12 @@ class CameraWidget:
|
|||||||
graph.update(background_color="white")
|
graph.update(background_color="white")
|
||||||
|
|
||||||
if eye_info.y < 0: # flip visualzation to be correct
|
if eye_info.y < 0: # flip visualzation to be correct
|
||||||
eye_info.y = abs(eye_info.y)
|
visy = abs(eye_info.y)
|
||||||
elif eye_info.y >= 0:
|
elif eye_info.y >= 0:
|
||||||
eye_info.y = -abs(eye_info.y)
|
visy = -abs(eye_info.y)
|
||||||
|
|
||||||
graph.draw_circle(
|
graph.draw_circle(
|
||||||
(eye_info.x * -100, eye_info.y * -100),
|
(eye_info.x * -100, visy * -100),
|
||||||
25,
|
25,
|
||||||
fill_color="black",
|
fill_color="black",
|
||||||
line_color="white",
|
line_color="white",
|
||||||
|
|||||||
@ -149,6 +149,8 @@ class EyeProcessor:
|
|||||||
|
|
||||||
# Cross algo state
|
# Cross algo state
|
||||||
self.lkg_projected_sphere = None
|
self.lkg_projected_sphere = None
|
||||||
|
self.xc = None
|
||||||
|
self.yc = None
|
||||||
|
|
||||||
# Image state
|
# Image state
|
||||||
self.previous_image = None
|
self.previous_image = None
|
||||||
@ -175,7 +177,7 @@ class EyeProcessor:
|
|||||||
|
|
||||||
|
|
||||||
min_cutoff = 0.0004
|
min_cutoff = 0.0004
|
||||||
beta = 0.7
|
beta = 0.9
|
||||||
noisy_point = np.array([1, 1])
|
noisy_point = np.array([1, 1])
|
||||||
self.one_euro_filter = OneEuroFilter(
|
self.one_euro_filter = OneEuroFilter(
|
||||||
noisy_point,
|
noisy_point,
|
||||||
@ -254,11 +256,37 @@ class EyeProcessor:
|
|||||||
|
|
||||||
def blob_tracking_fallback(self):
|
def blob_tracking_fallback(self):
|
||||||
|
|
||||||
|
|
||||||
|
# define circle
|
||||||
|
try:
|
||||||
|
ht, wd = self.current_image_gray.shape[:2]
|
||||||
|
radius = int(float(self.lkg_projected_sphere["axes"][0]))
|
||||||
|
|
||||||
|
|
||||||
|
# draw filled circle in white on black background as mask
|
||||||
|
mask = np.zeros((ht,wd), dtype=np.uint8)
|
||||||
|
mask = cv2.circle(mask, (self.xc,self.yc), radius, 255, -1)
|
||||||
|
|
||||||
|
# create white colored background
|
||||||
|
color = np.full_like(self.current_image_gray, (255))
|
||||||
|
|
||||||
|
# apply mask to image
|
||||||
|
masked_img = cv2.bitwise_and(self.current_image_gray, self.current_image_gray, mask=mask)
|
||||||
|
|
||||||
|
# apply inverse mask to colored image
|
||||||
|
masked_color = cv2.bitwise_and(color, color, mask=255-mask)
|
||||||
|
|
||||||
|
# combine the two masked images
|
||||||
|
self.current_image_gray = cv2.add(masked_img, masked_color)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Increase our threshold value slightly, in order to have a better possibility of getting back
|
# Increase our threshold value slightly, in order to have a better possibility of getting back
|
||||||
# something to do blob tracking on.
|
# something to do blob tracking on.
|
||||||
_, larger_threshold = cv2.threshold(
|
_, larger_threshold = cv2.threshold(
|
||||||
self.current_image_gray,
|
self.current_image_gray,
|
||||||
int(self.config.threshold + 20),
|
int(self.config.threshold + 15),
|
||||||
255,
|
255,
|
||||||
cv2.THRESH_BINARY,
|
cv2.THRESH_BINARY,
|
||||||
)
|
)
|
||||||
@ -274,29 +302,7 @@ class EyeProcessor:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# define circle
|
|
||||||
try:
|
|
||||||
ht, wd = self.current_image_gray.shape[:2]
|
|
||||||
radius = int(float(self.lkg_projected_sphere["axes"][0]))
|
|
||||||
xc = yc = radius
|
|
||||||
|
|
||||||
# draw filled circle in white on black background as mask
|
|
||||||
mask = np.zeros((ht,wd), dtype=np.uint8)
|
|
||||||
mask = cv2.circle(mask, (xc,yc), radius, 255, -1)
|
|
||||||
|
|
||||||
# create white colored background
|
|
||||||
color = np.full_like(self.current_image_gray, (255))
|
|
||||||
|
|
||||||
# apply mask to image
|
|
||||||
masked_img = cv2.bitwise_and(self.current_image_gray, self.current_image_gray, mask=mask)
|
|
||||||
|
|
||||||
# apply inverse mask to colored image
|
|
||||||
masked_color = cv2.bitwise_and(color, color, mask=255-mask)
|
|
||||||
|
|
||||||
# combine the two masked images
|
|
||||||
self.current_image_gray = cv2.add(masked_img, masked_color)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -321,10 +327,12 @@ class EyeProcessor:
|
|||||||
# if our blob width/height are within suitable (yet arbitrary) boundaries, call that good.
|
# if our blob width/height are within suitable (yet arbitrary) boundaries, call that good.
|
||||||
#
|
#
|
||||||
# TODO This should be scaled based on camera resolution.
|
# TODO This should be scaled based on camera resolution.
|
||||||
if not 6 <= h <= 25 or not 6 <= w <= 25:
|
if not 10 <= h <= 25 or not 10 <= w <= 25:
|
||||||
continue
|
continue
|
||||||
cx = x + int(w / 2)
|
cx = x + int(w / 2)
|
||||||
|
|
||||||
cy = y + int(h / 2)
|
cy = y + int(h / 2)
|
||||||
|
|
||||||
xrlb = (
|
xrlb = (
|
||||||
cx - self.lkg_projected_sphere["center"][0]
|
cx - self.lkg_projected_sphere["center"][0]
|
||||||
) / self.lkg_projected_sphere["axes"][0]
|
) / self.lkg_projected_sphere["axes"][0]
|
||||||
@ -364,19 +372,12 @@ class EyeProcessor:
|
|||||||
self.xmin = cx
|
self.xmin = cx
|
||||||
if cy> self.ymax:
|
if cy> self.ymax:
|
||||||
self.ymax = cy
|
self.ymax = cy
|
||||||
if cy < self.xmin:
|
if cy < self.ymin:
|
||||||
self.ymin = cy
|
self.ymin = cy
|
||||||
self.calibration_frame_counter -= 1
|
self.calibration_frame_counter -= 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
noisy_point = np.array([cx, cy]) #fliter our values with a One Euro Filter
|
|
||||||
point_hat = self.one_euro_filter(noisy_point)
|
|
||||||
cx = point_hat[0]
|
|
||||||
cy = point_hat[1]
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
xl = float(
|
xl = float(
|
||||||
((cx - self.xoff)) / (self.xmax - self.xoff)
|
((cx - self.xoff)) / (self.xmax - self.xoff)
|
||||||
@ -391,7 +392,7 @@ class EyeProcessor:
|
|||||||
((cy - self.yoff)) / (self.ymax - self.yoff)
|
((cy - self.yoff)) / (self.ymax - self.yoff)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# print(self.)
|
||||||
out_x = 0
|
out_x = 0
|
||||||
out_y = 0
|
out_y = 0
|
||||||
if xr > 0:
|
if xr > 0:
|
||||||
@ -403,6 +404,15 @@ class EyeProcessor:
|
|||||||
if yu > 0:
|
if yu > 0:
|
||||||
out_y = -abs(max(0.0, min(1.0, yu)))
|
out_y = -abs(max(0.0, min(1.0, yu)))
|
||||||
|
|
||||||
|
try:
|
||||||
|
noisy_point = np.array([out_x, out_y]) #fliter our values with a One Euro Filter
|
||||||
|
point_hat = self.one_euro_filter(noisy_point)
|
||||||
|
out_x = point_hat[0]
|
||||||
|
out_y = point_hat[1]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.output_images_and_update(
|
self.output_images_and_update(
|
||||||
@ -504,12 +514,12 @@ class EyeProcessor:
|
|||||||
|
|
||||||
radius = int(float(self.lkg_projected_sphere["axes"][0]))
|
radius = int(float(self.lkg_projected_sphere["axes"][0]))
|
||||||
|
|
||||||
xc = int(self.lkg_projected_sphere["center"][0])
|
self.xc = int(self.lkg_projected_sphere["center"][0])
|
||||||
yc = int(self.lkg_projected_sphere["center"][1])
|
self.yc = int(self.lkg_projected_sphere["center"][1])
|
||||||
|
|
||||||
# draw filled circle in white on black background as mask
|
# draw filled circle in white on black background as mask
|
||||||
mask = np.zeros((ht,wd), dtype=np.uint8)
|
mask = np.zeros((ht,wd), dtype=np.uint8)
|
||||||
mask = cv2.circle(mask, (xc,yc), radius, 255, -1)
|
mask = cv2.circle(mask, (self.xc,self.yc), radius, 255, -1)
|
||||||
|
|
||||||
# create white colored background
|
# create white colored background
|
||||||
color = np.full_like(self.current_image_gray, (255))
|
color = np.full_like(self.current_image_gray, (255))
|
||||||
@ -608,25 +618,25 @@ class EyeProcessor:
|
|||||||
self.recenter_eye = False
|
self.recenter_eye = False
|
||||||
self.xoff = exm
|
self.xoff = exm
|
||||||
self.yoff = eym
|
self.yoff = eym
|
||||||
elif self.calibration_frame_counter != None:
|
elif self.calibration_frame_counter != None: # TODO reset calibration values on button press
|
||||||
if exm > self.xmax:
|
if exm > self.xmax:
|
||||||
self.xmax = exm
|
self.xmax = exm
|
||||||
if exm < self.xmin:
|
if exm < self.xmin:
|
||||||
self.xmin = exm
|
self.xmin = exm
|
||||||
if eym > self.ymax:
|
if eym > self.ymax:
|
||||||
self.ymax = eym
|
self.ymax = eym
|
||||||
if eym < self.xmin:
|
if eym < self.ymin:
|
||||||
self.ymin = eym
|
self.ymin = eym
|
||||||
|
print(eym, self.ymin, self.ymax)
|
||||||
self.calibration_frame_counter -= 1
|
self.calibration_frame_counter -= 1
|
||||||
eye_position_scalar = self.config.vrc_eye_position_scalar
|
|
||||||
|
#print(self.yoff)
|
||||||
|
|
||||||
|
|
||||||
|
# noisy_point = np.array([cx, cy]) #fliter our values with a One Euro Filter
|
||||||
|
# point_hat = self.one_euro_filter(noisy_point)
|
||||||
noisy_point = np.array([cx, cy]) #fliter our values with a One Euro Filter
|
# cx = point_hat[0]
|
||||||
point_hat = self.one_euro_filter(noisy_point)
|
# cy = point_hat[1]
|
||||||
cx = point_hat[0]
|
|
||||||
cy = point_hat[1]
|
|
||||||
|
|
||||||
|
|
||||||
xl = float(
|
xl = float(
|
||||||
@ -657,6 +667,16 @@ class EyeProcessor:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
noisy_point = np.array([out_x, out_y]) #fliter our values with a One Euro Filter
|
||||||
|
point_hat = self.one_euro_filter(noisy_point)
|
||||||
|
out_x = point_hat[0]
|
||||||
|
out_y = point_hat[1]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# print(cy, self.yoff, self.ymin, self.ymax, out_y)
|
||||||
|
# print(out_y, yu, yd)
|
||||||
|
|
||||||
output_info = EyeInformation(InformationOrigin.RANSAC, out_x, out_y, out_pupil_dialation, False)
|
output_info = EyeInformation(InformationOrigin.RANSAC, out_x, out_y, out_pupil_dialation, False)
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
# -*- mode: py -3.6 ; coding: utf-8 -*-
|
# -*- mode: py -3.6 ; coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
block_cipher = None
|
block_cipher = None
|
||||||
|
|
||||||
|
|
||||||
@ -24,7 +23,7 @@ exe = EXE(pyz,
|
|||||||
a.scripts,
|
a.scripts,
|
||||||
[],
|
[],
|
||||||
exclude_binaries=True,
|
exclude_binaries=True,
|
||||||
name='EyeTrackApp',
|
name='eyetrackapp',
|
||||||
debug=False,
|
debug=False,
|
||||||
bootloader_ignore_signals=False,
|
bootloader_ignore_signals=False,
|
||||||
strip=False,
|
strip=False,
|
||||||
@ -41,4 +40,4 @@ coll = COLLECT(exe,
|
|||||||
strip=False,
|
strip=False,
|
||||||
upx=True,
|
upx=True,
|
||||||
upx_exclude=[],
|
upx_exclude=[],
|
||||||
name='eyetrackapp')
|
name='EyeTrackApp')
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 174 KiB |
Loading…
Reference in New Issue
Block a user