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);
197 __device__ Ncv32f getLeafValue(
void)
199 return (__int_as_float(this->_ui1.x));
205 return (this->_ui1.x);
215 this->_ui4.x = *(Ncv32u *)&f;
221 this->_ui4.y = *(Ncv32u *)&t;
227 this->_ui4.z = *(Ncv32u *)&nl;
233 this->_ui4.w = *(Ncv32u *)&nr;
244 return *(Ncv32f*)&this->_ui4.y;
260 #define HaarStage64_Interpret_MaskRootNodes 0x0000FFFF
261 #define HaarStage64_Interpret_MaskRootNodeOffset 0xFFFF0000
262 #define HaarStage64_Interpret_ShiftRootNodeOffset 16
268 this->_ui2.x = *(Ncv32u *)&t;
274 if (val > (HaarStage64_Interpret_MaskRootNodeOffset >> HaarStage64_Interpret_ShiftRootNodeOffset))
276 return NCV_HAAR_XML_LOADING_EXCEPTION;
278 this->_ui2.y = (val << HaarStage64_Interpret_ShiftRootNodeOffset) | (this->_ui2.y & HaarStage64_Interpret_MaskRootNodes);
284 if (val > HaarStage64_Interpret_MaskRootNodes)
286 return NCV_HAAR_XML_LOADING_EXCEPTION;
288 this->_ui2.y = val | (this->_ui2.y & HaarStage64_Interpret_MaskRootNodeOffset);
294 return *(Ncv32f*)&this->_ui2.x;
299 return (this->_ui2.y >> HaarStage64_Interpret_ShiftRootNodeOffset);
304 return (this->_ui2.y & HaarStage64_Interpret_MaskRootNodes);
336 NCVPipeObjDet_Default = 0x000,
337 NCVPipeObjDet_UseFairImageScaling = 0x001,
338 NCVPipeObjDet_FindLargestObject = 0x002,
339 NCVPipeObjDet_VisualizeInPlace = 0x004,
342 NCV_EXPORTS NCVStatus ncvDetectObjectsMultiScale_device(
NCVMatrix<Ncv8u> &d_srcImg,
361 cudaDeviceProp &devProp,
362 cudaStream_t cuStream);
364 #define OBJDET_MASK_ELEMENT_INVALID_32U 0xFFFFFFFF
365 #define HAAR_STDDEV_BORDER 1
367 NCV_EXPORTS NCVStatus ncvApplyHaarClassifierCascade_device(
NCVMatrix<Ncv32u> &d_integralImage,
370 Ncv32u &numDetections,
376 NcvBool bMaskElements,
382 cudaDeviceProp &devProp,
383 cudaStream_t cuStream);
385 NCV_EXPORTS NCVStatus ncvApplyHaarClassifierCascade_host(
NCVMatrix<Ncv32u> &h_integralImage,
388 Ncv32u &numDetections,
393 NcvBool bMaskElements,
398 #define RECT_SIMILARITY_PROPORTION 0.2f
400 NCV_EXPORTS NCVStatus ncvGrowDetectionsVector_device(
NCVVector<Ncv32u> &pixelMask,
401 Ncv32u numPixelMaskDetections,
403 Ncv32u &totalDetections,
404 Ncv32u totalMaxDetections,
408 cudaStream_t cuStream);
411 Ncv32u numPixelMaskDetections,
413 Ncv32u &totalDetections,
414 Ncv32u totalMaxDetections,
419 NCV_EXPORTS NCVStatus ncvHaarGetClassifierSize(
const std::string &filename, Ncv32u &numStages,
420 Ncv32u &numNodes, Ncv32u &numFeatures);
422 NCV_EXPORTS NCVStatus ncvHaarLoadFromFile_host(
const std::string &filename,
428 NCV_EXPORTS NCVStatus ncvHaarStoreNVBIN_host(
const std::string &filename,
434 #endif // PCL_GPU_PEOPLE_NCVHAAROBJECTDETECTION_HPP_
__host__ NCVStatus setStartClassifierRootNodeOffset(Ncv32u val)
__host__ NCVStatus setWeight(Ncv32f weight)
__host__ NCVStatus setRect(Ncv32u rectX, Ncv32u rectY, Ncv32u rectWidth, Ncv32u rectHeight, Ncv32u, Ncv32u)
__host__ NCVStatus setNumClassifierRootNodes(Ncv32u val)
__device__ __host__ NcvBool isTilted(void)
__host__ __device__ HaarClassifierNodeDescriptor32 getLeftNodeDesc(void)
__device__ __host__ Ncv32u getFeaturesOffset(void)
__host__ NCVStatus setLeftNodeDesc(HaarClassifierNodeDescriptor32 nl)
__device__ __host__ NcvBool isLeftNodeLeaf(void)
Ncv32u NumClassifierTotalNodes
__host__ __device__ Ncv32f getThreshold(void)
__host__ NCVStatus setThreshold(Ncv32f t)
__host__ NCVStatus create(Ncv32f leafValue)
__host__ Ncv32f getLeafValueHost(void)
__device__ __host__ NcvBool isRightNodeLeaf(void)
Classifier cascade descriptor.
__host__ __device__ HaarFeatureDescriptor32 getFeatureDesc(void)
Ncv32u NumClassifierRootNodes
__host__ __device__ Ncv32f getStageThreshold(void)
__host__ NCVStatus setRightNodeDesc(HaarClassifierNodeDescriptor32 nr)
__host__ NCVStatus create(NcvBool bTilted, NcvBool bLeftLeaf, NcvBool bRightLeaf, Ncv32u numFeatures, Ncv32u offsetFeatures)
NcvSize32u ClassifierSize
INCVMemAllocator (Interface)
__device__ __host__ Ncv32u getNextNodeOffset(void)
__host__ NCVStatus create(Ncv32u offsetHaarClassifierNode)
__host__ __device__ Ncv32u getNumClassifierRootNodes(void)
__device__ __host__ Ncv32u getNumFeatures(void)
__host__ NCVStatus setFeatureDesc(HaarFeatureDescriptor32 f)
__host__ __device__ HaarClassifierNodeDescriptor32 getRightNodeDesc(void)
__host__ __device__ Ncv32u getStartClassifierRootNodeOffset(void)
__host__ NCVStatus setStageThreshold(Ncv32f t)
__device__ __host__ Ncv32f getWeight(void)
__device__ __host__ void getRect(Ncv32u *rectX, Ncv32u *rectY, Ncv32u *rectWidth, Ncv32u *rectHeight)