photo-capture
v1.0.1
Published
This library is used to snap image from the media stream
Downloads
8
Maintainers
Readme
Photo Capture
Photo Capture is a JavaScript library that allows you to capture images from a media stream using the browser's camera. It provides an easy-to-use API to start and stop the camera and capture photos.
Features
- Start and stop the camera.
- Capture photos from the video stream.
- Check if the camera is available.
How to use
Include the library in your HTML file:
Initialize the library with the following options: ```html <video id="videoElement" autoplay></video>Include the library in your JavaScript file:
const photoCapture = new PhotoCapture(document.getElementById('videoElement'));You can call the following methods on the
photoCaptureobject:| Method | Description | |---|---| | startCamera | Starts the camera and displays the video stream in the provided video element. | | stopCamera | Stops the camera and hides the video stream. | | capturePhoto | Captures a photo from the video stream and returns it as a png image data URL | | isCameraAvailable | Checks if the camera is available on the device. Returns a boolean value. |
Example usage
See example.html for usage
If you like my work, please consider giving it a star on GitHub or Sponsor my work by following sponsoring me link.
