auto import from //depot/cupcake/@135843
[android/platform/external/neven.git] / Embedded / common / src / b_BitFeatureEm / LocalScanDetector.h
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef bbf_LOCAL_SCAN_DETECTOR_EM_H
18 #define bbf_LOCAL_SCAN_DETECTOR_EM_H
19
20 /* ---- includes ----------------------------------------------------------- */
21
22 #include "b_BasicEm/Context.h"
23 #include "b_BasicEm/Basic.h"
24 #include "b_BasicEm/UInt32Arr.h"
25 #include "b_BasicEm/Int16Arr.h"
26 #include "b_BasicEm/MemTbl.h"
27 #include "b_TensorEm/IdCluster2D.h"
28 #include "b_BitFeatureEm/Sequence.h"
29 #include "b_BitFeatureEm/BitParam.h"
30 #include "b_BitFeatureEm/LocalScanner.h"
31 #include "b_TensorEm/RBFMap2D.h"
32
33 /* ---- related objects  --------------------------------------------------- */
34
35 /* ---- typedefs ----------------------------------------------------------- */
36
37 /* ---- constants ---------------------------------------------------------- */
38
39 /* data format version number */
40 #define bbf_LOCAL_SCAN_DETECTOR_VERSION 100
41
42 /* maximum number of features in scan detector */
43 #define bbf_LOCAL_SCAN_DETECTOR_MAX_FEATURES 16
44
45 /* maximum size of any cluster in all processing stages of landmarker */
46 #define bpi_LOCAL_SCAN_DETECTOR_MAX_CLUSTER_SIZE 24
47
48 /* maximum dimension of PCA subspace  */
49 #define bpi_LOCAL_SCAN_DETECTOR_MAX_PCA_DIM 12
50
51 /* ---- object definition -------------------------------------------------- */
52
53 /** discrete feature set */
54 struct bbf_LocalScanDetector 
55 {
56         /* ---- private data --------------------------------------------------- */
57
58         /** feature pointer arrray */
59         struct bbf_Feature* ftrPtrArrE[ bbf_LOCAL_SCAN_DETECTOR_MAX_FEATURES ];
60
61         /** multiple purpose rbf map */
62         struct bts_RBFMap2D rbfMapE;
63
64         /** temporary cluster */
65         struct bts_Cluster2D tmpCluster1E; 
66
67         /** temporary cluster */
68         struct bts_Cluster2D tmpCluster2E; 
69
70         /** temporary cluster */
71         struct bts_Cluster2D tmpCluster3E; 
72
73         /** temporary cluster */
74         struct bts_Cluster2D tmpCluster4E; 
75
76         /** local scanner */
77         struct bbf_LocalScanner scannerE;
78
79         /** activity array */
80         struct bbs_Int32Arr actArrE;
81
82         /** index array */
83         struct bbs_Int16Arr idxArrE;
84
85         /** working image buffer */
86         struct bbs_UInt8Arr workImageBufE;
87
88         /* ---- public data ---------------------------------------------------- */
89
90         /** patch width */
91         uint32 patchWidthE;
92
93         /** patch height*/
94         uint32 patchHeightE;
95
96         /** width of scan area */
97         uint32 scanWidthE;
98
99         /** height of scan area */
100         uint32 scanHeightE;
101
102         /** scanner scale exponent */
103         uint32 scaleExpE;
104
105         /** interpolated image warping */
106         flag interpolatedWarpingE;
107
108         /** image downscale threshold (part of image warping) (16.16) */
109         uint32 warpScaleThresholdE;
110
111         /** reference cluster */
112         struct bts_IdCluster2D refClusterE; 
113
114         /** cluster with scan positions */
115         struct bts_Cluster2D scanClusterE; 
116
117         /** feature data array (contains feature elements) */
118         struct bbs_UInt16Arr ftrDataArrE;
119
120         /** parameter for bit generation */
121         struct bbf_BitParam bitParamE;
122
123         /** outlier distance in pixels (16.16); ( >0: activates outlier analysis ) */
124         uint32 outlierDistanceE;
125
126         /** pca reference cluster */
127         struct bts_IdCluster2D pcaClusterE; 
128
129         /** pca average vector (10.6) */
130         struct bbs_Int16Arr pcaAvgE;
131
132         /** pca projection matrix (8.8) */
133         struct bbs_Int16Arr pcaMatE; 
134
135         /** pcs subspace dimensions */
136         uint32 pcaDimSubSpaceE;
137
138         /** max width of working image */
139         uint32 maxImageWidthE;
140
141         /** max height of working image */
142         uint32 maxImageHeightE;
143
144 };
145
146 /* ---- associated objects ------------------------------------------------- */
147
148 /* ---- external functions ------------------------------------------------- */
149
150 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
151
152 /** initializes bbf_LocalScanDetector  */
153 void bbf_LocalScanDetector_init( struct bbs_Context* cpA,
154                                                                  struct bbf_LocalScanDetector* ptrA );
155
156 /** resets bbf_LocalScanDetector  */
157 void bbf_LocalScanDetector_exit( struct bbs_Context* cpA,
158                                                                  struct bbf_LocalScanDetector* ptrA );
159
160 /* ---- \ghd{ operators } -------------------------------------------------- */
161
162 /** copy operator */
163 void bbf_LocalScanDetector_copy( struct bbs_Context* cpA,
164                                                                  struct bbf_LocalScanDetector* ptrA, 
165                                                                  const struct bbf_LocalScanDetector* srcPtrA );
166
167 /** equal operator */
168 flag bbf_LocalScanDetector_equal( struct bbs_Context* cpA,
169                                                                   const struct bbf_LocalScanDetector* ptrA, 
170                                                                   const struct bbf_LocalScanDetector* srcPtrA );
171
172 /* ---- \ghd{ query functions } -------------------------------------------- */
173
174 /* ---- \ghd{ modify functions } ------------------------------------------- */
175
176 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
177
178 /** word size (16-bit) object needs when written to memory */
179 uint32 bbf_LocalScanDetector_memSize( struct bbs_Context* cpA,
180                                                                           const struct bbf_LocalScanDetector* ptrA );
181
182 /** writes object to memory; returns number of words (16-bit) written */
183 uint32 bbf_LocalScanDetector_memWrite( struct bbs_Context* cpA,
184                                                                            const struct bbf_LocalScanDetector* ptrA, uint16* memPtrA );
185
186 /** reads object from memory; returns number of words (16-bit) read */
187 uint32 bbf_LocalScanDetector_memRead( struct bbs_Context* cpA,
188                                                                           struct bbf_LocalScanDetector* ptrA, 
189                                                                           const uint16* memPtrA, 
190                                                                           struct bbs_MemTbl* mtpA );
191
192 /* ---- \ghd{ exec functions } --------------------------------------------- */
193
194 /** processes image with cluster; produces output cluster and returns confidence (8.24) 
195  *  offsPtrA specifies pixel position (0,0) in input image
196  */
197 int32 bbf_LocalScanDetector_process( struct bbs_Context* cpA,
198                                                                          const struct bbf_LocalScanDetector* ptrA, 
199                                      uint8* imagePtrA, 
200                                                                          uint32 imageWidthA,
201                                                                          uint32 imageHeightA,
202                                                                          const struct bts_Int16Vec2D*  offsPtrA,
203                                                                          const struct bts_IdCluster2D* inClusterPtrA,
204                                                                          struct bts_IdCluster2D* outClusterPtrA );
205
206 #endif /* bbf_LOCAL_SCAN_DETECTOR_EM_H */
207