|
|
|
@ -437,7 +437,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id |
|
|
|
|
if (is_buf_16u) |
|
|
|
|
{ |
|
|
|
|
unsigned short* udst_idx = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() + |
|
|
|
|
vi*sample_count + data_root->offset); |
|
|
|
|
(size_t)vi*sample_count + data_root->offset); |
|
|
|
|
for( int i = 0; i < num_valid; i++ ) |
|
|
|
|
{ |
|
|
|
|
idx = src_idx[i]; |
|
|
|
@ -450,7 +450,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int* idst_idx = buf->data.i + root->buf_idx*get_length_subbuf() + |
|
|
|
|
vi*sample_count + root->offset; |
|
|
|
|
(size_t)vi*sample_count + root->offset; |
|
|
|
|
for( int i = 0; i < num_valid; i++ ) |
|
|
|
|
{ |
|
|
|
|
idx = src_idx[i]; |
|
|
|
@ -467,14 +467,14 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id |
|
|
|
|
if (is_buf_16u) |
|
|
|
|
{ |
|
|
|
|
unsigned short* udst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() + |
|
|
|
|
(workVarCount-1)*sample_count + root->offset); |
|
|
|
|
(size_t)(workVarCount-1)*sample_count + root->offset); |
|
|
|
|
for( int i = 0; i < count; i++ ) |
|
|
|
|
udst[i] = (unsigned short)src_lbls[sidx[i]]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int* idst = buf->data.i + root->buf_idx*get_length_subbuf() + |
|
|
|
|
(workVarCount-1)*sample_count + root->offset; |
|
|
|
|
(size_t)(workVarCount-1)*sample_count + root->offset; |
|
|
|
|
for( int i = 0; i < count; i++ ) |
|
|
|
|
idst[i] = src_lbls[sidx[i]]; |
|
|
|
|
} |
|
|
|
@ -484,14 +484,14 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id |
|
|
|
|
if (is_buf_16u) |
|
|
|
|
{ |
|
|
|
|
unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() + |
|
|
|
|
workVarCount*sample_count + root->offset); |
|
|
|
|
(size_t)workVarCount*sample_count + root->offset); |
|
|
|
|
for( int i = 0; i < count; i++ ) |
|
|
|
|
sample_idx_dst[i] = (unsigned short)sample_idx_src[sidx[i]]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int* sample_idx_dst = buf->data.i + root->buf_idx*get_length_subbuf() + |
|
|
|
|
workVarCount*sample_count + root->offset; |
|
|
|
|
(size_t)workVarCount*sample_count + root->offset; |
|
|
|
|
for( int i = 0; i < count; i++ ) |
|
|
|
|
sample_idx_dst[i] = sample_idx_src[sidx[i]]; |
|
|
|
|
} |
|
|
|
@ -677,9 +677,9 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat |
|
|
|
|
|
|
|
|
|
// set sample labels
|
|
|
|
|
if (is_buf_16u) |
|
|
|
|
udst = (unsigned short*)(buf->data.s + work_var_count*sample_count); |
|
|
|
|
udst = (unsigned short*)(buf->data.s + (size_t)work_var_count*sample_count); |
|
|
|
|
else |
|
|
|
|
idst = buf->data.i + work_var_count*sample_count; |
|
|
|
|
idst = buf->data.i + (size_t)work_var_count*sample_count; |
|
|
|
|
|
|
|
|
|
for (int si = 0; si < sample_count; si++) |
|
|
|
|
{ |
|
|
|
@ -747,11 +747,11 @@ void CvCascadeBoostTrainData::get_ord_var_data( CvDTreeNode* n, int vi, float* o |
|
|
|
|
if ( vi < numPrecalcIdx ) |
|
|
|
|
{ |
|
|
|
|
if( !is_buf_16u ) |
|
|
|
|
*sortedIndices = buf->data.i + n->buf_idx*get_length_subbuf() + vi*sample_count + n->offset; |
|
|
|
|
*sortedIndices = buf->data.i + n->buf_idx*get_length_subbuf() + (size_t)vi*sample_count + n->offset; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
const unsigned short* shortIndices = (const unsigned short*)(buf->data.s + n->buf_idx*get_length_subbuf() + |
|
|
|
|
vi*sample_count + n->offset ); |
|
|
|
|
(size_t)vi*sample_count + n->offset ); |
|
|
|
|
for( int i = 0; i < nodeSampleCount; i++ ) |
|
|
|
|
sortedIndicesBuf[i] = shortIndices[i]; |
|
|
|
|
|
|
|
|
@ -862,14 +862,14 @@ struct FeatureIdxOnlyPrecalc : ParallelLoopBody |
|
|
|
|
{ |
|
|
|
|
valCachePtr[si] = (*featureEvaluator)( fi, si ); |
|
|
|
|
if ( is_buf_16u ) |
|
|
|
|
*(udst + fi*sample_count + si) = (unsigned short)si; |
|
|
|
|
*(udst + (size_t)fi*sample_count + si) = (unsigned short)si; |
|
|
|
|
else |
|
|
|
|
*(idst + fi*sample_count + si) = si; |
|
|
|
|
*(idst + (size_t)fi*sample_count + si) = si; |
|
|
|
|
} |
|
|
|
|
if ( is_buf_16u ) |
|
|
|
|
std::sort(udst + fi*sample_count, udst + (fi + 1)*sample_count, LessThanIdx<float, unsigned short>(valCachePtr) ); |
|
|
|
|
std::sort(udst + (size_t)fi*sample_count, udst + (size_t)(fi + 1)*sample_count, LessThanIdx<float, unsigned short>(valCachePtr) ); |
|
|
|
|
else |
|
|
|
|
std::sort(idst + fi*sample_count, idst + (fi + 1)*sample_count, LessThanIdx<float, int>(valCachePtr) ); |
|
|
|
|
std::sort(idst + (size_t)fi*sample_count, idst + (size_t)(fi + 1)*sample_count, LessThanIdx<float, int>(valCachePtr) ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const CvFeatureEvaluator* featureEvaluator; |
|
|
|
@ -898,14 +898,14 @@ struct FeatureValAndIdxPrecalc : ParallelLoopBody |
|
|
|
|
{ |
|
|
|
|
valCache->at<float>(fi,si) = (*featureEvaluator)( fi, si ); |
|
|
|
|
if ( is_buf_16u ) |
|
|
|
|
*(udst + fi*sample_count + si) = (unsigned short)si; |
|
|
|
|
*(udst + (size_t)fi*sample_count + si) = (unsigned short)si; |
|
|
|
|
else |
|
|
|
|
*(idst + fi*sample_count + si) = si; |
|
|
|
|
*(idst + (size_t)fi*sample_count + si) = si; |
|
|
|
|
} |
|
|
|
|
if ( is_buf_16u ) |
|
|
|
|
std::sort(udst + fi*sample_count, udst + (fi + 1)*sample_count, LessThanIdx<float, unsigned short>(valCache->ptr<float>(fi)) ); |
|
|
|
|
std::sort(udst + (size_t)fi*sample_count, udst + (size_t)(fi + 1)*sample_count, LessThanIdx<float, unsigned short>(valCache->ptr<float>(fi)) ); |
|
|
|
|
else |
|
|
|
|
std::sort(idst + fi*sample_count, idst + (fi + 1)*sample_count, LessThanIdx<float, int>(valCache->ptr<float>(fi)) ); |
|
|
|
|
std::sort(idst + (size_t)fi*sample_count, idst + (size_t)(fi + 1)*sample_count, LessThanIdx<float, int>(valCache->ptr<float>(fi)) ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const CvFeatureEvaluator* featureEvaluator; |
|
|
|
@ -1228,9 +1228,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node ) |
|
|
|
|
if (data->is_buf_16u) |
|
|
|
|
{ |
|
|
|
|
unsigned short *ldst = (unsigned short *)(buf->data.s + left->buf_idx*length_buf_row + |
|
|
|
|
(workVarCount-1)*scount + left->offset); |
|
|
|
|
(size_t)(workVarCount-1)*scount + left->offset); |
|
|
|
|
unsigned short *rdst = (unsigned short *)(buf->data.s + right->buf_idx*length_buf_row + |
|
|
|
|
(workVarCount-1)*scount + right->offset); |
|
|
|
|
(size_t)(workVarCount-1)*scount + right->offset); |
|
|
|
|
|
|
|
|
|
for( int i = 0; i < n; i++ ) |
|
|
|
|
{ |
|
|
|
@ -1251,9 +1251,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node ) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int *ldst = buf->data.i + left->buf_idx*length_buf_row + |
|
|
|
|
(workVarCount-1)*scount + left->offset; |
|
|
|
|
(size_t)(workVarCount-1)*scount + left->offset; |
|
|
|
|
int *rdst = buf->data.i + right->buf_idx*length_buf_row + |
|
|
|
|
(workVarCount-1)*scount + right->offset; |
|
|
|
|
(size_t)(workVarCount-1)*scount + right->offset; |
|
|
|
|
|
|
|
|
|
for( int i = 0; i < n; i++ ) |
|
|
|
|
{ |
|
|
|
@ -1281,9 +1281,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node ) |
|
|
|
|
if (data->is_buf_16u) |
|
|
|
|
{ |
|
|
|
|
unsigned short* ldst = (unsigned short*)(buf->data.s + left->buf_idx*length_buf_row + |
|
|
|
|
workVarCount*scount + left->offset); |
|
|
|
|
(size_t)workVarCount*scount + left->offset); |
|
|
|
|
unsigned short* rdst = (unsigned short*)(buf->data.s + right->buf_idx*length_buf_row + |
|
|
|
|
workVarCount*scount + right->offset); |
|
|
|
|
(size_t)workVarCount*scount + right->offset); |
|
|
|
|
for (int i = 0; i < n; i++) |
|
|
|
|
{ |
|
|
|
|
unsigned short idx = (unsigned short)tempBuf[i]; |
|
|
|
@ -1302,9 +1302,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node ) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int* ldst = buf->data.i + left->buf_idx*length_buf_row + |
|
|
|
|
workVarCount*scount + left->offset; |
|
|
|
|
(size_t)workVarCount*scount + left->offset; |
|
|
|
|
int* rdst = buf->data.i + right->buf_idx*length_buf_row + |
|
|
|
|
workVarCount*scount + right->offset; |
|
|
|
|
(size_t)workVarCount*scount + right->offset; |
|
|
|
|
for (int i = 0; i < n; i++) |
|
|
|
|
{ |
|
|
|
|
int idx = tempBuf[i]; |
|
|
|
@ -1473,7 +1473,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree ) |
|
|
|
|
if (data->is_buf_16u) |
|
|
|
|
{ |
|
|
|
|
unsigned short* labels = (unsigned short*)(buf->data.s + data->data_root->buf_idx*length_buf_row + |
|
|
|
|
data->data_root->offset + (data->work_var_count-1)*data->sample_count); |
|
|
|
|
data->data_root->offset + (size_t)(data->work_var_count-1)*data->sample_count); |
|
|
|
|
for( int i = 0; i < n; i++ ) |
|
|
|
|
{ |
|
|
|
|
// save original categorical responses {0,1}, convert them to {-1,1}
|
|
|
|
@ -1491,7 +1491,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree ) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int* labels = buf->data.i + data->data_root->buf_idx*length_buf_row + |
|
|
|
|
data->data_root->offset + (data->work_var_count-1)*data->sample_count; |
|
|
|
|
data->data_root->offset + (size_t)(data->work_var_count-1)*data->sample_count; |
|
|
|
|
|
|
|
|
|
for( int i = 0; i < n; i++ ) |
|
|
|
|
{ |
|
|
|
|