Skip to content

Instantly share code, notes, and snippets.

@imneonizer
Created September 26, 2025 04:52
Show Gist options
  • Select an option

  • Save imneonizer/c06e4ec89ea76001f496c09acc4dfe5e to your computer and use it in GitHub Desktop.

Select an option

Save imneonizer/c06e4ec89ea76001f496c09acc4dfe5e to your computer and use it in GitHub Desktop.
import cv2
import av
import numpy as np
from IPython.display import display, clear_output, Image as DispImage
def imshow(frame):
"""
Display a frame inline in Jupyter; each call replaces the previous one.
No matplotlib, no ipywidgets required.
"""
ok, jpeg = cv2.imencode('.jpg', frame)
if not ok:
return
clear_output(wait=True)
display(DispImage(data=jpeg.tobytes()))
container = av.open("rtsp://localhost:8554/home_camera")
for frame in container.decode(video=0):
img = frame.to_ndarray(format="bgr24")
imshow(img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment