@@ -352,22 +352,54 @@ struct DetectionROI
352
352
std::vector<double > confidences;
353
353
};
354
354
355
- /* *@example peopledetect.cpp
355
+ /* *@brief Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector.
356
+
357
+ the HOG descriptor algorithm introduced by Navneet Dalal and Bill Triggs @cite Dalal2005 .
358
+
359
+ useful links:
360
+
361
+ https://hal.inria.fr/inria-00548512/document/
362
+
363
+ https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients
364
+
365
+ https://software.intel.com/en-us/ipp-dev-reference-histogram-of-oriented-gradients-hog-descriptor
366
+
367
+ http://www.learnopencv.com/histogram-of-oriented-gradients
368
+
369
+ http://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-tutorial
370
+
356
371
*/
357
372
struct CV_EXPORTS_W HOGDescriptor
358
373
{
359
374
public:
360
- enum { L2Hys = 0
375
+ enum { L2Hys = 0 // !< Default histogramNormType
361
376
};
362
- enum { DEFAULT_NLEVELS = 64
377
+ enum { DEFAULT_NLEVELS = 64 // !< Default nlevels value.
363
378
};
379
+ /* *@brief Creates the HOG descriptor and detector with default params.
364
380
381
+ aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9, 1 )
382
+ */
365
383
CV_WRAP HOGDescriptor () : winSize(64 ,128 ), blockSize(16 ,16 ), blockStride(8 ,8 ),
366
384
cellSize(8 ,8 ), nbins(9 ), derivAperture(1 ), winSigma(-1 ),
367
385
histogramNormType(HOGDescriptor::L2Hys), L2HysThreshold(0.2 ), gammaCorrection(true ),
368
386
free_coef(-1 .f), nlevels(HOGDescriptor::DEFAULT_NLEVELS), signedGradient(false )
369
387
{}
370
388
389
+ /* * @overload
390
+ @param _winSize sets winSize with given value.
391
+ @param _blockSize sets blockSize with given value.
392
+ @param _blockStride sets blockStride with given value.
393
+ @param _cellSize sets cellSize with given value.
394
+ @param _nbins sets nbins with given value.
395
+ @param _derivAperture sets derivAperture with given value.
396
+ @param _winSigma sets winSigma with given value.
397
+ @param _histogramNormType sets histogramNormType with given value.
398
+ @param _L2HysThreshold sets L2HysThreshold with given value.
399
+ @param _gammaCorrection sets gammaCorrection with given value.
400
+ @param _nlevels sets nlevels with given value.
401
+ @param _signedGradient sets signedGradient with given value.
402
+ */
371
403
CV_WRAP HOGDescriptor (Size _winSize, Size _blockSize, Size _blockStride,
372
404
Size _cellSize, int _nbins, int _derivAperture=1 , double _winSigma=-1 ,
373
405
int _histogramNormType=HOGDescriptor::L2Hys,
@@ -379,97 +411,262 @@ struct CV_EXPORTS_W HOGDescriptor
379
411
gammaCorrection(_gammaCorrection), free_coef(-1 .f), nlevels(_nlevels), signedGradient(_signedGradient)
380
412
{}
381
413
414
+ /* * @overload
415
+ @param filename the file name containing HOGDescriptor properties and coefficients of the trained classifier
416
+ */
382
417
CV_WRAP HOGDescriptor (const String& filename)
383
418
{
384
419
load (filename);
385
420
}
386
421
422
+ /* * @overload
423
+ @param d the HOGDescriptor which cloned to create a new one.
424
+ */
387
425
HOGDescriptor (const HOGDescriptor& d)
388
426
{
389
427
d.copyTo (*this );
390
428
}
391
429
430
+ /* *@brief Default destructor.
431
+ */
392
432
virtual ~HOGDescriptor () {}
393
433
434
+ /* *@brief Returns the number of coefficients required for the classification.
435
+ */
394
436
CV_WRAP size_t getDescriptorSize () const ;
437
+
438
+ /* * @brief Checks if detector size equal to descriptor size.
439
+ */
395
440
CV_WRAP bool checkDetectorSize () const ;
441
+
442
+ /* * @brief Returns winSigma value
443
+ */
396
444
CV_WRAP double getWinSigma () const ;
397
445
446
+ /* *@example peopledetect.cpp
447
+ */
448
+ /* *@brief Sets coefficients for the linear SVM classifier.
449
+ @param _svmdetector coefficients for the linear SVM classifier.
450
+ */
398
451
CV_WRAP virtual void setSVMDetector (InputArray _svmdetector);
399
452
453
+ /* * @brief Reads HOGDescriptor parameters from a file node.
454
+ @param fn File node
455
+ */
400
456
virtual bool read (FileNode& fn);
457
+
458
+ /* * @brief Stores HOGDescriptor parameters in a file storage.
459
+ @param fs File storage
460
+ @param objname Object name
461
+ */
401
462
virtual void write (FileStorage& fs, const String& objname) const ;
402
463
464
+ /* * @brief loads coefficients for the linear SVM classifier from a file
465
+ @param filename Name of the file to read.
466
+ @param objname The optional name of the node to read (if empty, the first top-level node will be used).
467
+ */
403
468
CV_WRAP virtual bool load (const String& filename, const String& objname = String());
469
+
470
+ /* * @brief saves coefficients for the linear SVM classifier to a file
471
+ @param filename File name
472
+ @param objname Object name
473
+ */
404
474
CV_WRAP virtual void save (const String& filename, const String& objname = String()) const ;
475
+
476
+ /* * @brief clones the HOGDescriptor
477
+ @param c cloned HOGDescriptor
478
+ */
405
479
virtual void copyTo (HOGDescriptor& c) const ;
406
480
481
+ /* *@example train_HOG.cpp
482
+ */
483
+ /* * @brief Computes HOG descriptors of given image.
484
+ @param img Matrix of the type CV_8U containing an image where HOG features will be calculated.
485
+ @param descriptors Matrix of the type CV_32F
486
+ @param winStride Window stride. It must be a multiple of block stride.
487
+ @param padding Padding
488
+ @param locations Vector of Point
489
+ */
407
490
CV_WRAP virtual void compute (InputArray img,
408
491
CV_OUT std::vector<float >& descriptors,
409
492
Size winStride = Size(), Size padding = Size(),
410
493
const std::vector<Point>& locations = std::vector<Point>()) const ;
411
494
412
- // ! with found weights output
495
+ /* * @brief Performs object detection without a multi-scale window.
496
+ @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
497
+ @param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries.
498
+ @param weights Vector that will contain confidence values for each detected object.
499
+ @param hitThreshold Threshold for the distance between features and SVM classifying plane.
500
+ Usually it is 0 and should be specfied in the detector coefficients (as the last free coefficient).
501
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
502
+ @param winStride Window stride. It must be a multiple of block stride.
503
+ @param padding Padding
504
+ @param searchLocations Vector of Point includes set of requrested locations to be evaluated.
505
+ */
413
506
CV_WRAP virtual void detect (const Mat& img, CV_OUT std::vector<Point>& foundLocations,
414
507
CV_OUT std::vector<double >& weights,
415
508
double hitThreshold = 0 , Size winStride = Size(),
416
509
Size padding = Size(),
417
510
const std::vector<Point>& searchLocations = std::vector<Point>()) const ;
418
- // ! without found weights output
511
+
512
+ /* * @brief Performs object detection without a multi-scale window.
513
+ @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
514
+ @param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries.
515
+ @param hitThreshold Threshold for the distance between features and SVM classifying plane.
516
+ Usually it is 0 and should be specfied in the detector coefficients (as the last free coefficient).
517
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
518
+ @param winStride Window stride. It must be a multiple of block stride.
519
+ @param padding Padding
520
+ @param searchLocations Vector of Point includes locations to search.
521
+ */
419
522
virtual void detect (const Mat& img, CV_OUT std::vector<Point>& foundLocations,
420
523
double hitThreshold = 0 , Size winStride = Size(),
421
524
Size padding = Size(),
422
525
const std::vector<Point>& searchLocations=std::vector<Point>()) const ;
423
526
424
- // ! with result weights output
527
+ /* * @brief Detects objects of different sizes in the input image. The detected objects are returned as a list
528
+ of rectangles.
529
+ @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
530
+ @param foundLocations Vector of rectangles where each rectangle contains the detected object.
531
+ @param foundWeights Vector that will contain confidence values for each detected object.
532
+ @param hitThreshold Threshold for the distance between features and SVM classifying plane.
533
+ Usually it is 0 and should be specfied in the detector coefficients (as the last free coefficient).
534
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
535
+ @param winStride Window stride. It must be a multiple of block stride.
536
+ @param padding Padding
537
+ @param scale Coefficient of the detection window increase.
538
+ @param finalThreshold Final threshold
539
+ @param useMeanshiftGrouping indicates grouping algorithm
540
+ */
425
541
CV_WRAP virtual void detectMultiScale (InputArray img, CV_OUT std::vector<Rect>& foundLocations,
426
542
CV_OUT std::vector<double >& foundWeights, double hitThreshold = 0 ,
427
543
Size winStride = Size(), Size padding = Size(), double scale = 1.05,
428
544
double finalThreshold = 2.0,bool useMeanshiftGrouping = false) const ;
429
- // ! without found weights output
545
+
546
+ /* * @brief Detects objects of different sizes in the input image. The detected objects are returned as a list
547
+ of rectangles.
548
+ @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
549
+ @param foundLocations Vector of rectangles where each rectangle contains the detected object.
550
+ @param hitThreshold Threshold for the distance between features and SVM classifying plane.
551
+ Usually it is 0 and should be specfied in the detector coefficients (as the last free coefficient).
552
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
553
+ @param winStride Window stride. It must be a multiple of block stride.
554
+ @param padding Padding
555
+ @param scale Coefficient of the detection window increase.
556
+ @param finalThreshold Final threshold
557
+ @param useMeanshiftGrouping indicates grouping algorithm
558
+ */
430
559
virtual void detectMultiScale (InputArray img, CV_OUT std::vector<Rect>& foundLocations,
431
560
double hitThreshold = 0 , Size winStride = Size(),
432
561
Size padding = Size(), double scale = 1.05,
433
562
double finalThreshold = 2.0, bool useMeanshiftGrouping = false) const ;
434
563
564
+ /* * @brief Computes gradients and quantized gradient orientations.
565
+ @param img Matrix contains the image to be computed
566
+ @param grad Matrix of type CV_32FC2 contains computed gradients
567
+ @param angleOfs Matrix of type CV_8UC2 contains quantized gradient orientations
568
+ @param paddingTL Padding from top-left
569
+ @param paddingBR Padding from bottom-right
570
+ */
435
571
CV_WRAP virtual void computeGradient (const Mat& img, CV_OUT Mat& grad, CV_OUT Mat& angleOfs,
436
572
Size paddingTL = Size(), Size paddingBR = Size()) const ;
437
573
574
+ /* * @brief Returns coefficients of the classifier trained for people detection (for 64x128 windows).
575
+ */
438
576
CV_WRAP static std::vector<float > getDefaultPeopleDetector ();
577
+
578
+ /* *@example hog.cpp
579
+ */
580
+ /* * @brief Returns coefficients of the classifier trained for people detection (for 48x96 windows).
581
+ */
439
582
CV_WRAP static std::vector<float > getDaimlerPeopleDetector ();
440
583
584
+ // ! Detection window size. Align to block size and block stride. Default value is Size(64,128).
441
585
CV_PROP Size winSize;
586
+
587
+ // ! Block size in pixels. Align to cell size. Default value is Size(16,16).
442
588
CV_PROP Size blockSize;
589
+
590
+ // ! Block stride. It must be a multiple of cell size. Default value is Size(8,8).
443
591
CV_PROP Size blockStride;
592
+
593
+ // ! Cell size. Default value is Size(8,8).
444
594
CV_PROP Size cellSize;
595
+
596
+ // ! Number of bins used in the calculation of histogram of gradients. Default value is 9.
445
597
CV_PROP int nbins;
598
+
599
+ // ! not documented
446
600
CV_PROP int derivAperture;
601
+
602
+ // ! Gaussian smoothing window parameter.
447
603
CV_PROP double winSigma;
604
+
605
+ // ! histogramNormType
448
606
CV_PROP int histogramNormType;
607
+
608
+ // ! L2-Hys normalization method shrinkage.
449
609
CV_PROP double L2HysThreshold;
610
+
611
+ // ! Flag to specify whether the gamma correction preprocessing is required or not.
450
612
CV_PROP bool gammaCorrection;
613
+
614
+ // ! coefficients for the linear SVM classifier.
451
615
CV_PROP std::vector<float > svmDetector;
616
+
617
+ // ! coefficients for the linear SVM classifier used when OpenCL is enabled
452
618
UMat oclSvmDetector;
619
+
620
+ // ! not documented
453
621
float free_coef;
622
+
623
+ // ! Maximum number of detection window increases. Default value is 64
454
624
CV_PROP int nlevels;
455
- CV_PROP bool signedGradient;
456
625
626
+ // ! Indicates signed gradient will be used or not
627
+ CV_PROP bool signedGradient;
457
628
458
- // ! evaluate specified ROI and return confidence value for each location
629
+ /* * @brief evaluate specified ROI and return confidence value for each location
630
+ @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
631
+ @param locations Vector of Point
632
+ @param foundLocations Vector of Point where each Point is detected object's top-left point.
633
+ @param confidences confidences
634
+ @param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually
635
+ it is 0 and should be specfied in the detector coefficients (as the last free coefficient). But if
636
+ the free coefficient is omitted (which is allowed), you can specify it manually here
637
+ @param winStride winStride
638
+ @param padding padding
639
+ */
459
640
virtual void detectROI (const cv::Mat& img, const std::vector<cv::Point> &locations,
460
641
CV_OUT std::vector<cv::Point>& foundLocations, CV_OUT std::vector<double >& confidences,
461
642
double hitThreshold = 0 , cv::Size winStride = Size(),
462
643
cv::Size padding = Size()) const ;
463
644
464
- // ! evaluate specified ROI and return confidence value for each location in multiple scales
645
+ /* * @brief evaluate specified ROI and return confidence value for each location in multiple scales
646
+ @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
647
+ @param foundLocations Vector of rectangles where each rectangle contains the detected object.
648
+ @param locations Vector of DetectionROI
649
+ @param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specfied
650
+ in the detector coefficients (as the last free coefficient). But if the free coefficient is omitted (which is allowed), you can specify it manually here.
651
+ @param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it.
652
+ */
465
653
virtual void detectMultiScaleROI (const cv::Mat& img,
466
- CV_OUT std::vector<cv::Rect>& foundLocations,
467
- std::vector<DetectionROI>& locations,
468
- double hitThreshold = 0 ,
469
- int groupThreshold = 0 ) const ;
654
+ CV_OUT std::vector<cv::Rect>& foundLocations,
655
+ std::vector<DetectionROI>& locations,
656
+ double hitThreshold = 0 ,
657
+ int groupThreshold = 0 ) const ;
470
658
471
- // ! read/parse Dalal's alt model file
659
+ /* * @brief read/parse Dalal's alt model file
660
+ @param modelfile Path of Dalal's alt model file.
661
+ */
472
662
void readALTModel (String modelfile);
663
+
664
+ /* * @brief Groups the object candidate rectangles.
665
+ @param rectList Input/output vector of rectangles. Output vector includes retained and grouped rectangles. (The Python list is not modified in place.)
666
+ @param weights Input/output vector of weights of rectangles. Output vector includes weights of retained and grouped rectangles. (The Python list is not modified in place.)
667
+ @param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it.
668
+ @param eps Relative difference between sides of the rectangles to merge them into a group.
669
+ */
473
670
void groupRectangles (std::vector<cv::Rect>& rectList, std::vector<double >& weights, int groupThreshold, double eps) const ;
474
671
};
475
672
0 commit comments