Camera Capture
A camera viewfinder for documents, cards and faces: a framing guide, quality hints, auto-capture when steady, retake or keep, front/back switch and a list of required shots. Each photo is a Blob.
c2-camera-capture takes a photo with the device’s camera, as a bank’s cheque deposit, an identity check or a receipt scanner does. It draws a framing guide (guide="document", card or face), says what is wrong with the picture (too dark, glare, moving, blurry), can take the photo by itself once the picture holds steady (auto-capture), and lets the user retake or keep it. shots walks the user through several photos in order, each with its own guide and camera. Every photo reaches the app as a Blob, in the capture, accept and complete events and in photos.
The camera only opens when the user presses Start camera (or the app calls start()), and closes once the photos are taken or the element leaves the page. The examples on this page film a pretend scene through streamSource, so they never ask for your camera; the first row uses the real one.
Import
import '@c2n/components/camera-capture'Usage
Take a photo with your camera.
Take a photo with your camera.
- Front of the card
- Back of the card
- Selfie
Take a photo with your camera.
Read the photos from the events:
const camera = document.querySelector('c2-camera-capture')!
camera.addEventListener('complete', async (event) => {
const body = new FormData()
for (const photo of event.detail.photos) body.append(photo.id, photo.blob, `${photo.id}.jpg`)
await fetch('/api/verification', { method: 'POST', body })
})