-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from takeyamayuki/develop
Change to appropriate file structure
- Loading branch information
Showing
9 changed files
with
132 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import tkinter as tk | ||
|
||
|
||
def tk_arg(): | ||
root = tk.Tk() | ||
root.title("First Setup") | ||
root.geometry("370x320") | ||
screenRes = (root.winfo_screenwidth(), | ||
root.winfo_screenheight()) # ディスプレイ解像度取得 | ||
Val1 = tk.IntVar() | ||
Val2 = tk.IntVar() | ||
Val4 = tk.IntVar() | ||
Val4.set(30) # デフォルトマウス感度 | ||
place = ['Normal', 'Above', 'Behind'] | ||
# Camera ######################################################################### | ||
Static1 = tk.Label(text='Camera').grid(row=1) | ||
for i in range(4): | ||
tk.Radiobutton(root, | ||
value=i, | ||
variable=Val1, | ||
text=f'Device{i}' | ||
).grid(row=2, column=i*2) | ||
St1 = tk.Label(text=' ').grid(row=3) | ||
# Place ######################################################################### | ||
Static1 = tk.Label(text='How to place').grid(row=4) | ||
for i in range(3): | ||
tk.Radiobutton(root, | ||
value=i, | ||
variable=Val2, | ||
text=f'{place[i]}' | ||
).grid(row=5, column=i*2) | ||
St1 = tk.Label(text=' ').grid(row=6) | ||
# Sensitivity ################################################################### | ||
Static4 = tk.Label(text='Sensitivity').grid(row=7) | ||
s1 = tk.Scale(root, orient='h', | ||
from_=1, to=100, variable=Val4 | ||
).grid(row=8, column=2) | ||
St4 = tk.Label(text=' ').grid(row=9) | ||
# continue | ||
Button = tk.Button(text="continue", command=root.destroy).grid( | ||
row=10, column=2) | ||
# 待機 | ||
root.mainloop() | ||
# 出力 | ||
cap_device = Val1.get() # 0,1,2 | ||
mode = Val2.get() # 0:youself 1: | ||
kando = Val4.get()/10 # 1~10 | ||
return cap_device, mode, kando, screenRes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import cv2 | ||
import numpy as np | ||
|
||
|
||
def draw_circle(image, x, y, roudness, color): | ||
"""draw circle""" | ||
cv2.circle(image, (int(x), int(y)), roudness, color, | ||
thickness=5, lineType=cv2.LINE_8, shift=0) | ||
|
||
|
||
def calculate_distance(lankdmark1, landmark2): | ||
""" | ||
Calculate Euclidean distance | ||
Parameters | ||
---------- | ||
landmark1 : list | ||
landmark2 : list | ||
Returns | ||
------- | ||
distance : float | ||
""" | ||
v = np.array([lankdmark1[0], lankdmark1[1]]) - \ | ||
np.array([landmark2[0], landmark2[1]]) | ||
distance = np.linalg.norm(v) | ||
return distance | ||
|
||
|
||
def calculate_moving_average(landmark, ran, LiT): # (座標、いくつ分の平均か、移動平均を格納するリスト) | ||
""" | ||
Calculate moving averages | ||
Parameters | ||
---------- | ||
landmark : list | ||
landmark | ||
ran : int | ||
range | ||
LiT : list | ||
list in time | ||
Returns | ||
------- | ||
moving average : float | ||
""" | ||
|
||
while len(LiT) < ran: # ran個分のデータをLiTに追加(最初だけ) | ||
LiT.append(landmark) | ||
LiT.append(landmark) # LiTの更新(最後に追加) | ||
if len(LiT) > ran: # LiTの更新(最初を削除) | ||
LiT.pop(0) | ||
return sum(LiT)/ran |