Open
Description
Issue guidelines
- I've read the Issue Guidelines and wholeheartedly agree.
Issue Checklist
- I have searched open or closed issues for my problem and found nothing related or helpful.
- I have read the Documentation and found nothing related to my problem.
- I have gone through the Bonus Examples and FAQs and found nothing related or helpful.
Describe your Question
I checked docs and didn't find any example for my use case. I am getting a series of frames after processing and want to show them on the web. So basically a combination of streamgear and webgear.
I am using the inference pipeline from roboflow so I can't yield frame like in opencv. I can'rt just pass the on_prediction
to the webgear config as shown in the example
You can read here:https://inference.roboflow.com/using_inference/inference_pipeline/#usage
Terminal log output(Optional)
No response
Python Code(Optional)
sample code
// initialize like this?
stream = CamGear()
streamer = StreamGear(output=".\dash_out.mpd")
class CustomSink:
def __init__(self, weights_path: str, zone_configuration_path: str, classes: List[int]):
// initialization
def on_prediction(self, result: dict, frame: VideoFrame) -> None:
self.fps_monitor.tick()
fps = self.fps_monitor.fps
detections = sv.Detections.from_ultralytics(result)
detections = detections[find_in_list(detections.class_id, self.classes)]
detections = self.tracker.update_with_detections(detections)
annotated_frame = frame.image.copy()
annotated_frame = sv.draw_text(
scene=annotated_frame,
text=f"{fps:.1f}",
text_anchor=sv.Point(40, 30),
background_color=sv.Color.from_hex("#A351FB"),
text_color=sv.Color.from_hex("#000000"),
)
labels = [
f"#{tracker_id} {int(time // 60):02d}:{int(time % 60):02d}" if class_id != 2 else f"#{tracker_id}"
for tracker_id, time, class_id in zip(detections_in_zone.tracker_id, time_in_zone,detections_in_zone.class_id)
]
annotated_frame = LABEL_ANNOTATOR.annotate(
scene=annotated_frame,
detections=detections_in_zone,
labels=labels,
custom_color_lookup=custom_color_lookup,
)
# replace with streamgear and webgear
streamer.stream(annotated_frame)
try:
# Resize the frame to fit the window size
resized_frame = cv2.resize(annotated_frame, (width, height))
except cv2.error as e:
print(f"Error resizing frame: {e}")
return # Skip this frame and continue with the next one
# Display the resized frame in the window
cv2.imshow('Resizable Window', resized_frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
cv2.destroyAllWindows()
raise SystemExit("Program terminated by user")
VidGear Version
0.3.3
Python version
3.11.8
Operating System version
ubuntu
Any other Relevant Information?
No response