Skip to content

Commit 6f9ac82

Browse files
committed
test: add vitest & playwright tests
1 parent 8cb6153 commit 6f9ac82

14 files changed

Lines changed: 1837 additions & 18 deletions

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ jobs:
2222
- run: npm run lint
2323
- run: npm run type-check
2424
- run: npm run build
25+
26+
- name: Run unit tests
27+
run: npm run test:unit
28+
29+
- name: Install Playwright browsers
30+
run: npx playwright install --with-deps chromium
31+
32+
- name: Run e2e tests
33+
run: npm run test:e2e

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ yarn-error.log*
2828
# Testing
2929
coverage/
3030
.nyc_output/
31+
playwright-report
32+
test-results
3133

3234
# Misc
3335
.cache/

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# fisheye.js
22

3-
> Modern fisheye dewarping library for the web, using **General Purpose GPU**
3+
> Modern fisheye dewarping library for the web using **WebGPU** (general-purpose GPU compute)
44
5-
fisheye.js is a javascript library for drawing VideoFrame to the canvas with [simple radial lens distortion](<https://en.wikipedia.org/wiki/Distortion_(optics)>) using **GPGPU** WebGPU(WebGL if your browser does not support WebGPU).
5+
fisheye.js processes [VideoFrame](https://developer.mozilla.org/en-US/docs/Web/API/VideoFrame)s with **WebGPU compute shaders**—no canvas 2D—and corrects fisheye lens distortion using the **OpenCV fisheye camera model** (polynomial in angle θ with coefficients k1–k4), not a simple radial model.
66

77
## Features
88

9-
- ESM support: You can just `import { Fisheye } from @gyeonghokim/fisheye.js;` in your WebAPP
10-
- TypeGPU: WebGPU backend with type-safe shader programing(with [typegpu](https://www.npmjs.com/package/typegpu))
11-
- GPGPU: we do not use canvas element, read from GPU buffer directly(efficient more than other libraries)
12-
- WebCodecs API: Modern Video processing with WebCodecs' [VideoFrame](https://developer.mozilla.org/en-US/docs/Web/API/VideoFrame)
13-
- Installation from modern package managers(npm)
9+
- **WebGPU GPGPU**: Compute-shader pipeline via [TypeGPU](https://www.npmjs.com/package/typegpu); input/output as textures and readback to VideoFrame—no canvas element for dewarping
10+
- **OpenCV fisheye model**: Distortion model `θ_d = θ × (1 + k1·θ² + k2·θ⁴ + k3·θ⁶ + k4·θ⁸)` for accurate calibration
11+
- **WebCodecs**: Built on the [VideoFrame](https://developer.mozilla.org/en-US/docs/Web/API/VideoFrame) API
12+
- **ESM**: `import { Fisheye } from "@gyeonghokim/fisheye.js"`
13+
- **npm**: Install via npm or other package managers
1414

1515
## Getting Started(Typescript Example)
1616

@@ -68,12 +68,12 @@ Creates a new Fisheye dewarper instance.
6868

6969
**Options:**
7070

71-
- `k1` (number, optional): Fisheye distortion coefficient k1. Typical range: -1.0 to 1.0. Default: `0.5`.
71+
- `k1` (number, optional): Fisheye distortion coefficient k1. Typical range: -1.0 to 1.0. Default: `0`.
7272
- `k2` (number, optional): Fisheye distortion coefficient k2. Default: `0`.
7373
- `k3` (number, optional): Fisheye distortion coefficient k3. Default: `0`.
7474
- `k4` (number, optional): Fisheye distortion coefficient k4. Default: `0`.
75-
- `width` (number, optional): Output canvas width. Default: `640`
76-
- `height` (number, optional): Output canvas height. Default: `480`
75+
- `width` (number, optional): Output frame width. Default: `300`
76+
- `height` (number, optional): Output frame height. Default: `150`
7777
- `fov` (number, optional): Field of view in degrees. Default: `180`
7878
- `centerX` (number, optional): X offset of the lens center (normalized, -1.0 to 1.0). Default: `0`
7979
- `centerY` (number, optional): Y offset of the lens center (normalized, -1.0 to 1.0). Default: `0`
@@ -114,7 +114,7 @@ If you receive raw YUV binary data from a camera or server, you can use the `cre
114114
```ts
115115
import { Fisheye, createVideoFrameFromYUV } from "@gyeonghokim/fisheye.js";
116116

117-
const dewarper = new Fisheye({ distortion: 0.5, width: 1920, height: 1080 });
117+
const dewarper = new Fisheye({ k1: 0.5, width: 1920, height: 1080 });
118118

119119
// Example: Receiving NV12 data from a server
120120
const response = await fetch("/api/camera/frame");

0 commit comments

Comments
 (0)