|
1 | 1 | # fisheye.js |
2 | 2 |
|
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) |
4 | 4 |
|
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. |
6 | 6 |
|
7 | 7 | ## Features |
8 | 8 |
|
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 |
14 | 14 |
|
15 | 15 | ## Getting Started(Typescript Example) |
16 | 16 |
|
@@ -68,12 +68,12 @@ Creates a new Fisheye dewarper instance. |
68 | 68 |
|
69 | 69 | **Options:** |
70 | 70 |
|
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`. |
72 | 72 | - `k2` (number, optional): Fisheye distortion coefficient k2. Default: `0`. |
73 | 73 | - `k3` (number, optional): Fisheye distortion coefficient k3. Default: `0`. |
74 | 74 | - `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` |
77 | 77 | - `fov` (number, optional): Field of view in degrees. Default: `180` |
78 | 78 | - `centerX` (number, optional): X offset of the lens center (normalized, -1.0 to 1.0). Default: `0` |
79 | 79 | - `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 |
114 | 114 | ```ts |
115 | 115 | import { Fisheye, createVideoFrameFromYUV } from "@gyeonghokim/fisheye.js"; |
116 | 116 |
|
117 | | -const dewarper = new Fisheye({ distortion: 0.5, width: 1920, height: 1080 }); |
| 117 | +const dewarper = new Fisheye({ k1: 0.5, width: 1920, height: 1080 }); |
118 | 118 |
|
119 | 119 | // Example: Receiving NV12 data from a server |
120 | 120 | const response = await fetch("/api/camera/frame"); |
|
0 commit comments