icvPrecalculate
/*
*icvPrecalculate
*作用:计算特征值,并排序
*详细来说也就是依据训练样本信息和haar特征信息,在函数内部引用icvGetTrainingDataCallback来
*分批计算正负样本的前numprecalated个haar特征值。并把计算好的特征值进行排序,最后结果存储在data->valcache之中
*/
static
void icvPrecalculate( CvHaarTrainingData* data, //训练样本信息
CvIntHaarFeatures* haarFeatures, //haar特征信息
int numprecalculated ) //估计算特征个数
{
CV_FUNCNAME( "icvPrecalculate" ); __BEGIN__; icvReleaseHaarTrainingDataCache( &data ); numprecalculated -= numprecalculated % CV_STUMP_TRAIN_PORTION;
numprecalculated = MIN( numprecalculated, haarFeatures->count ); if( numprecalculated > 0 )
{
//size_t datasize;
int m;
CvUserdata userdata; /* private variables */
#ifdef CV_OPENMP
CvMat t_data;
CvMat t_idx;
int first;
int t_portion;
int portion = CV_STUMP_TRAIN_PORTION; //每批计算特征的数量
#endif /* CV_OPENMP */ m = data->sum.rows; //确定样本总数量。正负样本数之和 #ifdef CV_COL_ARRANGEMENT
CV_CALL( data->valcache = cvCreateMat( numprecalculated, m, CV_32FC1 ) ); //以下这三组代码是给data->valcache和data->idxcache分配内存
#else
CV_CALL( data->valcache = cvCreateMat( m, numprecalculated, CV_32FC1 ) );
#endif
CV_CALL( data->idxcache = cvCreateMat( numprecalculated, m, CV_IDX_MAT_TYPE ) ); userdata = cvUserdata( data, haarFeatures ); #ifdef CV_OPENMP
#pragma omp parallel for private(t_data, t_idx, first, t_portion)
for( first = 0; first < numprecalculated; first += portion )
{
t_data = *data->valcache;
t_idx = *data->idxcache;
t_portion = MIN( portion, (numprecalculated - first) ); /* indices */
t_idx.rows = t_portion; //每批计算特征的个数
t_idx.data.ptr = data->idxcache->data.ptr + first * ((size_t)t_idx.step); /* feature values */
#ifdef CV_COL_ARRANGEMENT
t_data.rows = t_portion;
t_data.data.ptr = data->valcache->data.ptr +
first * ((size_t) t_data.step );
#else
t_data.cols = t_portion;
t_data.data.ptr = data->valcache->data.ptr +
first * ((size_t) CV_ELEM_SIZE( t_data.type ));
#endif
icvGetTrainingDataCallback( &t_data, NULL, NULL, first, t_portion,
&userdata );
#ifdef CV_COL_ARRANGEMENT
cvGetSortedIndices( &t_data, &t_idx, 0 );
#else
cvGetSortedIndices( &t_data, &t_idx, 1 );
#endif #ifdef CV_VERBOSE
putc( '.', stderr );
fflush( stderr );
#endif /* CV_VERBOSE */ } #ifdef CV_VERBOSE
fprintf( stderr, "\n" );
fflush( stderr );
#endif /* CV_VERBOSE */ #else
icvGetTrainingDataCallback( data->valcache, NULL, NULL, 0, numprecalculated,
&userdata ); //调用icvGetTrainingDataCallback函数计算特征值,把计算好的特征值存储在data->valcache中
#ifdef CV_COL_ARRANGEMENT
cvGetSortedIndices( data->valcache, data->idxcache, 0 ); //对计算好的特征值data->valcache进行排序。并存储在data->idxcache中
#else
cvGetSortedIndices( data->valcache, data->idxcache, 1 );
#endif
#endif /* CV_OPENMP */
} __END__;
}
icvPrecalculate的更多相关文章
- 史上最全opencv源代码解读,opencv源代码具体解读文件夹
本博原创,如有转载请注明本博网址http://blog.csdn.net/ding977921830/article/details/46799043. opencv源代码主要是基于adaboost算 ...
- opencv源代码分析之二:cvhaartraining.cpp
我使用的是opencv2.4.9.安装后.我的cvboost..cpp文件的路径是........\opencv\sources\apps\haartraining\cvhaartraining.cp ...
随机推荐
- mysql允许外部连接设置
错误信息: SQL Error (1130): Host ‘192.168.1.88’ is not allowed to connect to this MySQL server 说明所连接的用户帐 ...
- 三分钟上手Highcharts简易甘特图
根据业务需求,找到了这个很少使用的图形,话不多说,看看该如何使用.首先要引入支持文件:可根据链接下载. exporting.js:https://img.hcharts.cn/highcharts/m ...
- 【hihocoder 1378】网络流二·最大流最小割定理
[Link]:http://hihocoder.com/problemset/problem/1378 [Description] [Solution] 在求完最小割(最大流)之后; 可以在剩余网络中 ...
- 实战c++中的vector系列--copy set to vector(别混淆了reserve和resize)
stl算法中有个copy函数.我们能够轻松的写出这种代码: #include <iostream> #include <algorithm> #include <vect ...
- TextView- 内容过长省略号设定
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_conte ...
- 11.Bean2Document-BEAN转document
1. package com.glodon.gspm.adapter.plugin.common; import com.glodon.cloudt.tenancy.context.TenantCon ...
- ZOJ 2301 Color the Ball 线段树(区间更新+离散化)
Color the Ball Time Limit: 2 Seconds Memory Limit: 65536 KB There are infinite balls in a line ...
- python学习一,python基本语法
python基本语法: 1.python基本语句结构: 首先,在其他的语言中,比如java,c++,c#等,没写完一行语句之后,都需要在语句的末尾加一个分号,表示该语句结束,但是在python中,我们 ...
- IOIOI卡片占卜(Atcoder-IOIOI カード占い)(最短路)
题目描述: K 理事長は占いが好きで,いつも様々な占いをしている.今日は,表の面に ‘I’ が,裏の面に ‘O’ が書か れたカードを使って今年の IOI での日本選手団の出来を占うことにした. 占い ...
- CISP/CISA 每日一题 八
CISA 每日一题(答)网关执行电子邮件格式转换 电子邮件安全——加密 大文件——对称加密 不可否认——非对称 哈希——完整性 电子银行主要风险: 战略.经营和声誉上的风险 双SSP每日一题 ...