-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame.py
More file actions
executable file
·78 lines (64 loc) · 2.26 KB
/
Frame.py
File metadata and controls
executable file
·78 lines (64 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
#-------------------------- ANNOTATIONS BY ANTON -------------------#
Class PixelFrame:
Purpose: - Get pixel values out of an incoming string that portraits a single FRAME
- Normalize those values
- Save within this class
-> this class IS a Frame
Author: Kubik, with some code extensions by Anton Giese
"""
import numpy as np
class PixelFrame:
def __init__(self, line):
self.data = [0, 0, 0, 0, 0, 0, 0, 0, 0]
#print("line: ",line)
#print(type(line))
if type(line) == type([]):
values = []
for a in range(len(line)):
values.append(line[a])
else:
values = np.zeros((9))
# print("länge line: ",len(line))
done = False
doneWithByte = False
index = 0
startByte = 0
#for b in line:
#print(int(b))
lenByte = 0
while not done:
try:
lenByte+=1
#print(int(line[startByte:startByte+lenByte]))
values[index] = int(line[startByte:startByte+lenByte])
if index == 8 and lenByte>4:
done = True
#break
except:
# print("except at byte {} with len {}".format(index,lenByte))
# print(values[index])
# print(index)
index += 1
startByte = startByte + lenByte
lenByte = 0
i = 0
while i < 9: #len(values):
#print("values: ",float(string(values[i])))
self.data[i] = float(values[i])/1024
i = i + 1
self.mean = sum(self.data) / len(self.data)
"""
pixeldiff
compare the single pixels of this frame with another frame and see if it variates or not
If yes: return 1
else return 0
"""
def pixeldiff(self, otherFrame, eps):
i = 0
while i < len(self.data):
# print(str(otherFrame.data[i]-self.data[i]))
if abs(otherFrame.data[i] - self.data[i]) > eps:
return 1
i = i + 1
return 0