whitphx / streamlit-webrtc

Real-time video and audio streams over the network, with Streamlit.
https://discuss.streamlit.io/t/new-component-streamlit-webrtc-a-new-way-to-deal-with-real-time-media-streams/8669
MIT License
1.28k stars 178 forks source link

Show multiple images using one cam's callback #1220

Closed kevinlinxc closed 1 year ago

kevinlinxc commented 1 year ago

When I receive the original frame in the callback, I want to do some simple processing on the image, for now let's just pretend I want to crop it. Then, I want to show the raw image and the cropped version in two different locations on the streamlit webapp (e.g. in two streamlit columns)

If I use two webrtc_streamer instances, I have to initialize the camera twice, which is not as elegant. Is there a way to get what I want?

kevinlinxc commented 1 year ago

Ok, I think this example might be what I'm looking for: https://github.com/whitphx/streamlit-webrtc/blob/main/pages/5_fork_multi_outputs.py

The code looks a little bit complex though.

kevinlinxc commented 1 year ago

It wasn't too complex, but there was definitely around 20-30s of startup lag and the callbacks running in their own thread was kind of problematic for image tracking.