0% found this document useful (0 votes)
3 views

script.js

The document contains JavaScript functions for a web application that allows users to open a camera, capture an image, and switch between learning and quiz modes. The 'openCamera' function accesses the user's camera, while 'captureImage' captures a frame from the video stream. Additionally, 'startLearning' and 'startQuiz' functions update the content area with educational and quiz-related information, respectively.

Uploaded by

avlerqy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

script.js

The document contains JavaScript functions for a web application that allows users to open a camera, capture an image, and switch between learning and quiz modes. The 'openCamera' function accesses the user's camera, while 'captureImage' captures a frame from the video stream. Additionally, 'startLearning' and 'startQuiz' functions update the content area with educational and quiz-related information, respectively.

Uploaded by

avlerqy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

function openCamera() {

let video = document.getElementById("video");


let cameraContainer = document.getElementById("camera-container");

cameraContainer.style.display = "block";

navigator.mediaDevices.getUserMedia({ video: true })


.then(function (stream) {
video.srcObject = stream;
})
.catch(function (error) {
console.error("Error accessing camera: ", error);
});
}

function captureImage() {
let video = document.getElementById("video");
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");

canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);

alert("Image Captured! AI Detection coming soon...");


}

function startLearning() {
document.getElementById("content").innerHTML = "<h2>Learning Mode</h2><p>Here
you will see educational content.</p>";
}

function startQuiz() {
document.getElementById("content").innerHTML = "<h2>Quiz
Mode</h2><p>Interactive quiz will be here.</p>";
}

You might also like