-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecognize.py
More file actions
executable file
·53 lines (47 loc) · 1.64 KB
/
recognize.py
File metadata and controls
executable file
·53 lines (47 loc) · 1.64 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
import pexpect
import time
import os
import datetime
from subprocess import Popen, PIPE
picture = 'data/new.jpg'
d_picture = 'predictions.png'
def shot():
a = datetime.datetime.now()
os.system('raspistill -o '+picture+' -ex sports -e jpg -h 480 -w 640 -t 1 -q 100 --exif none')
b = datetime.datetime.now()
print(b-a)
def stream():
cmd = 'raspivid -t 0 -w 360 -h 240 -fps 5 -b 25000000 -o - | mplayer -fps 10 -demuxer h264es -x 360 -y 240 -'
return Popen(cmd, stdout = PIPE, stdin = PIPE, stderr = PIPE, shell = True)
def init():
#cmd = './ninja/NNPACK-darknet/darknet-nnpack/darknet detector test ./ninja/NNPACK-darknet/darknet-nnpack/cfg/voc.data ./ninja/NNPACK-darknet/darknet-nnpack/cfg/tiny-yolo-voc.cfg ./ninja/NNPACK-darknet/darknet-nnpack/tiny-yolo-voc.weights'
cmd = './alter/ninja/NNPACK/darknet-nnpack/darknet detector test ./alter/ninja/NNPACK/darknet-nnpack/cfg/voc.data ./alter/ninja/NNPACK/darknet-nnpack/cfg/tiny-yolo-voc.cfg ./alter/ninja/NNPACK/darknet-nnpack/tiny-yolo-voc.weights'
p = pexpect.spawnu(cmd)
p.delaybeforesend = None
time.sleep(15)
try:
p.expect_exact('Image Path: ')
ret = p.before
except:
ret =''
return p
def recognize(p):
a = datetime.datetime.now()
try:
p.sendline(picture)
time.sleep(1.5)
p.expect_exact('all done')
ret = p.before
res = ret.find('person: ')
except:
return False
b = datetime.datetime.now()
if(res == -1):
print(b-a)
return False
else:
print(b-a)
return True
def move():
os.system('cp '+d_picture+' ./data/')
time.sleep(3)