Camera support and access

  • direct camera support so that client can upload or stream images directly from camera into web app.

  • use case examples:

    • applications serving trained image classifiers
    • scanning barcodes, QR codes, etc.
1 Like

Ok, not a full answer, but you can at least fire up the camera and upload images. Only tested on Chrome on Android, but I believe it works on all major android browsers. I also read that only Safari on iOS support this feature.

<input type="file" accept="image/*" capture="camera">

Try it here :

Click the button, you get a File Upload widget appear.
Click choose file and it opens the camera.

Not tried dealing with the upload yet in Anvil. When I get 10 mins … :slight_smile:

As for streaming … no idea, sorry.

Clone it here :

Also, I forgot about this :


Ooo, I do hate it when I realise what I’m going to be wasting the next XXX hours on :slight_smile:

This shows it can be done client side (turning on the camera and real-time scanning a QR code without installing an app) :

so logic dictates we can probably import a library into Anvil.
Sigh, there goes my weekend …


Right -

very, very, very, very hacky, and I haven’t imported all the graphics to make the page load properly, but try this :

It’s also live on

Based on an oldish library, but it’s all I’ve had time to play with today so far. Maybe someone else wants to have a bash?

Try reading a QR code (for example and it should display the link under the camera display (you may need to scroll down to see that it’s done anything).

Strip the code out of here rather than used the github repo. Just seemed a little easier (someone advised it somewhere and I think they were right) :


@david.wylie The QR reader tested well for me in Chrome. I found that it only works in live mode, not in test mode.

Thank you and impressive speed in hacking up a working prototype. I look forward to digging into this more and polishing it for a use case, hopefully maybe making a contribution to the community.

You have helped me decide to upgrade.


Hi every one. I am trying to use camera to capture image in laptop. To classify image directly by scanning instead of uploading. I am new to anvil and i dont know where to add this code. Can some one help me with this.

Appreciate you response thank you

Hi and welcome to the forum!

If you want to ask a question, please create a new post. Trying to revive old stale posts is unlikely to get the attention of someone that wants to answer, and it’s unlikely to help anyone in the future coming here with a similar question.

Here are some guidelines about how to ask a question: How to ask a good question


Thank You for letting me know. I will create a new post.

Locking this post to stop it being bumped and encourage people to raise new issues.