HuggingFace-SK commited on
Commit
69c145b
·
1 Parent(s): 19a3d36

increase cam res -> full

Browse files
Files changed (1) hide show
  1. static/index.js +9 -2
static/index.js CHANGED
@@ -37,17 +37,23 @@ async function switch_camera() {
37
  function load_camera() {
38
  const constraints = {
39
  video: {
40
- facingMode: video_facing_mode
 
 
41
  }
42
  };
43
  // Activate the webcam stream.
44
  navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
45
  video.srcObject = stream;
46
  video.addEventListener("loadeddata", img_load);
 
 
 
 
47
  });
48
  }
49
  function img_load(){
50
-
51
  canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
52
  canvasCtx.drawImage(video, 0, 0, canvasElement.width, (video.videoHeight / video.videoWidth) * canvasElement.width)
53
  var image = canvasElement.toDataURL()
@@ -61,6 +67,7 @@ function take_pic(){
61
  canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
62
  canvasCtx.drawImage(video, 0, 0, canvasElement.width, (video.videoHeight / video.videoWidth) * canvasElement.width)
63
  var image = canvasElement.toDataURL()
 
64
  outputImage.src= image
65
  console.log(image)
66
  send_frame(image);
 
37
  function load_camera() {
38
  const constraints = {
39
  video: {
40
+ facingMode: video_facing_mode,
41
+ width: { ideal: 4096 },
42
+ height: { ideal: 2160 }
43
  }
44
  };
45
  // Activate the webcam stream.
46
  navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
47
  video.srcObject = stream;
48
  video.addEventListener("loadeddata", img_load);
49
+ video.addEventListener("loadeddata", ()=>{
50
+ canvasElement.width=video.videoWidth
51
+ canvasElement.height=video.videoHeight
52
+ });
53
  });
54
  }
55
  function img_load(){
56
+
57
  canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
58
  canvasCtx.drawImage(video, 0, 0, canvasElement.width, (video.videoHeight / video.videoWidth) * canvasElement.width)
59
  var image = canvasElement.toDataURL()
 
67
  canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
68
  canvasCtx.drawImage(video, 0, 0, canvasElement.width, (video.videoHeight / video.videoWidth) * canvasElement.width)
69
  var image = canvasElement.toDataURL()
70
+
71
  outputImage.src= image
72
  console.log(image)
73
  send_frame(image);