aryan365 commited on
Commit
a2b026f
·
verified ·
1 Parent(s): 51c546d

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +13 -1
templates/index.html CHANGED
@@ -89,6 +89,7 @@
89
  // Take picture button event listener
90
  takePictureBtn.addEventListener('click', () => {
91
  predictionElem.textContent = '';
 
92
  const canvas = document.createElement('canvas');
93
  canvas.width = video.videoWidth;
94
  canvas.height = video.videoHeight;
@@ -97,7 +98,18 @@
97
 
98
  // Convert the image to base64
99
  const imageData = canvas.toDataURL('image/jpeg');
100
-
 
 
 
 
 
 
 
 
 
 
 
101
  if (showVegetablePrediction) {
102
  // Send the image to the server for vegetable prediction
103
  fetch('/predict', {
 
89
  // Take picture button event listener
90
  takePictureBtn.addEventListener('click', () => {
91
  predictionElem.textContent = '';
92
+ predictionElem2.textContent = '';
93
  const canvas = document.createElement('canvas');
94
  canvas.width = video.videoWidth;
95
  canvas.height = video.videoHeight;
 
98
 
99
  // Convert the image to base64
100
  const imageData = canvas.toDataURL('image/jpeg');
101
+ fetch('/ocr', {
102
+ method: 'POST',
103
+ headers: {
104
+ 'Content-Type': 'application/json',
105
+ },
106
+ body: JSON.stringify({ image: imageData }),
107
+ })
108
+ .then(response => response.json())
109
+ .then(data => {
110
+ predictionElem2.textContent = `bool: ${data.text_present.join(', ')}`; // Update vegetable prediction
111
+ })
112
+ .catch(err => console.error('Error:', err));
113
  if (showVegetablePrediction) {
114
  // Send the image to the server for vegetable prediction
115
  fetch('/predict', {