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 ...
随机推荐
- JS错误记录 - 右侧悬浮框 - 缓冲运动
本次练习错误总结: 1. 正确: startMove( document.documentElement.clientHeight - oDiv.offsetHeight + scrollTop); ...
- 【Pycharm】【HTML/jQuery】代码换行问题
问题:从网上下载jQuery文件后发现代码太长,不利于阅读:Pycharm没有预先设置好js文件的自动换行设置 问题 解决办法 解决后
- [AngularFire2 & Firestore] Example for collection and doc
import {Injectable} from '@angular/core'; import {Skill} from '../models/skills'; import {AuthServic ...
- https://github.com/ 英文库
https://github.com/ https://github.com/sachinchoolur
- RecyclerView 展示多种类型Item数据
一.多Item布局实现(MultipleItem) 如果之前你用过ListView实现过此功能,那么你一定对下面这两个方法并不陌生 @Override public int getItemViewTy ...
- centos7 Another app is currently holding the yum lock; waiting for it to exit...
解决方法:rm -rf /var/run/yum.pid 来强行解除锁定,然后你的yum就可以运行了
- APK文件浅析-Android
2011~2015,5年时间,断断续续学习了Android. 最近打算在2011年2个月认真学习的基础上,深入学习下. 由于有之前的Android基础,加上N年的Java等变成经验,自我感觉And ...
- 洛谷 P1598 垂直柱状图
P1598 垂直柱状图 题目描述 写一个程序从输入文件中去读取四行大写字母(全都是大写的,每行不超过72个字符),然后用柱状图输出每个字符在输入文件中出现的次数.严格地按照输出样例来安排你的输出格式. ...
- secureCRT The remote system refused the connection问题解决
问题: Ubuntu系统必须开启ssh服务后,XP或者其它的主机才干够远程登陆到Ubuntu系统. 1,安装软件包,运行sudo apt-get install openssh-server Ubun ...
- curl如何发起DELETE/PUT请求
curl如何发起DELETE/PUT请求 DELETE: curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); PUT: curl_setopt($ch ...