Hi,
I’m trying to expose some camera functionallity on a panel dashboard.
At the moment, a PC has an industrial camera connected and serves panel. On that same PC I open up the dashboard in a browser, click a “Snapshot” button, which captures a frame and updates a param.Parameter. I have this code that depends on that param:
class Camera(param.Parameterized):
latest = param.Parameter(default=(np.ones(shape=(50, 50), dtype=np.uint16) * 2000)) # Just some initial content
class InstrumentState(param.Parameterized):
camera = Camera()
........
@pn.depends(image=instrumentState.camera.param.latest, watch=True)
def img0(image):
return hv.Image(image, bounds=bounds).opts(*options)
layout = pn.Row(
pn.Column(
hv.DynamicMap(img0)
)
)
I felt like it took ages to take a snapshot, so I made some very primitive profiling and found that it took me 1.3s to do:
instrumentState.camera.latest = nparray_reshaped # A 3208x2200 numpy 8bit array.
I can see in the developer console that there is a 7.1MB binary sent on the websocket when .latest is updated. It should take no time at all to send 7.1 from one application to a browser on the same PC, right?
Maybe I’m not doing this the right way at all. If anyone has previous experience of updating large images in panel i would be very interested to hear what kind of results you have achieved.
I will probably setup a minimal reproducable example tomorrow.