forked from Qualcomm-Capstone/detection
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw_lines.py
More file actions
56 lines (44 loc) · 1.31 KB
/
draw_lines.py
File metadata and controls
56 lines (44 loc) · 1.31 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
54
55
56
import gi, os
gi.require_version('Gst', '1.0')
gi.require_version('GstVideo', '1.0')
from gi.repository import Gst, GLib
import cairo
from shared import line
Gst.init(None)
os.environ["XDG_RUNTIME_DIR"] = "/dev/socket/weston"
os.environ["WAYLAND_DISPLAY"] = "wayland-1"
def draw_overlay(overlay, context, timestamp, duration):
width, height = 1920, 1080
y1, y2 = line.LINE_Y1, line.LINE_Y2
context.set_line_width(3)
# 빨간 선
context.set_source_rgba(1, 0, 0, 0.8)
context.move_to(0, y1)
context.line_to(width, y1)
context.stroke()
# 초록 선
context.set_source_rgba(0, 1, 0, 0.8)
context.move_to(0, y2)
context.line_to(width, y2)
context.stroke()
pipeline_str = (
'qtiqmmfsrc camera=0 ! '
'qtivtransform flip-vertical=true ! '
'video/x-raw, width=1920, height=1080, framerate=15/1 ! '
'videoscale ! videoconvert ! '
'cairooverlay name=line_overlay ! '
'videoconvert ! '
'video/x-raw, width=1920, height=1080 ! '
'waylandsink fullscreen=true sync=false'
)
pipeline = Gst.parse_launch(pipeline_str)
overlay = pipeline.get_by_name("line_overlay")
overlay.connect("draw", draw_overlay)
pipeline.set_state(Gst.State.PLAYING)
loop = GLib.MainLoop()
try:
loop.run()
except KeyboardInterrupt:
pass
finally:
pipeline.set_state(Gst.State.NULL)