Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/objdetect/src/haar.hpp
16337 views
1
/*M///////////////////////////////////////////////////////////////////////////////////////
2
//
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4
//
5
// By downloading, copying, installing or using the software you agree to this license.
6
// If you do not agree to this license, do not download, install,
7
// copy or use the software.
8
//
9
//
10
// Intel License Agreement
11
// For Open Source Computer Vision Library
12
//
13
// Copyright (C) 2000, Intel Corporation, all rights reserved.
14
// Third party copyrights are property of their respective owners.
15
//
16
// Redistribution and use in source and binary forms, with or without modification,
17
// are permitted provided that the following conditions are met:
18
//
19
// * Redistribution's of source code must retain the above copyright notice,
20
// this list of conditions and the following disclaimer.
21
//
22
// * Redistribution's in binary form must reproduce the above copyright notice,
23
// this list of conditions and the following disclaimer in the documentation
24
// and/or other materials provided with the distribution.
25
//
26
// * The name of Intel Corporation may not be used to endorse or promote products
27
// derived from this software without specific prior written permission.
28
//
29
// This software is provided by the copyright holders and contributors "as is" and
30
// any express or implied warranties, including, but not limited to, the implied
31
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32
// In no event shall the Intel Corporation or contributors be liable for any direct,
33
// indirect, incidental, special, exemplary, or consequential damages
34
// (including, but not limited to, procurement of substitute goods or services;
35
// loss of use, data, or profits; or business interruption) however caused
36
// and on any theory of liability, whether in contract, strict liability,
37
// or tort (including negligence or otherwise) arising in any way out of
38
// the use of this software, even if advised of the possibility of such damage.
39
//
40
//M*/
41
42
/* Haar features calculation */
43
44
#ifndef OPENCV_OBJDETECT_HAAR_HPP
45
#define OPENCV_OBJDETECT_HAAR_HPP
46
47
#define CV_HAAR_FEATURE_MAX_LOCAL 3
48
49
typedef int sumtype;
50
typedef double sqsumtype;
51
52
typedef struct CvHidHaarFeature
53
{
54
struct
55
{
56
sumtype *p0, *p1, *p2, *p3;
57
float weight;
58
}
59
rect[CV_HAAR_FEATURE_MAX_LOCAL];
60
} CvHidHaarFeature;
61
62
63
typedef struct CvHidHaarTreeNode
64
{
65
CvHidHaarFeature feature;
66
float threshold;
67
int left;
68
int right;
69
} CvHidHaarTreeNode;
70
71
72
typedef struct CvHidHaarClassifier
73
{
74
int count;
75
//CvHaarFeature* orig_feature;
76
CvHidHaarTreeNode* node;
77
float* alpha;
78
} CvHidHaarClassifier;
79
80
#define calc_sumf(rect,offset) \
81
static_cast<float>((rect).p0[offset] - (rect).p1[offset] - (rect).p2[offset] + (rect).p3[offset])
82
83
namespace cv_haar_avx
84
{
85
#if 0 /*CV_TRY_AVX*/
86
#define CV_HAAR_USE_AVX 1
87
#else
88
#define CV_HAAR_USE_AVX 0
89
#endif
90
91
#if CV_HAAR_USE_AVX
92
// AVX version icvEvalHidHaarClassifier. Process 8 CvHidHaarClassifiers per call. Check AVX support before invocation!!
93
double icvEvalHidHaarClassifierAVX(CvHidHaarClassifier* classifier, double variance_norm_factor, size_t p_offset);
94
double icvEvalHidHaarStumpClassifierAVX(CvHidHaarClassifier* classifier, double variance_norm_factor, size_t p_offset);
95
double icvEvalHidHaarStumpClassifierTwoRectAVX(CvHidHaarClassifier* classifier, double variance_norm_factor, size_t p_offset);
96
#endif
97
}
98
99
#endif
100
101
/* End of file. */
102
103