-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpvg_headless.py
75 lines (59 loc) · 2.18 KB
/
pvg_headless.py
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
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# pvg_headless.py
#
# Copyright 2014 Giorgio Gilestro <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
import numpy as np
import cv2
import pysolovideo
class pvg_cli():
"""
A completeley headless pysolo-video monitor
Does not require wx
"""
def __init__(self, source, resolution=None):
"""
"""
self.resolution = resolution
self.mon = pysolovideo.Monitor()
self.mon.setSource(source, resolution)
def setTracking(self, track_type, mask_file, output_file):
track = ( int(track_type) > -1 )
self.mon.setTracking(track, track_type, mask_file, output_file)
def startTracking(self):
self.mon.startTracking()
def stopTracking(self):
self.mon.stopTracking()
def saveSnapshot(self, filename):
self.mon.saveSnapshot(filename)
def isRunning(self):
return self.mon.isTracking
if __name__ == '__main__':
pysolo_headless = pvg_cli(0, resolution=(640,480), mask_file="mask.msk", track_type=0, output_file="test.txt")
while True:
c = raw_input("Service started, enter S to stop it or P to take a snapshot:\n ")
if "S" in str(c).upper():
pysolo_headless.stopTracking()
print ("Tracking stopped")
exit()
elif "P" in str(c).upper():
pysolo_headless.saveSnapshot("0.jpg")
print ("Snapshot taken")