jupyter-widgets-contrib / ipycanvas

Interactive Canvas in Jupyter
https://ipycanvas.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
690 stars 64 forks source link

Improve put_image_data performances #175

Open martinRenou opened 3 years ago

martinRenou commented 3 years ago

We can improve put_image_data by sending a jpeg encoded value instead of the entire matrix: See this code in ipyvtk https://github.com/Kitware/ipyvtk-simple/blob/7a30b215c7d8dce5109330e8c4a197ff2e2c4426/ipyvtk_simple/viewer.py#L165-L171

superted6851 commented 3 years ago

Great library thank you.

Did you manage to get this enhancement to work?

I am trying to hand draw onto a video stream from opencv video capture. I have a Multicanvas setup with the background image being updated every 50ms and the top canvas being used for drawing. This works ok but he drawing is slow and the stroke colour defaults to black even through it is set to white, also the line width is 1 even through the attribute is set to 3. Not sure if improving put_image_data performance will help this with this issue or it is a different bug.

I tried to install the development version so I could try the put_image_data_improvements but I through an error during install. I will post this as a separate issue.

superted6851 commented 3 years ago

Actually never mind, I found the solution to my issue from looking at the Interaction during animation example. I need to implement an event loop. For some reason the iMac I was using was handling widget events most of the time but only with black lines but my MacBook was waiting until the loop had completed.

kushalkolar commented 1 year ago

I think simplejpeg is even faster for encoding, it's used in https://github.com/vispy/jupyter_rfb