Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
justin200914 committed Aug 15, 2023
1 parent ff1fa59 commit 90c7288
Showing 1 changed file with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,23 +285,45 @@ async function onPlay() {

async function startCamera() {

const stream = await navigator.mediaDevices.getUserMedia({ video: {} })
const videoEl = document.getElementById('inputVideo')
if(videoEl.srcObject == null) {
document.getElementById('camera').innerText = "Stop Camera";

videoEl.srcObject = stream
old_liveness1 = 0;
old_liveness2 = 0;
brisque_count = 0;

} else {
const canvas = document.getElementById("capture");
canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);

videoEl.srcObject = null
document.getElementById('camera').innerText = "Start Camera";
}
if(isMobile()) {
const stream = await navigator.mediaDevices.getUserMedia({ video: {width: 480,
height: 640} })
const videoEl = document.getElementById('inputVideo')
if(videoEl.srcObject == null) {
document.getElementById('camera').innerText = "Stop Camera";

videoEl.srcObject = stream
old_liveness1 = 0;
old_liveness2 = 0;
brisque_count = 0;

} else {
const canvas = document.getElementById("capture");
canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);

videoEl.srcObject = null
document.getElementById('camera').innerText = "Start Camera";
}
} else {
const stream = await navigator.mediaDevices.getUserMedia({ video: {width: 640,
height: 480} })
const videoEl = document.getElementById('inputVideo')
if(videoEl.srcObject == null) {
document.getElementById('camera').innerText = "Stop Camera";

videoEl.srcObject = stream
old_liveness1 = 0;
old_liveness2 = 0;
brisque_count = 0;

} else {
const canvas = document.getElementById("capture");
canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);

videoEl.srcObject = null
document.getElementById('camera').innerText = "Start Camera";
}
}
}

function isMobile() {
Expand Down

0 comments on commit 90c7288

Please sign in to comment.