Example #1
0
        public static uint NumSeparableFilters <T, U>(ObjectDetector <ScanFHogPyramid <T, U> > detector, uint weightIndex = 0)
            where T : class
            where U : class
        {
            if (detector == null)
            {
                throw new ArgumentNullException(nameof(detector));
            }

            detector.ThrowIfDisposed();

            var param = detector.GetFHogPyramidParameter();
            var ret   = NativeMethods.scan_fhog_pyramid_num_separable_filters(param.PyramidType,
                                                                              param.PyramidRate,
                                                                              param.FeatureExtractorType,
                                                                              detector.NativePtr,
                                                                              weightIndex,
                                                                              out var num);

            switch (ret)
            {
            case NativeMethods.ErrorType.FHogNotSupportExtractor:
            case NativeMethods.ErrorType.PyramidNotSupportRate:
            case NativeMethods.ErrorType.PyramidNotSupportType:
                throw new NotSupportedException();
            }

            return(num);
        }
Example #2
0
        public static ObjectDetector <ScanFHogPyramid <T, U> > ThresholdFilterSingularValues <T, U>(ObjectDetector <ScanFHogPyramid <T, U> > detector,
                                                                                                    double threshold,
                                                                                                    uint weightIndex = 0)
            where T : class
            where U : class
        {
            if (detector == null)
            {
                throw new ArgumentNullException(nameof(detector));
            }
            if (threshold < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            detector.ThrowIfDisposed();

            var param = detector.GetFHogPyramidParameter();
            var ret   = NativeMethods.scan_fhog_pyramid_threshold_filter_singular_values(param.PyramidType,
                                                                                         param.PyramidRate,
                                                                                         param.FeatureExtractorType,
                                                                                         detector.NativePtr,
                                                                                         threshold,
                                                                                         weightIndex,
                                                                                         out var newDetector);

            switch (ret)
            {
            case NativeMethods.ErrorType.FHogNotSupportExtractor:
            case NativeMethods.ErrorType.PyramidNotSupportRate:
            case NativeMethods.ErrorType.PyramidNotSupportType:
                throw new NotSupportedException();
            }

            return(new ObjectDetector <ScanFHogPyramid <T, U> >(newDetector, param));
        }