We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bfd892e commit c8b3410Copy full SHA for c8b3410
src/mtcnn/extractImagePatches.ts
@@ -1,5 +1,12 @@
1
import * as tf from '@tensorflow/tfjs-core';
2
-import { Box, createCanvas, getContext2dOrThrow, IDimensions } from 'tfjs-image-recognition-base';
+import {
3
+ Box,
4
+ createCanvas,
5
+ createCanvasFromMedia,
6
+ env,
7
+ getContext2dOrThrow,
8
+ IDimensions,
9
+} from 'tfjs-image-recognition-base';
10
11
import { normalize } from './normalize';
12
@@ -20,7 +27,7 @@ export async function extractImagePatches(
20
27
const fromY = y - 1
21
28
const imgData = imgCtx.getImageData(fromX, fromY, (ex - fromX), (ey - fromY))
22
29
23
- return createImageBitmap(imgData)
30
+ return env.isNodejs() ? createCanvasFromMedia(imgData) : createImageBitmap(imgData)
24
31
}))
25
32
26
33
const imagePatchesDatas: number[][] = []
0 commit comments