takuya-takeuchi / DlibDotNet

Dlib .NET wrapper written in C++ and C# for Windows, MacOS, Linux and iOS
MIT License
484 stars 134 forks source link

System.Runtime.InteropServices.SEHException:An exception occurred in an external component #223

Open 147906825 opened 3 years ago

147906825 commented 3 years ago

Summary of your issue

Environment

vs 2019

What did you do when you faced the problem?

System.Runtime.InteropServices.SEHException:An exception occurred in an external component

Example code:

public MainForm() { this.InitializeComponent();
this._ShapePredictor = ShapePredictor.Deserialize("shape_predictor_81_face_landmarks.dat"); this._BackgroundWorker = new BackgroundWorker(); this._BackgroundWorker.DoWork += this.BackgroundWorkerOnDoWork; }

public static ImageWindow.OverlayLine[] RenderFaceDetections(IEnumerable shapes) { return RenderFaceDetections(shapes, new RgbPixel { Green = 255 }); }

    public static ImageWindow.OverlayLine[] RenderFaceDetections(IEnumerable<FullObjectDetection> detection, RgbPixel color)
    {
        if (detection == null)
            throw new ArgumentNullException(nameof(detection));

        using (var vectorIn = new StdVector<FullObjectDetection>(detection))
        using (var vectorOut = new StdVector<ImageWindow.OverlayLine>())
        {
            NativeMethods.render_face_detections(vectorIn.NativePtr, ref color, vectorOut.NativePtr);
            return vectorOut.ToArray();
        }
    }

Output:

System.Runtime.InteropServices.SEHException:An exception occurred in an external component

What did you intend to be?

takuya-takeuchi commented 3 years ago

@takuya-takeuchi Please attach a minimum sample program to reproduce it.

I guess exception occurs in BackgroundWorkerOnDoWork but I'm not sure.

takuya-takeuchi commented 3 years ago

@147906825 Sorry. I found that this program is examples\WinForms\FaceLandmarkDetection.

But this program works fine by using latest DlibDotNet.

image