我正在尝试创建一个从流式视频中识别人脸的程序,但我从静态照片开始,所以我将从下到上学习我的代码到目前为止是:
$ dotnet new console -o DetectFaces
$ cd DetectFaces
$ dotnet add package DlibDotNet
using System;
using DlibDotNet;
using DlibDotNet.Extensions;
using Dlib = DlibDotNet.Dlib;
namespace FaceDetector
{
/// <summary>
/// The main program class
/// </summary>
class Program
{
// file paths
private const string inputFilePath = "./input.jpg";
/// <summary>
/// The main program entry point
/// </summary>
/// <param name="args">The command line arguments</param>
static void Main(string[] args)
{
// set up Dlib facedetector
using (var fd = Dlib.GetFrontalFaceDetector())
{
// load input image
var img = Dlib.LoadImage<RgbPixel>(inputFilePath);
// find all faces in the image
var faces = fd.Operator(img);
foreach (var face in faces)
{
// draw a rectangle for each face
Dlib.DrawRectangle(img, face, color: new RgbPixel(0, 255, 255), thickness: 4);
}
// export the modified image
Dlib.SaveJpeg(img, "output.jpg");
$ dotnet run
}
}
}
}
当我尝试运行它时,我得到“启动错误?” 消息说“您的项目中的一个或多个文件包含错误。您仍然要启动吗?” 我按是并得到“无效的语法(FacialRecognitionLearning.py,第 2 行)”。这就是问题所在,我什至不知道从哪里开始,我知道问题在第 2 行,但代码看起来与我用来学习的示例中的代码完全相同(链接如下)。https://medium.com/machinelearningadvantage/detect-faces-with-c-and-dlib-in-only-40-lines-of-code-f0bb1b929133 我试过谷歌并查看指南上的评论,但可以'似乎没有解决它,我真的很陌生。