Reading a webcam in Anvil

I have a ML application and I need to access the PC’s webcam.

I have seen posts saying that it can be done with javascript or the file uploader but I can not see any examples of how that can be done.

Does anybody have an example of how to read the webcam into a anvil image?

Thanks,
Louis

Hello :wave:,

Perhpas playing around with this will help:

Thanks fro that.

This is a a lot more that I need.

I can display a webcam on a canvas using the javascript below but then I can not use the canvas as an anvil component ( self.canvas )

Can I pass an anvil canvas component to this script?

Sorry I cant seem to post code so this is an image

You can use the Javascript bridge to set the id of your Anvil canvas element, and then your Javascript can get that component by id. You would not then have a separate HTML canvas element.

Something like:

    node = js.get_dom_node(self.canvas_1)
    node.id = "canvas_1"
1 Like

Thanks I will try this

That worked perfectly.
Thank you so much.

I will clean up the app and post in the show and tell as many others have been asking the same question.

1 Like