public DLibFaceIdentification(IImageRotationService imageRotationService)
        {
            this.imageRotationService = imageRotationService ?? throw new ArgumentNullException(nameof(imageRotationService));
            detector = Dlib.GetFrontalFaceDetector();

            // set up a 5-point landmark detector
            predictor = ShapePredictor.Deserialize("model/shape_predictor_5_face_landmarks.dat");

            // set up a neural network for face recognition
            dnn = DlibDotNet.Dnn.LossMetric.Deserialize("model/dlib_face_recognition_resnet_model_v1.dat");

            // create a color palette for plotting
            palette = new RgbPixel[]
            {
                new RgbPixel(0xe6, 0x19, 0x4b),
                new RgbPixel(0xf5, 0x82, 0x31),
                new RgbPixel(0xff, 0xe1, 0x19),
                new RgbPixel(0xbc, 0xf6, 0x0c),
                new RgbPixel(0x3c, 0xb4, 0x4b),
                new RgbPixel(0x46, 0xf0, 0xf0),
                new RgbPixel(0x43, 0x63, 0xd8),
                new RgbPixel(0x91, 0x1e, 0xb4),
                new RgbPixel(0xf0, 0x32, 0xe6),
                new RgbPixel(0x80, 0x80, 0x80)
            };
        }
Exemple #2
0
        public static async Task <Array2D <RgbPixel> > LoadRotatedImage(IImageRotationService imageRotationService, string filename)
        {
            var result = await imageRotationService.GetImageRotationDegreesAsync(filename);

            var radiansRotation = result switch
            {
                0 => 0,
                180 => Math.PI,
                90 => 4.71238898038469D, // 1.5 * Math.PI
                270 => 1.5707963267949D, // 0.5 * Math.PI
                _ => 0
            };

            var origImg = Dlib.LoadImage <RgbPixel>(filename);

            if (radiansRotation == 0d)
            {
                return(origImg);
            }

            // load the image
            var img = new Array2D <RgbPixel>();

            Dlib.RotateImage(origImg, img, radiansRotation, InterpolationTypes.Bilinear);

            origImg.Dispose();
            return(img);
        }
    }
Exemple #3
0
 public ImageWithoutCanvasCaptionService(
     IImageCaptionService imageCaptionService,
     IImageRotationService imageRotationService,
     ILogger logger)
 {
     _imageCaptionService  = imageCaptionService;
     _imageRotationService = imageRotationService;
     _logger = logger;
 }
        public DLibFaceIdentificationService(IImageRotationService imageRotationService)
        {
            this.imageRotationService = imageRotationService ?? throw new ArgumentNullException(nameof(imageRotationService));

            // set up a 5-point landmark detector
            predictor = ShapePredictor.Deserialize("model/shape_predictor_5_face_landmarks.dat");

            // set up a neural network for face recognition
            dnn = DlibDotNet.Dnn.LossMetric.Deserialize("model/dlib_face_recognition_resnet_model_v1.dat");
        }
Exemple #5
0
 public ImageWithCanvasCaptionService(
     int?canvasHeight,
     int?canvasWidth,
     IImageCaptionService imageCaptionService,
     IImageRotationService imageRotationService,
     ILogger logger)
 {
     _canvasHeight         = canvasHeight ?? throw new ArgumentNullException(nameof(canvasHeight));
     _canvasWidth          = canvasWidth ?? throw new ArgumentNullException(nameof(canvasWidth));
     _imageCaptionService  = imageCaptionService;
     _imageRotationService = imageRotationService;
     _logger = logger;
 }
Exemple #6
0
 public DLibRectangleExtractor(IImageRotationService imageRotationService)
 {
     this.imageRotationService = imageRotationService;
 }
Exemple #7
0
 public DLibHog([NotNull] IImageRotationService imageRotationService)
 {
     this.imageRotationService = imageRotationService ?? throw new ArgumentNullException(nameof(imageRotationService));
     detector = Dlib.GetFrontalFaceDetector();
 }