Giter VIP home page Giter VIP logo

js-camera-capture's Introduction

JS-Camera-Capture

Vanilla JS camera capture example, working on desktop and mobile based on navigator.mediaDevices.getUserMedia().

Designed as a basic user interface example for taking a picture and sending it to some server, here the ntfy channel: https://ntfy.sh/js-camera-capture

There are two versions.

1) Modal Version

Demo

For realistic use cases: Activate Camera opens a modal with the canvas. The buttons have some basic styling.

image

image

There is another version with an additional text input option: with-text-input

image

2) Simple Version

Demo

This version displays the video stream canvas directly to the html body (which might be good for testing and simple stuff). Pretty much without CSS modifications.

image

Options

If you'd like to activate the front camera on mobile as default (instead of the rear one) use the facingMode: 'user' instead of facingMode: 'environment':

stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'user' } });

Collaboration

PR's are very welcome, especially for enhancing the UI or adding more features. However, the codebase should be kept:

  • simple
  • small

I used one html file only as it's easier to move around and download but I'm open for separating it properly in html, js, css. Feel free to create plugins or wrapper!

To Do

  • add camera switch for mobile phones
  • add logic when user rotates phone - the canvas currently doesn't follow the 90° rotation which leads to a weird UX

js-camera-capture's People

Contributors

do-me avatar

Stargazers

 avatar Fabio avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.