Merge pull request #3898 from greensea:2.4

This commit is contained in:
Vadim Pisarevsky 2015-04-07 09:31:36 +00:00
commit a153948a19

View File

@ -374,7 +374,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
if (is_buf_16u) if (is_buf_16u)
{ {
unsigned short* udst_idx = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() + 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++ ) for( int i = 0; i < num_valid; i++ )
{ {
idx = src_idx[i]; idx = src_idx[i];
@ -387,7 +387,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
else else
{ {
int* idst_idx = buf->data.i + root->buf_idx*get_length_subbuf() + 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++ ) for( int i = 0; i < num_valid; i++ )
{ {
idx = src_idx[i]; idx = src_idx[i];
@ -404,14 +404,14 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
if (is_buf_16u) if (is_buf_16u)
{ {
unsigned short* udst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() + 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++ ) for( int i = 0; i < count; i++ )
udst[i] = (unsigned short)src_lbls[sidx[i]]; udst[i] = (unsigned short)src_lbls[sidx[i]];
} }
else else
{ {
int* idst = buf->data.i + root->buf_idx*get_length_subbuf() + 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++ ) for( int i = 0; i < count; i++ )
idst[i] = src_lbls[sidx[i]]; idst[i] = src_lbls[sidx[i]];
} }
@ -421,14 +421,14 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
if (is_buf_16u) if (is_buf_16u)
{ {
unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() + 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++ ) for( int i = 0; i < count; i++ )
sample_idx_dst[i] = (unsigned short)sample_idx_src[sidx[i]]; sample_idx_dst[i] = (unsigned short)sample_idx_src[sidx[i]];
} }
else else
{ {
int* sample_idx_dst = buf->data.i + root->buf_idx*get_length_subbuf() + 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++ ) for( int i = 0; i < count; i++ )
sample_idx_dst[i] = sample_idx_src[sidx[i]]; sample_idx_dst[i] = sample_idx_src[sidx[i]];
} }
@ -614,9 +614,9 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat
// set sample labels // set sample labels
if (is_buf_16u) 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 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++) for (int si = 0; si < sample_count; si++)
{ {
@ -684,11 +684,11 @@ void CvCascadeBoostTrainData::get_ord_var_data( CvDTreeNode* n, int vi, float* o
if ( vi < numPrecalcIdx ) if ( vi < numPrecalcIdx )
{ {
if( !is_buf_16u ) 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 else
{ {
const unsigned short* shortIndices = (const unsigned short*)(buf->data.s + n->buf_idx*get_length_subbuf() + 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++ ) for( int i = 0; i < nodeSampleCount; i++ )
sortedIndicesBuf[i] = shortIndices[i]; sortedIndicesBuf[i] = shortIndices[i];
@ -799,14 +799,14 @@ struct FeatureIdxOnlyPrecalc : ParallelLoopBody
{ {
valCachePtr[si] = (*featureEvaluator)( fi, si ); valCachePtr[si] = (*featureEvaluator)( fi, si );
if ( is_buf_16u ) if ( is_buf_16u )
*(udst + fi*sample_count + si) = (unsigned short)si; *(udst + (size_t)fi*sample_count + si) = (unsigned short)si;
else else
*(idst + fi*sample_count + si) = si; *(idst + (size_t)fi*sample_count + si) = si;
} }
if ( is_buf_16u ) if ( is_buf_16u )
icvSortUShAux( udst + fi*sample_count, sample_count, valCachePtr ); icvSortUShAux( udst + (size_t)fi*sample_count, sample_count, valCachePtr );
else else
icvSortIntAux( idst + fi*sample_count, sample_count, valCachePtr ); icvSortIntAux( idst + (size_t)fi*sample_count, sample_count, valCachePtr );
} }
} }
const CvFeatureEvaluator* featureEvaluator; const CvFeatureEvaluator* featureEvaluator;
@ -835,14 +835,14 @@ struct FeatureValAndIdxPrecalc : ParallelLoopBody
{ {
valCache->at<float>(fi,si) = (*featureEvaluator)( fi, si ); valCache->at<float>(fi,si) = (*featureEvaluator)( fi, si );
if ( is_buf_16u ) if ( is_buf_16u )
*(udst + fi*sample_count + si) = (unsigned short)si; *(udst + (size_t)fi*sample_count + si) = (unsigned short)si;
else else
*(idst + fi*sample_count + si) = si; *(idst + (size_t)fi*sample_count + si) = si;
} }
if ( is_buf_16u ) if ( is_buf_16u )
icvSortUShAux( udst + fi*sample_count, sample_count, valCache->ptr<float>(fi) ); icvSortUShAux( udst + (size_t)fi*sample_count, sample_count, valCache->ptr<float>(fi) );
else else
icvSortIntAux( idst + fi*sample_count, sample_count, valCache->ptr<float>(fi) ); icvSortIntAux( idst + (size_t)fi*sample_count, sample_count, valCache->ptr<float>(fi) );
} }
} }
const CvFeatureEvaluator* featureEvaluator; const CvFeatureEvaluator* featureEvaluator;
@ -1165,9 +1165,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
if (data->is_buf_16u) if (data->is_buf_16u)
{ {
unsigned short *ldst = (unsigned short *)(buf->data.s + left->buf_idx*length_buf_row + 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 + 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++ ) for( int i = 0; i < n; i++ )
{ {
@ -1188,9 +1188,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
else else
{ {
int *ldst = buf->data.i + left->buf_idx*length_buf_row + 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 + 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++ ) for( int i = 0; i < n; i++ )
{ {
@ -1218,9 +1218,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
if (data->is_buf_16u) if (data->is_buf_16u)
{ {
unsigned short* ldst = (unsigned short*)(buf->data.s + left->buf_idx*length_buf_row + 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 + 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++) for (int i = 0; i < n; i++)
{ {
unsigned short idx = (unsigned short)tempBuf[i]; unsigned short idx = (unsigned short)tempBuf[i];
@ -1239,9 +1239,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
else else
{ {
int* ldst = buf->data.i + left->buf_idx*length_buf_row + 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 + 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++) for (int i = 0; i < n; i++)
{ {
int idx = tempBuf[i]; int idx = tempBuf[i];
@ -1410,7 +1410,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree )
if (data->is_buf_16u) if (data->is_buf_16u)
{ {
unsigned short* labels = (unsigned short*)(buf->data.s + data->data_root->buf_idx*length_buf_row + 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++ ) for( int i = 0; i < n; i++ )
{ {
// save original categorical responses {0,1}, convert them to {-1,1} // save original categorical responses {0,1}, convert them to {-1,1}
@ -1428,7 +1428,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree )
else else
{ {
int* labels = buf->data.i + data->data_root->buf_idx*length_buf_row + 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++ ) for( int i = 0; i < n; i++ )
{ {