Commit c8b3410d by vincent

mtcnn - createImageBitmap alternative for nodejs env

parent bfd892e5
import * as tf from '@tensorflow/tfjs-core';
import { Box, createCanvas, getContext2dOrThrow, IDimensions } from 'tfjs-image-recognition-base';
import {
Box,
createCanvas,
createCanvasFromMedia,
env,
getContext2dOrThrow,
IDimensions,
} from 'tfjs-image-recognition-base';
import { normalize } from './normalize';
......@@ -20,7 +27,7 @@ export async function extractImagePatches(
const fromY = y - 1
const imgData = imgCtx.getImageData(fromX, fromY, (ex - fromX), (ey - fromY))
return createImageBitmap(imgData)
return env.isNodejs() ? createCanvasFromMedia(imgData) : createImageBitmap(imgData)
}))
const imagePatchesDatas: number[][] = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment