Skip to content

Latest commit

 

History

History
49 lines (48 loc) · 2.32 KB

oneshot.md

File metadata and controls

49 lines (48 loc) · 2.32 KB
<title>Project 4d - adamgulde.github.io</title> <script type=“text/javascript” src=“/server.js”></script>

One-Shot AI Implementation (Experimental)

To Home Start Camera
CONVERT Image

Empty

<script type="module"> import { insertIntoDB } from "/server.js" const getBase64StringFromDataURL = (dataURL) => dataURL.replace('data:', '').replace(/^.+,/, ''); let camera_button = document.querySelector("#start-camera"); let convert_button = document.querySelector("#convert"); let video = document.querySelector("#video"); let canvas = document.querySelector("#canvas"); let data_paragraph = document.querySelector("#data_text"); data_paragraph.innerHTML = 'Empty' camera_button.addEventListener('click', async function() { let stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: false }); video.srcObject = stream; setInterval(function() { canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height); }, 30); }); convert_button.addEventListener('click', async function() { let converted_image = getBase64StringFromDataURL(canvas.toDataURL('image/jpeg')); data_paragraph.innerHTML = converted_image; insertIntoDB(convertedImage, "Data sent... waiting on response"); }); </script> <script src="" async defer></script>