This recipe shows how to control the contrast feature of a video using the HTML5 filter feature. This is the second most important control that customers usually want to have when using video applications.
Follow the given steps:
Add a control element to the main web page of your application—using this object we will change the contrast:
Contrast <input type="range" oninput="changeContrast(this.valueAsNumber);" value="0" step="0.1" min="0" max="10">
Add an appropriate JavaScript function:
function changeContrast(val) { var v = document.getElementById("localVideo"); v.style.webkitFilter="contrast(" + val + ")"; };
Here,
localVideo
is the ID property of the HTML video tag for the local video playback.Navigate your web browser to the web page. You will first see an unprocessed video from the web camera. The following screenshot depicts such a situation:
On the left-hand side of the page, you can see a control described as Contrast. Try to move it to the...