BK-V commited on
Commit
1049c26
·
1 Parent(s): e146850

change ui style

Browse files
Files changed (1) hide show
  1. index.html +222 -101
index.html CHANGED
@@ -4,141 +4,258 @@
4
  <meta charset="UTF-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
  <title>Camera Interaction App</title>
 
 
7
  <style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  body {
9
- font-family: sans-serif;
 
 
10
  display: flex;
11
  flex-direction: column;
12
  align-items: center;
13
- gap: 20px;
14
- padding: 20px;
15
- background-color: #f0f0f0;
16
  }
17
- .controls,
18
- .io-areas {
19
- display: flex;
20
- gap: 10px;
21
- align-items: center;
22
- background-color: #fff;
23
- padding: 15px;
24
- border-radius: 8px;
25
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
26
  }
27
- .io-areas {
 
 
 
28
  flex-direction: column;
29
- align-items: stretch;
30
  }
31
- textarea {
32
- width: 300px;
33
- height: 80px;
34
- padding: 8px;
35
- border: 1px solid #ccc;
36
- border-radius: 4px;
37
- font-size: 14px;
 
 
 
 
38
  }
39
  #videoFeed {
40
- display: block;
41
  width: 100%;
42
  height: 100%;
43
- border-radius: 6px;
44
  object-fit: cover;
45
- }
46
- #videoContainer {
47
- position: relative;
48
- width: 480px;
49
- height: 360px;
50
- border: 2px solid #333;
51
- background-color: #000;
52
- border-radius: 8px;
53
- margin: 0 auto;
54
  }
55
  #loadingOverlay {
56
  position: absolute;
57
- top: 0;
58
- left: 0;
59
- width: 100%;
60
- height: 100%;
61
  display: none;
62
  justify-content: center;
63
  align-items: center;
64
- background-color: rgba(0, 0, 0, 0.7);
65
  z-index: 10;
66
- border-radius: 6px;
67
- color: #ffffff;
68
  font-size: 1.5em;
69
  font-weight: bold;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
  #startButton {
72
- padding: 10px 20px;
73
- font-size: 16px;
 
74
  cursor: pointer;
75
  border: none;
76
- border-radius: 4px;
77
- color: white;
 
 
78
  }
79
  #startButton.start {
80
- background-color: #28a745; /* Green */
81
  }
82
  #startButton.stop {
83
- background-color: #dc3545; /* Red */
84
- }
85
- label {
86
- font-weight: bold;
87
- }
88
- select {
89
- padding: 8px;
90
- border-radius: 4px;
91
- border: 1px solid #ccc;
92
  }
93
  .hidden {
94
  display: none;
95
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  </style>
97
  </head>
98
  <body>
99
- <h1>Camera Interaction App</h1>
100
-
101
- <div id="videoContainer">
102
- <video id="videoFeed" autoplay playsinline></video>
103
- <div id="loadingOverlay">Loading...</div>
104
- </div>
105
- <canvas id="canvas" class="hidden"></canvas>
106
- <!-- For capturing frames -->
107
-
108
- <div class="io-areas">
109
- <div>
110
- <label for="instructionText">Instruction:</label><br />
111
- <textarea
112
- id="instructionText"
113
- style="height: 2em; width: 40em"
114
- name="Instruction"
115
- ></textarea>
116
  </div>
117
- <div>
118
- <label for="responseText">Response:</label><br />
119
- <textarea
120
- id="responseText"
121
- style="height: 2em; width: 40em"
122
- name="Response"
123
- readonly
124
- placeholder="Server response will appear here..."
125
- ></textarea>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  </div>
127
  </div>
128
-
129
- <div class="controls">
130
- <label for="intervalSelect">Interval between 2 requests:</label>
131
- <select id="intervalSelect" name="Interval between 2 requests">
132
- <option value="0" selected>0ms</option>
133
- <option value="100">100ms</option>
134
- <option value="250">250ms</option>
135
- <option value="500">500ms</option>
136
- <option value="1000">1s</option>
137
- <option value="2000">2s</option>
138
- </select>
139
- <button id="startButton" class="start">Start</button>
140
- </div>
141
-
142
  <script type="module">
143
  import {
144
  AutoProcessor,
@@ -158,13 +275,13 @@
158
 
159
  const video = document.getElementById("videoFeed");
160
  const canvas = document.getElementById("canvas");
161
- const instructionText = document.getElementById("instructionText");
162
  const responseText = document.getElementById("responseText");
163
  const intervalSelect = document.getElementById("intervalSelect");
164
  const startButton = document.getElementById("startButton");
165
  const loadingOverlay = document.getElementById("loadingOverlay");
166
 
167
- instructionText.value = "What do you see?"; // default instruction
168
  const CONTEXT = `
169
  Translate the text into persian and only return the translated text without any other text.
170
  `
@@ -295,7 +412,7 @@
295
 
296
  async function sendData() {
297
  if (!isProcessing) return;
298
- const instruction = instructionText.value;
299
  const rawImg = captureImage();
300
  if (!rawImg) {
301
  responseText.value = "Capture failed";
@@ -328,18 +445,18 @@
328
  return;
329
  }
330
  isProcessing = true;
331
- startButton.textContent = "Stop";
332
  startButton.classList.replace("start", "stop");
333
- instructionText.disabled = true;
334
  intervalSelect.disabled = true;
335
  responseText.value = "Processing started...";
336
  processingLoop();
337
  }
338
  function handleStop() {
339
  isProcessing = false;
340
- startButton.textContent = "Start";
341
  startButton.classList.replace("stop", "start");
342
- instructionText.disabled = false;
343
  intervalSelect.disabled = false;
344
  if (responseText.value.startsWith("Processing started...")) {
345
  responseText.value = "Processing stopped.";
@@ -368,6 +485,10 @@
368
  }
369
  await initModel();
370
  await initCamera();
 
 
 
 
371
  });
372
  window.addEventListener("beforeunload", () => {
373
  if (stream) {
 
4
  <meta charset="UTF-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
  <title>Camera Interaction App</title>
7
+ <!-- Add Vazirmatn Persian font from Google Fonts -->
8
+ <link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;600;700&display=swap" rel="stylesheet">
9
  <style>
10
+ :root {
11
+ --primary: #2563eb;
12
+ --primary-dark: #1e40af;
13
+ --danger: #dc2626;
14
+ --success: #16a34a;
15
+ --bg: #f8fafc;
16
+ --surface: #ffffff;
17
+ --border: #e5e7eb;
18
+ --shadow: 0 4px 24px 0 rgba(30, 41, 59, 0.08);
19
+ --radius: 14px;
20
+ --font: 'Vazirmatn', 'Inter', 'Segoe UI', Arial, sans-serif;
21
+ }
22
+ html, body {
23
+ height: 100%;
24
+ margin: 0;
25
+ padding: 0;
26
+ }
27
  body {
28
+ font-family: var(--font);
29
+ background: var(--bg);
30
+ min-height: 100vh;
31
  display: flex;
32
  flex-direction: column;
33
  align-items: center;
34
+ gap: 32px;
35
+ padding: 40px 0;
 
36
  }
37
+ h1 {
38
+ color: var(--primary-dark);
39
+ font-size: 2.2rem;
40
+ font-weight: 700;
41
+ margin-bottom: 0;
42
+ text-align: center;
43
+ width: 100%;
44
+ max-width: 700px;
 
45
  }
46
+ .container {
47
+ width: 100%;
48
+ max-width: 700px;
49
+ display: flex;
50
  flex-direction: column;
51
+ gap: 32px;
52
  }
53
+ #videoContainer {
54
+ position: relative;
55
+ width: 100%;
56
+ max-width: 520px;
57
+ aspect-ratio: 4/3;
58
+ border-radius: var(--radius);
59
+ overflow: hidden;
60
+ box-shadow: var(--shadow);
61
+ border: 1.5px solid var(--border);
62
+ background: #000;
63
+ margin: 0 auto;
64
  }
65
  #videoFeed {
 
66
  width: 100%;
67
  height: 100%;
 
68
  object-fit: cover;
69
+ border-radius: var(--radius);
70
+ display: block;
 
 
 
 
 
 
 
71
  }
72
  #loadingOverlay {
73
  position: absolute;
74
+ inset: 0;
 
 
 
75
  display: none;
76
  justify-content: center;
77
  align-items: center;
78
+ background: rgba(30, 41, 59, 0.7);
79
  z-index: 10;
80
+ color: #fff;
 
81
  font-size: 1.5em;
82
  font-weight: bold;
83
+ border-radius: var(--radius);
84
+ text-align: right;
85
+ }
86
+ .io-areas {
87
+ display: flex;
88
+ flex-direction: column;
89
+ gap: 18px;
90
+ background: var(--surface);
91
+ border-radius: var(--radius);
92
+ box-shadow: var(--shadow);
93
+ padding: 24px 28px;
94
+ align-items: stretch;
95
+ border: 1.5px solid var(--border);
96
+ }
97
+ .io-areas > div {
98
+ display: flex;
99
+ flex-direction: column;
100
+ align-items: flex-start;
101
+ gap: 6px;
102
+ }
103
+ label {
104
+ font-weight: 600;
105
+ color: var(--primary-dark);
106
+ font-size: 1rem;
107
+ text-align: right;
108
+ width: 100%;
109
+ }
110
+ textarea {
111
+ width: 100%;
112
+ min-width: 320px;
113
+ max-width: 600px;
114
+ height: 8em;
115
+ min-height: 8em;
116
+ max-height: 8em;
117
+ padding: 10px 14px;
118
+ border: 1.5px solid var(--border);
119
+ border-radius: 8px;
120
+ font-size: 1rem;
121
+ background: var(--bg);
122
+ color: #222;
123
+ resize: vertical;
124
+ box-sizing: border-box;
125
+ text-align: right;
126
+ transition: border 0.2s;
127
+ }
128
+ textarea:focus {
129
+ border-color: var(--primary);
130
+ outline: none;
131
+ background: #f1f5f9;
132
+ }
133
+ .controls {
134
+ display: flex;
135
+ gap: 18px;
136
+ align-items: center;
137
+ background: var(--surface);
138
+ padding: 18px 28px;
139
+ border-radius: var(--radius);
140
+ box-shadow: var(--shadow);
141
+ border: 1.5px solid var(--border);
142
+ justify-content: flex-start;
143
+ }
144
+ .controls label {
145
+ margin-bottom: 0;
146
+ font-size: 1rem;
147
+ color: #334155;
148
+ font-weight: 500;
149
+ text-align: right;
150
+ width: auto;
151
+ }
152
+ select {
153
+ padding: 8px 14px;
154
+ border-radius: 8px;
155
+ border: 1.5px solid var(--border);
156
+ font-size: 1rem;
157
+ background: var(--bg);
158
+ color: #222;
159
+ text-align: right;
160
+ min-width: 90px;
161
+ transition: border 0.2s;
162
+ }
163
+ select:focus {
164
+ border-color: var(--primary);
165
+ outline: none;
166
  }
167
  #startButton {
168
+ padding: 10px 28px;
169
+ font-size: 1.1rem;
170
+ font-weight: 600;
171
  cursor: pointer;
172
  border: none;
173
+ border-radius: 8px;
174
+ color: #fff;
175
+ transition: background 0.2s, box-shadow 0.2s;
176
+ box-shadow: 0 2px 8px 0 rgba(37, 99, 235, 0.08);
177
  }
178
  #startButton.start {
179
+ background: var(--success);
180
  }
181
  #startButton.stop {
182
+ background: var(--danger);
 
 
 
 
 
 
 
 
183
  }
184
  .hidden {
185
  display: none;
186
  }
187
+ /* Right-align all text elements */
188
+ *:not(input):not(textarea) {
189
+ direction: rtl;
190
+ }
191
+ textarea, select, input {
192
+ direction: rtl;
193
+ }
194
+ /* Responsive */
195
+ @media (max-width: 800px) {
196
+ .container {
197
+ max-width: 98vw;
198
+ }
199
+ #videoContainer {
200
+ max-width: 98vw;
201
+ }
202
+ textarea {
203
+ min-width: 0;
204
+ max-width: 98vw;
205
+ }
206
+ }
207
+ @media (max-width: 600px) {
208
+ .io-areas, .controls {
209
+ padding: 12px 6px;
210
+ }
211
+ h1 {
212
+ font-size: 1.3rem;
213
+ }
214
+ }
215
  </style>
216
  </head>
217
  <body>
218
+ <div class="container">
219
+ <h1>مدل زبانی-بصری فارسی</h1>
220
+ <div id="videoContainer">
221
+ <video id="videoFeed" autoplay playsinline></video>
222
+ <div id="loadingOverlay">در حال بارگذاری...</div>
 
 
 
 
 
 
 
 
 
 
 
 
223
  </div>
224
+ <canvas id="canvas" class="hidden"></canvas>
225
+ <div class="io-areas">
226
+ <!-- <div>
227
+ <label for="instructionText">دستورالعمل:</label>
228
+ <textarea
229
+ id="instructionText"
230
+ name="Instruction"
231
+ placeholder="دستورالعمل خود را وارد کنید..."
232
+ ></textarea>
233
+ </div> -->
234
+ <div>
235
+ <label for="responseText">پاسخ:</label>
236
+ <textarea
237
+ id="responseText"
238
+ name="Response"
239
+ readonly
240
+ placeholder="پاسخ سرور اینجا نمایش داده می‌شود..."
241
+ rows="4"
242
+ cols="50"
243
+ ></textarea>
244
+ </div>
245
+ </div>
246
+ <div class="controls">
247
+ <label for="intervalSelect">فاصله بین دو درخواست:</label>
248
+ <select id="intervalSelect" name="Interval between 2 requests">
249
+ <option value="0" selected>۰ میلی‌ثانیه</option>
250
+ <option value="100">۱۰۰ میلی‌ثانیه</option>
251
+ <option value="250">۲۵۰ میلی‌ثانیه</option>
252
+ <option value="500">۵۰۰ میلی‌ثانیه</option>
253
+ <option value="1000">۱ ثانیه</option>
254
+ <option value="2000">۲ ثانیه</option>
255
+ </select>
256
+ <button id="startButton" class="start">شروع</button>
257
  </div>
258
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  <script type="module">
260
  import {
261
  AutoProcessor,
 
275
 
276
  const video = document.getElementById("videoFeed");
277
  const canvas = document.getElementById("canvas");
278
+ // const instructionText = document.getElementById("instructionText");
279
  const responseText = document.getElementById("responseText");
280
  const intervalSelect = document.getElementById("intervalSelect");
281
  const startButton = document.getElementById("startButton");
282
  const loadingOverlay = document.getElementById("loadingOverlay");
283
 
284
+ // instructionText.value = "What do you see?"; // default instruction (Persian)
285
  const CONTEXT = `
286
  Translate the text into persian and only return the translated text without any other text.
287
  `
 
412
 
413
  async function sendData() {
414
  if (!isProcessing) return;
415
+ const instruction = "What do you see?";
416
  const rawImg = captureImage();
417
  if (!rawImg) {
418
  responseText.value = "Capture failed";
 
445
  return;
446
  }
447
  isProcessing = true;
448
+ startButton.textContent = "توقف";
449
  startButton.classList.replace("start", "stop");
450
+ // instructionText.disabled = true;
451
  intervalSelect.disabled = true;
452
  responseText.value = "Processing started...";
453
  processingLoop();
454
  }
455
  function handleStop() {
456
  isProcessing = false;
457
+ startButton.textContent = "شروع";
458
  startButton.classList.replace("stop", "start");
459
+ // instructionText.disabled = false;
460
  intervalSelect.disabled = false;
461
  if (responseText.value.startsWith("Processing started...")) {
462
  responseText.value = "Processing stopped.";
 
485
  }
486
  await initModel();
487
  await initCamera();
488
+ // Set placeholders and button text to Persian on load
489
+ // instructionText.placeholder = "دستورالعمل خود را وارد کنید...";
490
+ responseText.placeholder = "پاسخ سرور اینجا نمایش داده می‌شود...";
491
+ startButton.textContent = isProcessing ? "توقف" : "شروع";
492
  });
493
  window.addEventListener("beforeunload", () => {
494
  if (stream) {