Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public static Matrix <byte> DrawFHog <T>(ObjectDetector <T> hogImage, uint weightIndex = 0, int cellDrawSize = 15)
            where T : ImageScanner
        {
            if (hogImage == null)
            {
                throw new ArgumentNullException(nameof(hogImage));
            }
            //// make sure requires clause is not broken
            //DLIB_ASSERT(weight_index < detector.num_detectors(),
            //    "\t matrix draw_fhog()"
            //    << "\n\t Invalid arguments were given to this function. "
            //    << "\n\t weight_index:             " << weight_index
            //    << "\n\t detector.num_detectors(): " << detector.num_detectors()
            //);
            //DLIB_ASSERT(cell_draw_size > 0 && detector.get_w(weight_index).size() >= detector.get_scanner().get_num_dimensions(),
            //    "\t matrix draw_fhog()"
            //    << "\n\t Invalid arguments were given to this function. "
            //    << "\n\t cell_draw_size:                              " << cell_draw_size
            //    << "\n\t weight_index:                                " << weight_index
            //    << "\n\t detector.get_w(weight_index).size():         " << detector.get_w(weight_index).size()
            //    << "\n\t detector.get_scanner().get_num_dimensions(): " << detector.get_scanner().get_num_dimensions()
            //);

            hogImage.ThrowIfDisposed();

            return(hogImage.DrawFHog(weightIndex, cellDrawSize));
        }
Ejemplo n.º 3
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));
        }
        public static Matrix <double> TestObjectDetectionFunction <T, U>(ObjectDetector <T> detector,
                                                                         IEnumerable <Matrix <U> > images,
                                                                         IEnumerable <IEnumerable <Rectangle> > objects)
            where T : ImageScanner
            where U : struct
        {
            if (detector == null)
            {
                throw new ArgumentNullException(nameof(detector));
            }
            if (images == null)
            {
                throw new ArgumentNullException(nameof(images));
            }
            if (objects == null)
            {
                throw new ArgumentNullException(nameof(objects));
            }

            detector.ThrowIfDisposed();
            images.ThrowIfDisposed();

            return(detector.TestObjectDetectionFunction(images, objects));
        }