diff --git a/src/OpenCvSharp/Internal/PInvoke/NativeMethods/objdetect/NativeMethods_objdetect_CascadeClassfier.cs b/src/OpenCvSharp/Internal/PInvoke/NativeMethods/objdetect/NativeMethods_objdetect_CascadeClassfier.cs
index a03d7bbbe..463447270 100644
--- a/src/OpenCvSharp/Internal/PInvoke/NativeMethods/objdetect/NativeMethods_objdetect_CascadeClassfier.cs
+++ b/src/OpenCvSharp/Internal/PInvoke/NativeMethods/objdetect/NativeMethods_objdetect_CascadeClassfier.cs
@@ -12,6 +12,9 @@ namespace OpenCvSharp.Internal
{
static partial class NativeMethods
{
+ [Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern ExceptionStatus objdetect_CascadeClassifier_read(IntPtr obj, IntPtr fn, out int returnValue);
+
[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ExceptionStatus objdetect_CascadeClassifier_new(out IntPtr returnValue);
diff --git a/src/OpenCvSharp/Modules/objdetect/CascadeClassifier.cs b/src/OpenCvSharp/Modules/objdetect/CascadeClassifier.cs
index 5843a690e..488208883 100644
--- a/src/OpenCvSharp/Modules/objdetect/CascadeClassifier.cs
+++ b/src/OpenCvSharp/Modules/objdetect/CascadeClassifier.cs
@@ -87,6 +87,25 @@ public bool Load(string fileName)
return ret != 0;
}
+ ///
+ /// Reads a classifier parameters from a file storage
+ ///
+ ///
+ public virtual bool Read(FileNode fn)
+ {
+ if (ptr == IntPtr.Zero)
+ throw new ObjectDisposedException(GetType().Name);
+ if (fn == null)
+ throw new ArgumentNullException(nameof(fn));
+
+ NativeMethods.HandleException(
+ NativeMethods.objdetect_CascadeClassifier_read(ptr, fn.CvPtr, out var ret));
+ GC.KeepAlive(this);
+ GC.KeepAlive(fn);
+
+ return ret != 0;
+ }
+
///
/// Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
///
diff --git a/src/OpenCvSharpExtern/objdetect.h b/src/OpenCvSharpExtern/objdetect.h
index d79786011..34fde3b48 100644
--- a/src/OpenCvSharpExtern/objdetect.h
+++ b/src/OpenCvSharpExtern/objdetect.h
@@ -43,6 +43,14 @@ CVAPI(ExceptionStatus) objdetect_CascadeClassifier_load(
END_WRAP
}
+CVAPI(ExceptionStatus) objdetect_CascadeClassifier_read(
+ cv::CascadeClassifier* obj, cv::FileNode* fn, int* returnValue)
+{
+ BEGIN_WRAP
+ * returnValue = obj->read(*fn) ? 1 : 0;
+ END_WRAP
+}
+
CVAPI(ExceptionStatus) objdetect_CascadeClassifier_detectMultiScale1(
cv::CascadeClassifier *obj,
cv::Mat *image, std::vector *objects,