Pipeline not terminated #498
Answered
by
MubashirWaheed
MubashirWaheed
asked this question in
Q&A
-
Why is the program not terminated on keyboard interrupt? def main(
weight_path: str,
rtsp_url: str,
zone_configuration_path: str,
model_id: str,
confidence: float,
iou: float,
classes: List[int],
) -> None:
sink = CustomSink(weights_path=weight_path ,zone_configuration_path=zone_configuration_path, classes=classes)
pipeline = InferencePipeline.init_with_custom_logic(
video_reference=rtsp_url,
on_video_frame=sink.infer,
on_prediction=sink.on_prediction,
)
pipeline.start()
try:
pipeline.join()
# except (KeyboardInterrupt, SystemExit):
except KeyboardInterrupt:
pipeline.terminate()
print("Program terminated.")
pipeline.terminate()
print("Program terminated.") I tried |
Beta Was this translation helpful? Give feedback.
Answered by
MubashirWaheed
Jul 1, 2024
Replies: 1 comment
-
I fixed it by moving the try:
pipeline.start()
pipeline.join()
except (KeyboardInterrupt, SystemExit):
pipeline.terminate()
print("Program terminated.") and added this in the def on_prediction()
// code here
if cv2.waitKey(1) & 0xFF == ord('q'):
cv2.destroyAllWindows()
raise SystemExit("Program terminated by user") now I can quit it by pressing |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MubashirWaheed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I fixed it by moving the
pipeline.start()
inside thetry
and added this in the
on_prediction
functionnow I can quit it by pressing
q
key