-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_imagepipe.py
73 lines (54 loc) · 1.95 KB
/
test_imagepipe.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
import logging
from multiprocessing import Queue
from unittest import TestCase
import cv2
import image2pipe
SCALE = scale = (320, 160)
VIDEO_URL = "/Users/chexov/testvideo/shuttle-flip.mp4"
logging.basicConfig()
class Image2PipeTest(TestCase):
def test_min_params(self):
q = Queue()
decoder = image2pipe.images_from_url(q, VIDEO_URL)
decoder.start()
for i in range(30):
fn, img = q.get()
cv2.imshow("frame %d" % i, img)
cv2.waitKey()
cv2.destroyAllWindows()
def test_rgb24_from_url(self):
q = Queue()
decoder = image2pipe.images_from_url(q, VIDEO_URL, fps="30", scale=SCALE)
decoder.start()
for i in range(30):
fn, img = q.get()
cv2.imshow("frame %d" % i, img)
cv2.waitKey()
cv2.destroyAllWindows()
def test_vf(self):
q = Queue()
# decoder = image2pipe.images_from_url(q, VIDEO_URL, fps="30", scale=SCALE, vf=["cropdetect=24:16:0"])
decoder = image2pipe.images_from_url(q, VIDEO_URL, fps="30", scale=SCALE, vf=["crop=224:224:0:36"])
decoder.start()
fn, img = q.get()
cv2.imshow("frame %d" % 0, img)
cv2.waitKey()
cv2.destroyAllWindows()
def test_stitch(self):
fps = "30"
out_url = "out.ts"
# out_url = "out.mov"
scale = (1000, 552)
bgr_q = Queue()
decoder = image2pipe.images_from_url(bgr_q, VIDEO_URL, fps="30", scale=(1000, 552))
decoder.start()
# rtmpt = image2pipe.StitchVideoProcess(bgr_q, out_url, fps, scale, muxer="mov")
FORMAT_MPEGTS = "mpegts"
rtmpt = image2pipe.StitchVideoProcess(bgr_q, out_url, fps, scale, FORMAT_MPEGTS)
rtmpt.start()
rtmpt.join()
if __name__ == '__main__':
Image2PipeTest().test_min_params()
Image2PipeTest().test_vf()
Image2PipeTest().test_rgb24_from_url()
Image2PipeTest().test_stitch()