/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifdef HAVE_CONFIG_H
#include <cvconfig.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include <stdio.h>
#include <memory.h>
#include <float.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <_cvcommon.h>
#include <cvclassifier.h>
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */
#define CV_BOOST_IMPL
typedef struct CvValArray
{
uchar* data;
size_t step;
} CvValArray;
#define CMP_VALUES( idx1, idx2 ) \
( *( (float*) (aux->data + ((int) (idx1)) * aux->step ) ) < \
*( (float*) (aux->data + ((int) (idx2)) * aux->step ) ) )
CV_IMPLEMENT_QSORT_EX( icvSortIndexedValArray_16s, short, CMP_VALUES, CvValArray* )
CV_IMPLEMENT_QSORT_EX( icvSortIndexedValArray_32s, int, CMP_VALUES, CvValArray* )
CV_IMPLEMENT_QSORT_EX( icvSortIndexedValArray_32f, float, CMP_VALUES, CvValArray* )
CV_BOOST_IMPL
void cvGetSortedIndices( CvMat* val, CvMat* idx, int sortcols )
{
int idxtype = 0;
uchar* data = NULL;
size_t istep = 0;
size_t jstep = 0;
int i = 0;
int j = 0;
CvValArray va;
assert( idx != NULL );
assert( val != NULL );
idxtype = CV_MAT_TYPE( idx->type );
assert( idxtype == CV_16SC1 || idxtype == CV_32SC1 || idxtype == CV_32FC1 );
assert( CV_MAT_TYPE( val->type ) == CV_32FC1 );
if( sortcols )
{
assert( idx->rows == val->cols );
assert( idx->cols == val->rows );
istep = CV_ELEM_SIZE( val->type );
jstep = val->step;
}
else
{
assert( idx->rows == val->rows );
assert( idx->cols == val->cols );
istep = val->step;
jstep = CV_ELEM_SIZE( val->type );
}
va.data = val->data.ptr;
va.step = jstep;
switch( idxtype )
{
case CV_16SC1:
for( i = 0; i < idx->rows; i++ )
{
for( j = 0; j < idx->cols; j++ )
{
CV_MAT_ELEM( *idx, short, i, j ) = (short) j;
}
icvSortIndexedValArray_16s( (short*) (idx->data.ptr + i * idx->step),
idx->cols, &va );
va.data += istep;
}
break;
case CV_32SC1:
for( i = 0; i < idx->rows; i++ )
{
for( j = 0; j < idx->cols; j++ )
{
CV_MAT_ELEM( *idx, int, i, j ) = j;
}
icvSortIndexedValArray_32s( (int*) (idx->data.ptr + i * idx->step),
idx->cols, &va );
va.data += istep;
}
break;
case CV_32FC1:
for( i = 0; i < idx->rows; i++ )
{
for( j = 0; j < idx->cols; j++ )
{
CV_MAT_ELEM( *idx, float, i, j ) = (float) j;
}
icvSortIndexedValArray_32f( (float*) (idx->data.ptr + i * idx->step),
idx->cols, &va );
va.data += istep;
}
break;
default:
assert( 0 );
break;
}
}
CV_BOOST_IMPL
void cvReleaseStumpClassifier( CvClassifier** classifier )
{
cvFree( classifier );
*classifier = 0;
}
CV_BOOST_IMPL
float cvEvalStumpClassifier( CvClassifier* classifier, CvMat* sample )
{
assert( classifier != NULL );
assert( sample != NULL );
assert( CV_MAT_TYPE( sample->type ) == CV_32FC1 );
if( (CV_MAT_ELEM( (*sample), float, 0,
((CvStumpClassifier*) classifier)->compidx )) <
((CvStumpClassifier*) classifier)->threshold )
{
return ((CvStumpClassifier*) classifier)->left;
}
else
{
return ((CvStumpClassifier*) classifier)->right;
}
return 0.0F;
}
#define ICV_DEF_FIND_STUMP_THRESHOLD( suffix, type, error ) \
CV_BOOST_IMPL int icvFindStumpThreshold_##suffix( \
uchar* data, size_t datastep, \
uchar* wdata, size_t wstep, \
uchar* ydata, size_t ystep, \
uchar* idxdata, size_t idxstep, int num, \
float* lerror, \
float* rerror, \
float* threshold, float* left, float* right, \
float* sumw, float* sumwy, float* sumwyy ) \
{ \
int found = 0; \
float wyl = 0.0F; \
float wl = 0.0F; \
float wyyl = 0.0F; \
float wyr = 0.0F; \
float wr = 0.0F; \
\
float curleft = 0.0F; \
float curright = 0.0F; \
float* prevval = NULL;
没有合适的资源?快使用搜索试试~ 我知道了~
OpenCV haartraining源码注解
共27个文件
cpp:8个
h:4个
dsp:4个
4星 · 超过85%的资源 需积分: 9 182 下载量 34 浏览量
2011-12-06
21:33:35
上传
评论 4
收藏 127KB RAR 举报
温馨提示
OpenCV的haartraining源码注释,对于要研究人脸检测代码的人,可以借鉴借鉴。10000多行代码,只对一些主要部分进行了注释。
资源推荐
资源详情
资源评论
收起资源包目录
HaarTraining.rar (27个子文件)
HaarTraining
Makefile.am 46B
Makefile.in 16KB
make
cvhaartraining.dsp 4KB
haartraining.dsw 3KB
haartraining.sln 12KB
haartraining.dsp 5KB
createsamples.dsp 5KB
haartraining.suo 42KB
performance.dsp 5KB
cvhaartraining.plg 2KB
createsamples.plg 34KB
cvhaartraining.ncb 97KB
src
Makefile.am 1KB
Makefile.in 21KB
_cvhaartraining.h 14KB
cvhaartraining.cpp 108KB
_cvcommon.h 3KB
cvboost.cpp 124KB
createsamples.cpp 8KB
cvsamples.cpp 29KB
cvcommon.cpp 4KB
performance.cpp 12KB
cvhaarclassifier.cpp 23KB
haartraining.cpp 10KB
cvclassifier.h 26KB
doc
haartraining.htm 34KB
include
cvhaartraining.h 8KB
共 27 条
- 1
延陵小明
- 粉丝: 650
- 资源: 33
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页