Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
millcake666 committed Nov 6, 2023
1 parent fe29cef commit 0a617f6
Show file tree
Hide file tree
Showing 67 changed files with 102 additions and 50 deletions.
Binary file removed logo/2.png
Binary file not shown.
Binary file added logo_new/1961573f-da31-466c-8d36-3a089e66c603.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/2b76e105-5251-4c0e-9540-10c5d918af6f.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/35eec83d-1995-499d-995c-72e82fda5a9d.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/4577ea66-3435-479e-9588-2de6675d3ef0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/70b742dd-1f24-4ac1-b6e8-157dff49948a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/7f0602f6-f7ba-40a8-8d53-3f3cb9949700.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/819cfe86-cf75-43c5-9ca3-0beedbd38dee.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/846fbb55-979c-4a43-adb5-d000ab3f63e5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/89c95b02ab6241e8aeeb3d96.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/8ed37724-73ef-405b-8750-24fbcd83e24d.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/9428fdac-0653-41b4-ae32-b2df13326afa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/a8abd0b4-2880-4118-9a35-4c5416e99867.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/b60a8cec-aee0-4dbf-8a1f-9082046dbd0f.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/c52521bf-a137-4ba3-8f8b-95436d9c6949.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/d17a075f-7db3-4f00-92aa-6258523db0fa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/d7141c6f-72e4-44ad-9ef3-34563bbc794c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/d93eaf56-1e49-434b-be48-8d09c5392353.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/d9d1ddbb-6b4f-4b8f-a2cc-cec90d5c027b.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/e901f7df61f2486c913899f5.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/ee15603e6115479ea53d3a91.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/Снимок.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/Снимок10.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/Снимок11.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo_new/Снимок111.JPG
Binary file added logo_new/Снимок14.JPG
Binary file added logo_new/Снимок2.JPG
Binary file added logo_new/Снимок4.JPG
Binary file added logo_new/Снимок5.JPG
Binary file added logo_new/Снимок6.JPG
Binary file added logo_new/Снимок8.JPG
Binary file added logo_new/Снимок9.JPG
Binary file added logo_new_scaled/89c95b02ab6241e8aeeb3d96.jpeg
Binary file added logo_new_scaled/e901f7df61f2486c913899f5.jpeg
Binary file added logo_new_scaled/ee15603e6115479ea53d3a91.jpeg
Binary file added logo_new_scaled/Снимок.JPG
Binary file added logo_new_scaled/Снимок10.JPG
Binary file added logo_new_scaled/Снимок11.JPG
Binary file added logo_new_scaled/Снимок111.JPG
Binary file added logo_new_scaled/Снимок14.JPG
Binary file added logo_new_scaled/Снимок2.JPG
Binary file added logo_new_scaled/Снимок4.JPG
Binary file added logo_new_scaled/Снимок5.JPG
Binary file added logo_new_scaled/Снимок6.JPG
Binary file added logo_new_scaled/Снимок8.JPG
Binary file added logo_new_scaled/Снимок9.JPG
137 changes: 87 additions & 50 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,100 @@
from time import perf_counter
from os import walk
from random import randint
import numpy as np

gaze = GazeTracking()
webcam = cv2.VideoCapture(0)

mypath = r'logo'
filenames = list(walk(mypath))[0][2]
time_to_show = 1 # sec

dir_path = r'logo_new_scaled'
filenames = list(walk(dir_path))[0][2]
print(filenames)
logos_time = [0] * len(filenames)
time_old = perf_counter()
photos_shows = []

for i in range(5):
r1 = randint(0, len(filenames))
r2 = randint(0, len(filenames))
while True:
if r1 not in photos_shows:
photos_shows.append(r1)
break
r1 = randint(0, len(filenames))
while True:
if r2 not in photos_shows:
photos_shows.append(r2)
break
r2 = randint(0, len(filenames))

image1 = cv2.imread(filenames[r1])
image2 = cv2.imread(filenames[r2])
while True:
# We get a new frame from the webcam
_, frame = webcam.read()
# We send this frame to GazeTracking to analyze it
gaze.refresh(frame)
frame = gaze.annotated_frame()

pos = gaze.horizontal_ratio()
print(pos)

if pos is None:
# "Blinking"
pass
elif pos <= 0.6:
# "Looking right"
logos_time[r2] += perf_counter() - time_old
time_old = perf_counter()
elif pos > 0.6:
# "Looking left"
logos_time[r1] += perf_counter() - time_old
logos_already_shows = []
logos_pair = []

for round in range(5):
r1 = 0
r2 = 0
for i in range(len(filenames)//2):
r1 = randint(0, len(filenames)-1)
r2 = randint(0, len(filenames)-1)
while True:
if r1 not in logos_already_shows:
logos_already_shows.append(r1)
break
r1 = randint(0, len(filenames)-1)

while True:
if r2 not in logos_already_shows:
logos_already_shows.append(r2)
break
r2 = randint(0, len(filenames)-1)

logos_pair.append((r1, r2))
print(r1, r2)
image1 = cv2.imread(f'{dir_path}/{filenames[r1]}')
image2 = cv2.imread(f'{dir_path}/{filenames[r2]}')

time_start_10_sec = perf_counter()
while perf_counter() - time_start_10_sec < time_to_show:
time_old = perf_counter()
# show 2 logo
hori = np.concatenate((image1, image2), axis=1)

cv2.namedWindow("programs", cv2.WINDOW_NORMAL)
cv2.resizeWindow("programs", 1680, 1000)
cv2.imshow("programs", hori)
if cv2.waitKey(1) == 27:
break

# We get a new frame from the webcam
_, frame = webcam.read()
# We send this frame to GazeTracking to analyze it
gaze.refresh(frame)
frame = gaze.annotated_frame()

pos = gaze.horizontal_ratio()
# print(pos)

if pos is None:
# "Blinking"
pass
elif pos <= 0.6:
# "Looking right"
logos_time[r2] += perf_counter() - time_old
time_old = perf_counter()
elif pos > 0.6:
# "Looking left"
logos_time[r1] += perf_counter() - time_old
time_old = perf_counter()

print(logos_time)
# удалить логотипы с наименьшем временем
win_logos = []
for item in logos_pair:
if item[0] > item[1]:
win_logos.append(filenames[item[1]])
else:
win_logos.append(filenames[item[0]])

left_pupil = gaze.pupil_left_coords()
right_pupil = gaze.pupil_right_coords()
# print(win_logos)
filenames = win_logos
print(filenames)
logos_time = [0] * len(filenames)
logos_already_shows = []
logos_pair = []

cv2.namedWindow("programs", cv2.WINDOW_NORMAL)
cv2.resizeWindow("programs", 1680, 1000)
cv2.imshow("programs", frame)
image = cv2.imread(f'{dir_path}/{filenames[0]}')
cv2.namedWindow("programs", cv2.WINDOW_NORMAL)
cv2.resizeWindow("programs", 1680, 1000)
cv2.imshow("programs", image)
while True:
if cv2.waitKey(1) == 27:
break

if cv2.waitKey(1) == 27:
break

webcam.release()
cv2.destroyAllWindows()
webcam.release()
cv2.destroyAllWindows()
15 changes: 15 additions & 0 deletions scale_logos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from PIL import Image, ImageGrab, ImageOps
from os import walk


dir_path = r'logo_new'
filenames = list(walk(dir_path))[0][2]
print(filenames)

for i in range(len(filenames)):
img_orig = Image.open(f'logo_new/{filenames[i]}')
# впишем скриншот в квадрат 1000x1000 пикселей
# img = ImageOps.contain(img_orig, (900, 900), method=Image.LANCZOS)
img = ImageOps.pad(img_orig, (840, 840), color='#ffffff', method=Image.LANCZOS, centering=(0.5, 0.5))

img.save(f'logo_new_scaled/{filenames[i]}')

0 comments on commit 0a617f6

Please sign in to comment.