Skip to content

Commit b301ab6

Browse files
committed
Fixed code as per bot review
1 parent 49b5320 commit b301ab6

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/OpenCvSharp/Modules/objdetect/FaceDetectorYN.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class FaceDetectorYN : DisposableCvObject
1717
/// Creates an instance of this class with given parameters.
1818
/// </summary>
1919
/// <param name="model">The path to the requested model</param>
20-
/// <param name="config">The path to the config file for compability, which is not requested for ONNX models</param>
20+
/// <param name="config">The path to the config file for compatibility, which is not requested for ONNX models</param>
2121
/// <param name="inputSize">The size of the input image</param>
2222
/// <param name="scoreThreshold">The threshold to filter out bounding boxes of score smaller than the given value</param>
2323
/// <param name="nmsThreshold">The threshold to suppress bounding boxes of IoU bigger than the given value</param>
@@ -58,9 +58,12 @@ ref _sharedPtr
5858
/// <returns>1 if detection is successful, 0 otherwise.</returns>
5959
public int Detect(Mat image, Mat faces)
6060
{
61+
ThrowIfDisposed();
6162
using InputArray iaImage = new(image);
6263
using OutputArray oaFaces = new(faces);
63-
return NativeMethods.cveFaceDetectorYNDetect(ptr, iaImage.CvPtr, oaFaces.CvPtr);
64+
int result = NativeMethods.cveFaceDetectorYNDetect(ptr, iaImage.CvPtr, oaFaces.CvPtr);
65+
GC.KeepAlive(this);
66+
return result;
6467
}
6568

6669
/// <summary>

src/OpenCvSharpExtern/face_detector_yn.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ void cveFaceDetectorYNRelease(cv::Ptr<cv::FaceDetectorYN>** faceDetector)
4444
#endif
4545
}
4646

47-
int cveFaceDetectorYNDetect(cv::FaceDetectorYN* faceDetetor, cv::_InputArray* image, cv::_OutputArray* faces)
47+
int cveFaceDetectorYNDetect(cv::FaceDetectorYN* faceDetector, cv::_InputArray* image, cv::_OutputArray* faces)
4848
{
4949
#ifdef HAVE_OPENCV_OBJDETECT
50-
return faceDetetor->detect(*image, *faces);
50+
return faceDetector->detect(*image, *faces);
5151
#else
5252
throw_no_objdetect();
5353
#endif

0 commit comments

Comments
 (0)