【发布时间】:2021-08-02 22:47:17
【问题描述】:
我正在学习 react 并且 我正在尝试在我的 react 项目中实现一个名为 face-recognition 的 npm 包。
但看起来他们的文档是针对 nodejs 的。我查看了包的源代码,似乎它没有导出任何模块,所以我只是导入了它。但是,我的控制台仍然给我错误 ModuleNotFoundError
简而言之:我可以在我的 react.js 中使用这个 face-recognition 库吗?
这是我在codesandbox中的实时代码
以下是同一文件的原始代码。
import React from "react";
import "face-recognition";
import image1 from "./assets/fFace.jpg";
import image2 from "./assets/mFace.jpg";
const Home = () => {
const imageOne = image1;
const win = new fr.ImageWindow();
// display image
win.setImage(imageOne);
const detector = fr.FaceDetector(imageOne);
// detect all faces
const faceRectangles = detector.locateFaces(imageOne);
return (
<>
<h1>Face Recognition</h1>
{faceRectangles}
</>
);
};
export default Home;
【问题讨论】:
标签: javascript node.js reactjs npm