OpenCvSharp.HOGDescriptor.DetectMultiScaleROI C# (CSharp) Method

DetectMultiScaleROI() public method

evaluate specified ROI and return confidence value for each location in multiple scales
public DetectMultiScaleROI ( OpenCvSharp.Mat img, Rect &foundLocations, DetectionROI &locations, double hitThreshold, int groupThreshold ) : void
img OpenCvSharp.Mat
foundLocations Rect
locations DetectionROI
hitThreshold double
groupThreshold int
return void
        public void DetectMultiScaleROI(
            Mat img,
            out Rect[] foundLocations,
            out DetectionROI[] locations,
            double hitThreshold = 0,
            int groupThreshold = 0)
        {
            if (disposed)
                throw new ObjectDisposedException("HOGDescriptor");
            if (img == null)
                throw new ArgumentNullException(nameof(img));
            img.ThrowIfDisposed();

            using (var flVec = new VectorOfRect())
            using (var scalesVec = new VectorOfDouble())
            using (var locationsVec = new VectorOfVectorPoint())
            using (var confidencesVec = new VectorOfVectorDouble())
            {
                NativeMethods.objdetect_HOGDescriptor_detectMultiScaleROI(
                    ptr, img.CvPtr, flVec.CvPtr, 
                    scalesVec.CvPtr, locationsVec.CvPtr, confidencesVec.CvPtr,
                    hitThreshold, groupThreshold);
                foundLocations = flVec.ToArray();

                double[] s = scalesVec.ToArray();
                Point[][] l = locationsVec.ToArray();
                double[][] c = confidencesVec.ToArray();

                if(s.Length != l.Length || l.Length != c.Length)
                    throw new OpenCvSharpException("Invalid result data 'locations'");
                locations = new DetectionROI[s.Length];
                for (int i = 0; i < s.Length; i++)
                {
                    locations[i] = new DetectionROI
                    {
                        Scale = s[i],
                        Locations = l[i],
                        Confidences = c[i]
                    };
                }
            }
        }