Closed pick30 closed 5 years ago
FRDN does not support multi-thread process. This limitation is also on original face_recognition.
Check the https://github.com/takuya-takeuchi/FaceRecognitionDotNet/issues/24#issuecomment-458744002
Yes,I use multi-thread.
I try to use your DlibDotNet not the FaceRecognitionDotNet, write my code to get FaceEncodings and FaceLocations,then it's perfect,Never get the Exception again for now.
The key code is here,it's where the Exception happens,use the lock to avoid the error:
private Rectangle[] locations(Matrix
My english is bad! When I use the lib,I often get Exception at these two places: recognition.FaceLocations(image).ToArray() recognition.FaceEncodings(image).ToArray() the Exception is : System.AccessViolationException: Attempted to read or write protected memory This is often an indication that other memory is corrupt
at DlibDotNet.NativeMethods.frontal_face_detector_matrix_operator2(IntPtr detector, MatrixElementType imgType, IntPtr img, Double adjustThreshold, IntPtr dets) at DlibDotNet.FrontalFaceDetector.Operator(MatrixBase image, IEnumerable
1& detections, Double threshold) at FaceRecognitionDotNet.Dlib.Python.SimpleObjectDetector.RunDetectorWithUpscale1(FrontalFaceDetector detector, Image img, UInt32 upsamplingAmount, Double adjustThreshold, List
1 detectionConfidences, List1 weightIndices) at FaceRecognitionDotNet.Dlib.Python.SimpleObjectDetector.RunDetectorWithUpscale2(FrontalFaceDetector detector, Image image, UInt32 upsamplingAmount) at FaceRecognitionDotNet.FaceRecognition.RawFaceLocations(Image faceImage, Int32 numberOfTimesToUpsample, Model model) at FaceRecognitionDotNet.FaceRecognition.<FaceLocations>d__18.MoveNext() at System.Linq.Buffer
1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable
1 source)My c# code is like this: lock (locker) { Bitmap bitmap = (Bitmap)bmp.Clone(); var array2d = bitmap.ToArray2D();
var image = FaceRecognition.LoadImage(array2d.ToBytes(), array2d.Rows, array2d.Columns, 3);
Location[] locations = recognition.FaceLocations(image).ToArray(); return locations; }
I don't know how it happens? Any one if know how to solve it,thank you,please help me!