-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrealtime_iir_main.py
More file actions
61 lines (45 loc) · 1.26 KB
/
realtime_iir_main.py
File metadata and controls
61 lines (45 loc) · 1.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
import sys
from time import sleep
import numpy as np
import scipy.signal as signal
import pickle
#import QT
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
from MainWindow import *
sys.path.append("./webcam2rgb")
import webcam2rgb
#import pannal
# create a global QT application object
app = QtGui.QApplication(sys.argv)
#panningPlot = QtPanningPlot("helloworld")
main_window = MainWindow("person detect system")
def callBack(retval, data):
b = data[0]
g = data[1]
r = data[2]
main_window.addData(r)
#calculate num of data
counter = 0
time_pre = 0
def callBack2(retaval, data):
global counter
global time_pre
#to eliminate jitter, every interval between datas should larger than 0.01
now = time.time()
if (now- time_pre)>0.010:
counter += 1
time_pre = now
camera = webcam2rgb.Webcam2rgb()
print("start calculating sampling rate")
#check the samplling rate of camera
time_pre = time.time() #initiate time
camera.start(callback = callBack2, cameraNumber=0)
#sleep 5 seconds to calculate sample rate
time.sleep(5)
print("camera samplerate: {}Hz".format(counter/5.0))
camera.stop()
camera.start(callback = callBack, cameraNumber=0)
#print("camera samplerate: ", camera.cameraFs(), "Hz")
app.exec_()
camera.stop()