DllNotFoundException: 无法加载 DLL 'cvextern': 找不到指定的模块。 (HRESULT 的异常:0x8007007E)
[HttpPost]
public ActionResult DetectFacesAndBlur(string imagePath)
{
var imageString= imagePath.Split(',')[1];
string base64String = imageString;
Mat image = new Mat();
// Convert the base64 string to a byte array
byte[] imageBytes = Convert.FromBase64String(base64String);
CvInvoke.Imdecode(imageBytes, ImreadModes.Color, image);
// Load a pre-trained face recognition model
EigenFaceRecognizer recognizer = new EigenFaceRecognizer();
recognizer.Read("face_recognition_model.xml");
// Detect faces in the image
Emgu.CV.CascadeClassifier faceCascade = new CascadeClassifier("haarcascade_frontalface_default.xml");
Rectangle[] faces = faceCascade.DetectMultiScale(image, 1.1, 3,Size.Empty);
bool isFaceDetected = faces.Length > 0;
bool isBlurred = 22 > 100;
// Return the result
return Json(new { IsBlurred = isBlurred, IsFaceDetected = isFaceDetected });
}