This is the error I keep getting “Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from ‘System.Drawing.Bitmap’ to ‘byte[,,*]’ MarkAttendanceSystemMVC C:UsersIKUBIEDocumentsDMU 3rd YearDevelopment ProjectMarkAttendanceSystemMVCServicesFacialRecognitionService.cs 33 Active
“
This is now the code
using Emgu.CV;
using Emgu.CV.Structure;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
public class FacialRecognitionService
{
private readonly CascadeClassifier _faceCascade;
public FacialRecognitionService(string cascadeFilePath)
{
_faceCascade = new CascadeClassifier(cascadeFilePath);
}
public List<Rectangle> DetectFaces(Stream imageStream)
{
// Convert the stream to a Bitmap
Bitmap bitmap;
try
{
imageStream.Position = 0; // Reset stream position to ensure it's read correctly
bitmap = new Bitmap(imageStream);
}
catch (Exception e)
{
throw new Exception("Could not convert stream to bitmap: " + e.Message);
}
// Convert the Bitmap to an Image<Bgr, byte>
Image<Bgr, byte> image = new Image<Bgr, byte>(bitmap);
var faces = new List<Rectangle>();
if (image != null)
{
// Perform the face detection
var detectedFaces = _faceCascade.DetectMultiScale(image, 1.1, 10, Size.Empty); // Adjust scale factor (1.1) and minNeighbors (10) according to your needs
faces.AddRange(detectedFaces);
}
return faces;
}
}