face-api.js从磁盘加载图像文件 [英] face-api.js load image file from disk

查看:283
本文介绍了face-api.js从磁盘加载图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下操作,使用face-api.js从磁盘加载图像:

I tried the following to load an image from disk using face-api.js:

faceapi.fetchImage(path.resolve(INPUT_DIR, 'input1.jpg');

它引发以下错误:Error: fetch - missing fetch implementation for nodejs environment

It throws the following error: Error: fetch - missing fetch implementation for nodejs environment

还有其他从磁盘加载图像并使用nodejs显示的方法吗?

Is there any other way of load image from disk and displaying using nodejs?

推荐答案

之所以失败,是因为您需要实现fetch函数才能使其工作.尝试从网上检索图像时,应使用FetchImage.如果您正在使用本地磁盘中的映像,请执行以下操作:

The reason it fails because you need to implements the fetch function for it to work. FetchImage should be used when you are trying to retrieve the image from online. If you are using the image from local disk, then do this:

  1. 从本地磁盘加载模块.

  1. Load the modules from local disk.

await faceapi.nets.ssdMobilenetv1.loadFromDisk(path.join(__dirname, 'models'));

//对我来说,我已将所有模块放入src/models/

// for me, I have put all the modules in src/models/

加载画布

传递canvas和modules选项(如果有)

Pass the canvas and modules option (if any)

let detectionresult = awaitfaceapi.detectAllFaces(canvas, this.getSSNMobileOptions())

这篇关于face-api.js从磁盘加载图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆