Chapter 11. Using a webcam in your application

 

This chapter covers

  • Accessing the webcam on your computer
  • Creating still images from live video
  • Saving the still images to your computer

Not many years ago, webcams were external devices that you bought to plug into your computer and used to chat with friends and family. Today, almost all laptops come with webcams and microphones built in, making it easy for people to travel and communicate with each other, as long as they have a good internet connection. Back then, the only way you could access a webcam feed was via a desktop app, or by using Adobe Flash. There wasn’t an easy way to do it over a web browser.

But that changed. With the introduction of the HTML5 Media Capture API, webcams could be accessible to web pages (with good security procedures in place), and it is this capability that we’ll explore in this chapter. We’ll look at ways to access and use these APIs to build a photo booth app.

11.1. Photo snapping with the HTML5 Media Capture API

When using Electron or NW.js to build your desktop app, you get the benefit of Google Chrome’s extensive support for HTML5 APIs, one of which is the Media Capture API. The HTML5 Media Capture API allows you to access the microphone and video camera that are embedded in your computer, and the app you’ll build will make use of this.

11.2. Summary

sitemap