这是我的代码,我想更改 pointColor 和 lineColor 但我不知道如何? 我正在使用 fast-api.js 库,但没有找到任何具有自定义地标样式的示例。
export const drawResults = async (image, canvas, results, type) => {
if (image && canvas && results) {
const imgSize = image.getBoundingClientRect();
const displaySize = { width: imgSize.width, height: imgSize.height };
faceapi.matchDimensions(canvas, displaySize);
canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
const resizedDetections = faceapi.resizeResults(results, displaySize);
switch (type) {
case 'landmarks':
faceapi.draw.drawFaceLandmarks(canvas, resizedDetections);
break;
case 'expressions':
faceapi.draw.drawFaceExpressions(canvas, resizedDetections);
break;
case 'box':
faceapi.draw.drawDetections(canvas, resizedDetections);
break;
case 'boxLandmarks':
faceapi.draw.drawDetections(canvas, resizedDetections);
faceapi.draw.drawFaceExpressions(canvas, resizedDetections);
faceapi.draw.drawFaceLandmarks(canvas, resizedDetections);
break;
default:
break;
}
}
};
```
利用faceapi中的drawFaceLandmarks函数进行自定义绘制线、线条颜色等
// Custom options for drawing landmarks
const drawOptions = {
drawLines: true, // Enable drawing lines between points
lineColor: 'red', // Custom line color
pointColor: 'blue', // Custom point color
};
在drawfacelandmark函数中传递drawOptions对象 喜欢
faceapi.draw.drawFaceLandmarks(canvas, resizedDetections, drawOptions);