Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added simple RTSP support and custom video sink option #40

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions basic_pipelines/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class GStreamerDetectionApp(GStreamerApp):
def __init__(self, args, user_data):
# Call the parent class constructor
super().__init__(args, user_data)
self.video_sink = args.video_sink if hasattr(args, 'video_sink') else 'autovideosink'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used please remove

# Additional initialization code can be added here
# Set Hailo parameters these parameters should be set based on the model used
self.batch_size = 2
Expand Down Expand Up @@ -154,6 +155,14 @@ def get_pipeline_string(self):
f"v4l2src device={self.video_source} name=src_0 ! "
"video/x-raw, width=640, height=480, framerate=30/1 ! "
)
elif self.video_source.startswith("rtsp://"):
source_element = (
f"rtspsrc location={self.video_source} name=src_0 ! "
"application/x-rtp,media=video ! "
"decodebin ! "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add some queues between decodebin, videoconvert and videoscale. These are big tasks which can benefit if separated to multiple threads.

"videoconvert ! videoscale ! "
f"video/x-raw, format={self.network_format}, width={self.network_width}, height={self.network_height} ! "
)
else:
source_element = (
f"filesrc location=\"{self.video_source}\" name=src_0 ! "
Expand Down Expand Up @@ -216,6 +225,8 @@ def get_pipeline_string(self):
default=None,
help="Path to costume labels JSON file",
)
parser.add_argument('--video-sink', default='autovideosink',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

help='GStreamer video sink to use (e.g., autovideosink, ximagesink, fakesink)')
args = parser.parse_args()
app = GStreamerDetectionApp(args, user_data)
app.run()
8 changes: 8 additions & 0 deletions basic_pipelines/instance_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ def get_pipeline_string(self):
elif self.source_type == "usb":
source_element = f"v4l2src device={self.video_source} name=src_0 ! "
source_element += f"video/x-raw, width=640, height=480, framerate=30/1 ! "
elif self.video_source.startswith("rtsp://"):
source_element = (
f"rtspsrc location={self.video_source} name=src_0 ! "
"application/x-rtp,media=video ! "
"decodebin ! "
"videoconvert ! videoscale ! "
f"video/x-raw, format={self.network_format}, width={self.network_width}, height={self.network_height} ! "
)
else:
source_element = f"filesrc location=\"{self.video_source}\" name=src_0 ! "
source_element += QUEUE("queue_dec264")
Expand Down
8 changes: 8 additions & 0 deletions basic_pipelines/pose_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ def get_pipeline_string(self):
elif self.source_type == "usb":
source_element = f"v4l2src device={self.video_source} name=src_0 ! "
source_element += f"video/x-raw, width=640, height=480, framerate=30/1 ! "
elif self.video_source.startswith("rtsp://"):
source_element = (
f"rtspsrc location={self.video_source} name=src_0 ! "
"application/x-rtp,media=video ! "
"decodebin ! "
"videoconvert ! videoscale ! "
f"video/x-raw, format={self.network_format}, width={self.network_width}, height={self.network_height} ! "
)
else:
source_element = f"filesrc location=\"{self.video_source}\" name=src_0 ! "
source_element += QUEUE("queue_dec264")
Expand Down