Adding drawing on webcam image

Hi,

I’m trying to display a live video stream from the webcam while adding a rectangle on the image, using Blocks.

So this is what I have:

Def draw(im):
cv2.rectangle(im,(50,50), (200,200), (0, 255, 255), 2)
return im

with gr.Blocks() as demo:
inp = gr.Image(source=“webcam”, shape=(250,250), streaming=True)
out = gr.Image(label=‘Out-Calibration’, )
inp.change(draw, inp, out)

This works and does what I expect it to do, but the output image is flickering, which is annoying.

Am I doing something wrong here? is there a better way to do this?

Thanks!