Skip to content

Commit 25f0cb2

Browse files
docs: buffer type update
1 parent 882b9c5 commit 25f0cb2

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

docs/pages/apidetails.md

+18-8
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,26 @@ base64ToMat(data: string): Mat;
140140
### Mat to Buffer
141141
Convert Mat object to Uint8Array or Float32Array based on value of parameter and returns with number of cols, rows and channels.
142142

143-
```js
144-
matToBuffer(
143+
```ts
144+
matToBuffer<T extends keyof BufferType>(
145145
mat: Mat,
146-
type: 'uint8'
147-
): { cols: number; rows: number; channels: number; buffer: Uint8Array };
146+
type: T
147+
): { cols: number; rows: number; channels: number; buffer: BufferType[T] };
148+
```
148149

149-
matToBuffer(
150-
mat: Mat,
151-
type: 'float32'
152-
): { cols: number; rows: number; channels: number; buffer: Float32Array };
150+
where `BufferType` is:
151+
152+
```ts
153+
type BufferType = {
154+
uint8: Uint8Array;
155+
uint16: Uint16Array;
156+
uint32: Uint32Array;
157+
int8: Int8Array;
158+
int16: Int16Array;
159+
int32: Int32Array;
160+
float32: Float32Array;
161+
float64: Float64Array;
162+
};
153163
```
154164

155165
## Functions

0 commit comments

Comments
 (0)