forked from spehj/yolov7-counter-jetson-nano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trt2.py
65 lines (54 loc) · 1.2 KB
/
trt2.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
# import cv2
# def gstreamer_pipeline(
# input_file,
# capture_width=3280,
# capture_height=2464,
# display_width=816,
# display_height=616,
# framerate=21,
# flip_method=2,
# ):
# return (
# 'filesrc location="{0}" ! '
# 'decodebin ! '
# 'videoconvert ! '
# 'video/x-raw, width=(int){1}, height=(int){2}, format=(string)BGR ! '
# 'videoconvert ! '
# 'appsink'
# .format(
# input_file,
# display_width,
# display_height
# )
# )
# # Example usage with an MP4 file
# input_file_path = 'file_example_MP4_480_1_5MG.mp4'
# pipeline = gstreamer_pipeline(input_file_path)
# cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)
import cv2
def gstreamer_pipeline(
input_file,
capture_width=3280,
capture_height=2464,
display_width=816,
display_height=616,
framerate=21,
flip_method=2,
):
return (
'filesrc location=output1.mp4 ! '
'decodebin ! '
'videoconvert ! '
'video/x-raw, width=(int){1}, height=(int){2}, format=(string)BGR ! '
'videoconvert ! '
'appsink'
.format(
input_file,
display_width,
display_height
)
)
# Example usage with an MP4 file
input_file_path = 'outpu1.mp4'
pipeline = gstreamer_pipeline(input_file_path)
cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)