-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
39 lines (30 loc) · 863 Bytes
/
test.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
import cv2
import sys
import time
class Camera(object):
def __init__(self, path=None):
self._source = 0 if path is None else path
self._cap = cv2.VideoCapture(self._source)
def resolution(self):
width = self._cap.get(cv2.CAP_PROP_FRAME_WIDTH)
height = self._cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
return (int(width), int(height))
def read(self):
ret, frame = self._cap.read()
return frame
def main():
cam = Camera()
if '--lr' in sys.argv:
from lib import LRTracker
ln = LRTracker(cam)
else:
from lib import ContourTracker
ln = ContourTracker(cam)
if '--preview' in sys.argv:
ln.preview(True)
while True:
print(ln.track_line())
cv2.waitKey(1)
cv2.closeAllWindows()
if __name__ == '__main__':
main()