57 #ifndef PCL_GPU_PEOPLE_NCVHAAROBJECTDETECTION_HPP_
58 #define PCL_GPU_PEOPLE_NCVHAAROBJECTDETECTION_HPP_
73 #define HaarFeature64_CreateCheck_MaxRectField 0xFF
75 __host__ NCVStatus
setRect(Ncv32u rectX, Ncv32u rectY, Ncv32u rectWidth, Ncv32u rectHeight, Ncv32u , Ncv32u )
77 ncvAssertReturn(rectWidth <= HaarFeature64_CreateCheck_MaxRectField && rectHeight <= HaarFeature64_CreateCheck_MaxRectField, NCV_HAAR_TOO_LARGE_FEATURES);
78 ((
NcvRect8u*)&(this->_ui2.x))->x = (Ncv8u)rectX;
79 ((
NcvRect8u*)&(this->_ui2.x))->y = (Ncv8u)rectY;
80 ((
NcvRect8u*)&(this->_ui2.x))->width = (Ncv8u)rectWidth;
81 ((
NcvRect8u*)&(this->_ui2.x))->height = (Ncv8u)rectHeight;
87 ((Ncv32f*)&(this->_ui2.y))[0] = weight;
91 __device__ __host__
void getRect(Ncv32u *rectX, Ncv32u *rectY, Ncv32u *rectWidth, Ncv32u *rectHeight)
96 *rectWidth = tmpRect.
width;
97 *rectHeight = tmpRect.
height;
102 return *(Ncv32f*)(&this->_ui2.y);
110 #define HaarFeatureDescriptor32_Interpret_MaskFlagTilted 0x80000000
111 #define HaarFeatureDescriptor32_Interpret_MaskFlagLeftNodeLeaf 0x40000000
112 #define HaarFeatureDescriptor32_Interpret_MaskFlagRightNodeLeaf 0x20000000
113 #define HaarFeatureDescriptor32_CreateCheck_MaxNumFeatures 0x1F
114 #define HaarFeatureDescriptor32_NumFeatures_Shift 24
115 #define HaarFeatureDescriptor32_CreateCheck_MaxFeatureOffset 0x00FFFFFF
121 __host__ NCVStatus
create(NcvBool bTilted, NcvBool bLeftLeaf, NcvBool bRightLeaf,
122 Ncv32u numFeatures, Ncv32u offsetFeatures)
124 if (numFeatures > HaarFeatureDescriptor32_CreateCheck_MaxNumFeatures)
126 return NCV_HAAR_TOO_MANY_FEATURES_IN_CLASSIFIER;
128 if (offsetFeatures > HaarFeatureDescriptor32_CreateCheck_MaxFeatureOffset)
130 return NCV_HAAR_TOO_MANY_FEATURES_IN_CASCADE;
133 this->desc |= (bTilted ? HaarFeatureDescriptor32_Interpret_MaskFlagTilted : 0);
134 this->desc |= (bLeftLeaf ? HaarFeatureDescriptor32_Interpret_MaskFlagLeftNodeLeaf : 0);
135 this->desc |= (bRightLeaf ? HaarFeatureDescriptor32_Interpret_MaskFlagRightNodeLeaf : 0);
136 this->desc |= (numFeatures << HaarFeatureDescriptor32_NumFeatures_Shift);
137 this->desc |= offsetFeatures;
143 return (this->desc & HaarFeatureDescriptor32_Interpret_MaskFlagTilted) != 0;
148 return (this->desc & HaarFeatureDescriptor32_Interpret_MaskFlagLeftNodeLeaf) != 0;
153 return (this->desc & HaarFeatureDescriptor32_Interpret_MaskFlagRightNodeLeaf) != 0;
158 return (this->desc >> HaarFeatureDescriptor32_NumFeatures_Shift) & HaarFeatureDescriptor32_CreateCheck_MaxNumFeatures;
163 return this->desc & HaarFeatureDescriptor32_CreateCheck_MaxFeatureOffset;
171 __host__ NCVStatus
create(Ncv32f leafValue)
173 *(Ncv32f *)&this->_ui1 = leafValue;
174 return (NCV_SUCCESS);
177 __host__ NCVStatus
create(Ncv32u offsetHaarClassifierNode)
179 this->_ui1.x = offsetHaarClassifierNode;
180 return (NCV_SUCCESS);
185 return (*(Ncv32f *)&this->_ui1.x);
190 return (
_ui1.x != 0);
194 __device__ Ncv32f getLeafValue(
void)
196 return (__int_as_float(this->_ui1.x));
202 return (this->_ui1.x);
212 this->_ui4.x = *(Ncv32u *)&f;
218 this->_ui4.y = *(Ncv32u *)&t;
224 this->_ui4.z = *(Ncv32u *)&nl;
230 this->_ui4.w = *(Ncv32u *)&nr;
241 return *(Ncv32f*)&this->_ui4.y;
257 #define HaarStage64_Interpret_MaskRootNodes 0x0000FFFF
258 #define HaarStage64_Interpret_MaskRootNodeOffset 0xFFFF0000
259 #define HaarStage64_Interpret_ShiftRootNodeOffset 16
265 this->_ui2.x = *(Ncv32u *)&t;
271 if (val > (HaarStage64_Interpret_MaskRootNodeOffset >> HaarStage64_Interpret_ShiftRootNodeOffset))
273 return NCV_HAAR_XML_LOADING_EXCEPTION;
275 this->_ui2.y = (val << HaarStage64_Interpret_ShiftRootNodeOffset) | (this->_ui2.y & HaarStage64_Interpret_MaskRootNodes);
281 if (val > HaarStage64_Interpret_MaskRootNodes)
283 return NCV_HAAR_XML_LOADING_EXCEPTION;
285 this->_ui2.y = val | (this->_ui2.y & HaarStage64_Interpret_MaskRootNodeOffset);
291 return *(Ncv32f*)&this->_ui2.x;
296 return (this->_ui2.y >> HaarStage64_Interpret_ShiftRootNodeOffset);
301 return (this->_ui2.y & HaarStage64_Interpret_MaskRootNodes);
333 NCVPipeObjDet_Default = 0x000,
334 NCVPipeObjDet_UseFairImageScaling = 0x001,
335 NCVPipeObjDet_FindLargestObject = 0x002,
336 NCVPipeObjDet_VisualizeInPlace = 0x004,
339 NCV_EXPORTS NCVStatus ncvDetectObjectsMultiScale_device(
NCVMatrix<Ncv8u> &d_srcImg,
358 cudaDeviceProp &devProp,
359 cudaStream_t cuStream);
361 #define OBJDET_MASK_ELEMENT_INVALID_32U 0xFFFFFFFF
362 #define HAAR_STDDEV_BORDER 1
364 NCV_EXPORTS NCVStatus ncvApplyHaarClassifierCascade_device(
NCVMatrix<Ncv32u> &d_integralImage,
367 Ncv32u &numDetections,
373 NcvBool bMaskElements,
379 cudaDeviceProp &devProp,
380 cudaStream_t cuStream);
382 NCV_EXPORTS NCVStatus ncvApplyHaarClassifierCascade_host(
NCVMatrix<Ncv32u> &h_integralImage,
385 Ncv32u &numDetections,
390 NcvBool bMaskElements,
395 #define RECT_SIMILARITY_PROPORTION 0.2f
397 NCV_EXPORTS NCVStatus ncvGrowDetectionsVector_device(
NCVVector<Ncv32u> &pixelMask,
398 Ncv32u numPixelMaskDetections,
400 Ncv32u &totalDetections,
401 Ncv32u totalMaxDetections,
405 cudaStream_t cuStream);
408 Ncv32u numPixelMaskDetections,
410 Ncv32u &totalDetections,
411 Ncv32u totalMaxDetections,
416 NCV_EXPORTS NCVStatus ncvHaarGetClassifierSize(
const std::string &filename, Ncv32u &numStages,
417 Ncv32u &numNodes, Ncv32u &numFeatures);
419 NCV_EXPORTS NCVStatus ncvHaarLoadFromFile_host(
const std::string &filename,
425 NCV_EXPORTS NCVStatus ncvHaarStoreNVBIN_host(
const std::string &filename,
INCVMemAllocator (Interface)
Classifier cascade descriptor.
NcvSize32u ClassifierSize
Ncv32u NumClassifierTotalNodes
Ncv32u NumClassifierRootNodes
__host__ __device__ HaarClassifierNodeDescriptor32 getRightNodeDesc()
__host__ __device__ HaarFeatureDescriptor32 getFeatureDesc()
__host__ NCVStatus setRightNodeDesc(HaarClassifierNodeDescriptor32 nr)
__host__ NCVStatus setThreshold(Ncv32f t)
__host__ NCVStatus setFeatureDesc(HaarFeatureDescriptor32 f)
__host__ __device__ HaarClassifierNodeDescriptor32 getLeftNodeDesc()
__host__ __device__ Ncv32f getThreshold()
__host__ NCVStatus setLeftNodeDesc(HaarClassifierNodeDescriptor32 nl)
__host__ bool isLeaf() const
__host__ Ncv32f getLeafValueHost()
__host__ NCVStatus create(Ncv32u offsetHaarClassifierNode)
__host__ NCVStatus create(Ncv32f leafValue)
__device__ __host__ Ncv32u getNextNodeOffset()
__device__ __host__ Ncv32f getWeight()
__host__ NCVStatus setRect(Ncv32u rectX, Ncv32u rectY, Ncv32u rectWidth, Ncv32u rectHeight, Ncv32u, Ncv32u)
__host__ NCVStatus setWeight(Ncv32f weight)
__device__ __host__ void getRect(Ncv32u *rectX, Ncv32u *rectY, Ncv32u *rectWidth, Ncv32u *rectHeight)
__device__ __host__ Ncv32u getNumFeatures() const
__device__ __host__ NcvBool isRightNodeLeaf() const
__device__ __host__ NcvBool isTilted() const
__device__ __host__ Ncv32u getFeaturesOffset() const
__device__ __host__ NcvBool isLeftNodeLeaf() const
__host__ NCVStatus create(NcvBool bTilted, NcvBool bLeftLeaf, NcvBool bRightLeaf, Ncv32u numFeatures, Ncv32u offsetFeatures)
__host__ __device__ Ncv32u getNumClassifierRootNodes() const
__host__ NCVStatus setNumClassifierRootNodes(Ncv32u val)
__host__ NCVStatus setStartClassifierRootNodeOffset(Ncv32u val)
__host__ NCVStatus setStageThreshold(Ncv32f t)
__host__ __device__ Ncv32f getStageThreshold()
__host__ __device__ Ncv32u getStartClassifierRootNodeOffset() const