-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* vite 追加 * vite dev で動くようになったので一旦コミット * pnpm run dev * vite + mts 化 * vite config にファイル設定 * dev / build を用意 * examples が pnpm build に成功した * examples のビルド方法を追加 * ビルドと起動 * deploy.yml をシンプルにする * 不要なコード削除 * とりあえず呼び出し * とりあえず vite-plugin-static-copy を使ってみる * ファイル保存 * 画像を bundle するようにする * 粛々と vite 化 * vite 化 * vite 化 * 不要なリンクを削除 * title 修正 * name 入れておく * 整理
- Loading branch information
Showing
37 changed files
with
1,332 additions
and
681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<html lang="ja"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Media Processors Examples</title> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<ul> | ||
<li><a href="/virtual-background/">仮想背景サンプル</a></li> | ||
<li><a href="/light-adjustment/">ライト調整サンプル</a></li> | ||
<li><a href="/light-adjustment-gpu/">ライト調整GPUサンプル</a></li> | ||
<li><a href="/noise-suppression/">ノイズ抑制サンプル</a></li> | ||
</ul> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Media Processors: ライト調整(GPU)サンプル</title> | ||
</head> | ||
|
||
<body> | ||
<h1>Media Processors: ライト調整(GPU)サンプル</h1> | ||
|
||
<h3>入力映像設定</h3> | ||
解像度: <input id="videoWidth" type="number" min="1" max="2000" value="640">x | ||
<input id="videoHeight" type="number" min="1" max="2000" value="360"> | ||
| ||
FPS: <input id="videoFps" type="number" min="1" max="120" value="15"> | ||
<br /> | ||
入力カメラデバイス: <select id="videoDevice" size="1"> | ||
<option>未指定</option> | ||
</select><br /> | ||
モデル: | ||
<select id="model"> | ||
<option value="semantic_guided_llie_1284x720">Semantic-Guided-Low-Light-Image-Enhancement 1284x720</option> | ||
<option selected value="semantic_guided_llie_648x360">Semantic-Guided-Low-Light-Image-Enhancement 648x360</option> | ||
<option value="semantic_guided_llie_648x480">Semantic-Guided-Low-Light-Image-Enhancement 648x480</option> | ||
<option value="semantic_guided_llie_324x240">Semantic-Guided-Low-Light-Image-Enhancement 324x240</option> | ||
</select> | ||
効果強度: <input id="strength" type="range" min="0.0" max="1.0" value="0.5" step="0.05"> | ||
<output id="strengthValue">0.5</output> | ||
<br /> | ||
<input type="button" value="設定反映" id="start"> | ||
|
||
<br /> | ||
|
||
<h3>左: 処理映像、右: オリジナル映像</h3> | ||
|
||
フレーム処理時間: <span id="elapsed">0.0</span> 秒 フレームレート: <span id="fps">0.0</span>FPS<br /> | ||
<video id="videoProcessed" autoplay playsinline style="border: 1px solid blue;"></video> | ||
<video id="videoOriginal" autoplay playsinline style="border: 1px solid red;"></video><br /> | ||
|
||
<script type="module" src="./main.mts"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { LightAdjustmentGpuProcessor } from '@shiguredo/light-adjustment-gpu' | ||
|
||
document.addEventListener('DOMContentLoaded', async () => { | ||
if (!LightAdjustmentGpuProcessor.isSupported()) { | ||
alert('Unsupported platform') | ||
throw Error('Unsupported platform') | ||
} | ||
|
||
let processor: LightAdjustmentGpuProcessor | ||
setInterval(() => { | ||
if (processor !== undefined) { | ||
const elapsed = processor.getAverageProcessedTimeMs() / 1000 | ||
const elapsedElement = document.getElementById('elapsed') as HTMLSpanElement | ||
elapsedElement.textContent = elapsed.toFixed(4).padStart(4, '0') | ||
const fps = processor.getFps() | ||
const fpsElement = document.getElementById('fps') as HTMLSpanElement | ||
fpsElement.textContent = fps.toFixed(2).padStart(5, '0') | ||
} | ||
}, 300) | ||
|
||
function getUserMedia() { | ||
const constraints = { | ||
width: (document.getElementById('videoWidth') as HTMLInputElement).value, | ||
height: (document.getElementById('videoHeight') as HTMLInputElement).value, | ||
frameRate: { ideal: (document.getElementById('videoFps') as HTMLInputElement).value }, | ||
deviceId: (document.getElementById('videoDevice') as HTMLInputElement).value, | ||
} | ||
return navigator.mediaDevices.getUserMedia({ video: constraints }).then((result) => { | ||
updateDeviceList() | ||
return result | ||
}) | ||
} | ||
|
||
let isFirst = true | ||
async function updateDeviceList() { | ||
if (!isFirst) { | ||
return | ||
} | ||
isFirst = false | ||
|
||
const devices = await navigator.mediaDevices.enumerateDevices() | ||
const videoDevices = devices.filter((device) => device.kind === 'videoinput' && device.label) | ||
const select = document.getElementById('videoDevice') as HTMLSelectElement | ||
for (const device of videoDevices) { | ||
const option = document.createElement('option') | ||
option.value = device.deviceId | ||
option.text = device.label | ||
select.appendChild(option) | ||
} | ||
} | ||
|
||
function updateStrength(event: Event) { | ||
if (processor !== undefined) { | ||
processor.setStrength((event.target as HTMLInputElement).value) | ||
} | ||
const strengthValueElement = document.getElementById('strengthValue') | ||
if (strengthValueElement !== null) { | ||
strengthValueElement.textContent = (event.target as HTMLInputElement).value | ||
} | ||
} | ||
|
||
async function start() { | ||
if (processor !== undefined) { | ||
processor.stopProcessing() | ||
} | ||
processor = new LightAdjustmentGpuProcessor( | ||
'', | ||
(document.getElementById('model') as HTMLInputElement).value, | ||
(document.getElementById('strength') as HTMLInputElement).value, | ||
) | ||
|
||
const stream = await getUserMedia() | ||
const videoOriginalElement = document.getElementById('videoOriginal') as HTMLVideoElement | ||
videoOriginalElement.srcObject = stream | ||
|
||
const track = stream.getVideoTracks()[0] | ||
const options = {} | ||
const processedTrack = await processor.startProcessing(track, options) | ||
const videoProcessedElement = document.getElementById('videoProcessed') as HTMLVideoElement | ||
videoProcessedElement.srcObject = new MediaStream([processedTrack]) | ||
|
||
const strengthElement = document.getElementById('strength') as HTMLInputElement | ||
strengthElement.addEventListener('change', updateStrength) | ||
} | ||
|
||
const startButton = document.getElementById('start') as HTMLButtonElement | ||
startButton.addEventListener('click', start) | ||
|
||
start() | ||
}) |
Oops, something went wrong.