-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
51 lines (43 loc) · 990 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
40
41
42
43
44
45
46
47
48
49
50
51
import unittest
import pytest
import numpy as np
import cv2
import time
import tracking as track
hand_hist = None
size = 9
hand_rect_one_x = None
hand_rect_one_y = None
hand_rect_two_x = None
hand_rect_two_y = None
traverse_point = []
is_hand_hist_created = False
cap = cv2.VideoCapture('v.mp4')
cap_test = cap.isOpened()
cx = -1
cy = -1
while cap.isOpened():
# read first frame
ret1, frame = cap.read()
#print(1)
frame = track.draw_rect(frame)
is_hand_hist_created = True
hand_hist = track.hand_histogram(frame)
# read next frame
ret2, frame2 = cap.read()
#print(2)
if is_hand_hist_created:
frame2, max_cont = track.manipulate(frame, hand_hist)
cx, cy = track.centroid(max_cont)
a = np.array(max_cont)
#print(3)
cap.release()
cv2.destroyAllWindows()
# test frame
def test():
assert cap_test == True
assert ret1 == True
assert ret2 == True
assert a.size != 0
assert cx > 0
assert cy > 0