1

I'm trying to create a program that recognices faces from streamed video but am starting with still photos so i'll learn from the bottom up my code so far is:

$ 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
            }
        }
    }
}

When i try to run it i get the "launch with errors?" message saying "one or more files in your project contain errors. Do you want to launch anyway?" I press yes and get "invalid syntax (FacialRecognitionLearning.py, line 2)". Here is the problem, i have no idea where to even start, i understand that the problem is in line 2 but the code looks exactly like in the example im using to learn from (link bellow). https://medium.com/machinelearningadvantage/detect-faces-with-c-and-dlib-in-only-40-lines-of-code-f0bb1b929133 I've tried google and looking at the comments on the guide but can't seem to fix it, i'm really new at this.

  • Means that there is a compile time error and you need to resolve those before you can successfully run the program. What's line 2 of that Cs file? – Jawad Jun 05 '20 at 06:26
  • Aah! I don't even have a cs file, all i have is the code in the post in the same file, the guide didn't say anything about a cs file. – Alu Wassfelt Jun 05 '20 at 06:44
  • Turns out im more of an idiot than i thought.... i've made it in a py framwork, will try to remake it in .NET – Alu Wassfelt Jun 05 '20 at 06:57

0 Answers0