Skip to content

Conversation

@jmotow
Copy link
Contributor

@jmotow jmotow commented Dec 4, 2025

New DLStreamer sample to show how to use valve element in DLS pipeline.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

pylint

libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|183 col 19| C0123: Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|157 col 39| W0613: Unused argument 'pad' (unused-argument)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|157 col 50| W0613: Unused argument 'u_data' (unused-argument)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|234| C0116: Missing function or method docstring (missing-function-docstring)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|243| C0116: Missing function or method docstring (missing-function-docstring)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|285 col 11| W0718: Catching too general exception Exception (broad-exception-caught)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|280 col 26| W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|243| R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|274 col 20| W0612: Unused variable 'err' (unused-variable)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|10| C0411: standard import "sys" should be placed before third party imports "gi", "gi.repository.Gst" (wrong-import-order)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|11| C0411: standard import "sys" should be placed before third party imports "gi", "gi.repository.Gst" (wrong-import-order)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|12| C0411: standard import "time" should be placed before third party imports "gi", "gi.repository.Gst" (wrong-import-order)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|13| C0411: standard import "contextlib.contextmanager" should be placed before third party imports "gi", "gi.repository.Gst" (wrong-import-order)
libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py|13| W0611: Unused contextmanager imported from contextlib (unused-import)

print("Error: Could not find control_valve element")
return False
else:
print("Found control_valve element")
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0303: Trailing whitespace (trailing-whitespace)

return False
else:
print("Found control_valve element")

Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0303: Trailing whitespace (trailing-whitespace)

return False
else:
print("Found pre_view_classify element")

Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0303: Trailing whitespace (trailing-whitespace)

return False
else:
print("Got sink pad of pre_view_classify")

Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0303: Trailing whitespace (trailing-whitespace)

print("Got sink pad of pre_view_classify")

# and add probe/callback
pre_view_classify_pad.add_probe(Gst.PadProbeType.BUFFER, self.object_detector_callback, 0)
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0301: Line too long (102/100) (line-too-long)


try:
self.pipeline = Gst.parse_launch(pipeline_str)
if not self.pipeline:
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)


# Get valve element from pipeline
self.valve = self.pipeline.get_by_name("control_valve")
if not self.valve:
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)

# Get pre_view_classify element from pipeline
# Below we add a probe to the sink pad of pre_view_classify to monitor detected objects
self.pre_view_classify = self.pipeline.get_by_name("pre_view_classify")
if not self.pre_view_classify:
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)


# Get sink pad of pre_view_classify
pre_view_classify_pad = self.pre_view_classify.get_static_pad("sink")
if not pre_view_classify_pad:
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)

return Gst.PadProbeReturn.OK

rmeta = GstAnalytics.buffer_get_analytics_relation_meta(buffer)
if not rmeta:
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)

return Gst.PadProbeReturn.OK
else:
for mtd in rmeta:
if type(mtd) == GstAnalytics.ODMtd:
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
C0123: Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)

return False
return True

def object_detector_callback(self, pad, info, u_data):
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0613: Unused argument 'pad' (unused-argument)

return False
return True

def object_detector_callback(self, pad, info, u_data):
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0613: Unused argument 'u_data' (unused-argument)

except KeyboardInterrupt as e:
print(f"Interrupted by user. Stopping pipeline...[{e}]")
terminate = True
except Exception as e:
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0718: Catching too general exception Exception (broad-exception-caught)

print(f"Debug info: {debug_info}")
terminate = True
if msg.type == Gst.MessageType.EOS:
print(f"Pipeline complete.")
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)

print("# DL Streamer Open/Close Valve Sample #")
print("# ====================================== #\n")

def main():
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)

Gst.MessageType.EOS | Gst.MessageType.ERROR)
if msg:
if msg.type == Gst.MessageType.ERROR:
err, debug_info = msg.parse_error()
Copy link

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0612: Unused variable 'err' (unused-variable)

* [Draw Face Attributes C++ Sample](./cpp/draw_face_attributes/README.md) - constructs pipeline and sets "C" callback to access frame metadata and visualize inference results
3. Python samples
* [Draw Face Attributes Python Sample](./python/draw_face_attributes/README.md) - constructs pipeline and sets Python callback to access frame metadata and visualize inference results
* [Open Close Valve Sample](./python/open_close_valve/README.md) - constructs pipeline with two sinks. On of them has valve element, which is managed based object detection result and opened/closed by callback.
Copy link
Contributor

Choose a reason for hiding this comment

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

add web link to the 'valve' element gstreamer description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants