Commit d37ecaa4ab0e7d874e59e0df3b9f9b979336b230
1 parent
3f2b76da
Less casting
Showing
1 changed file
with
16 additions
and
21 deletions
openbr/core/boost.cpp
| ... | ... | @@ -431,8 +431,8 @@ void CascadeBoostTrainData::setData( const FeatureEvaluator* _featureEvaluator, |
| 431 | 431 | int* idst = 0; |
| 432 | 432 | unsigned short* udst = 0; |
| 433 | 433 | |
| 434 | - uint64 effective_buf_size = 0; | |
| 435 | - int effective_buf_height = 0, effective_buf_width = 0; | |
| 434 | + uint64_t effective_buf_size = 0; | |
| 435 | + uint64_t effective_buf_height = 0, effective_buf_width = 0; | |
| 436 | 436 | |
| 437 | 437 | clear(); |
| 438 | 438 | shared = true; |
| ... | ... | @@ -464,12 +464,7 @@ void CascadeBoostTrainData::setData( const FeatureEvaluator* _featureEvaluator, |
| 464 | 464 | |
| 465 | 465 | // 1048576 is the number of bytes in a megabyte |
| 466 | 466 | numPrecalcVal = min( cvRound((double)_precalcValBufSize*1048576. / (sizeof(float)*sample_count)), var_count ); |
| 467 | - qDebug("MB required to cache all %d features: %llu", var_count, (sizeof(float)*(uint64_t)sample_count*var_count)/1048576); | |
| 468 | - qDebug("Features cached: %.2f", float(numPrecalcVal)/var_count); | |
| 469 | - | |
| 470 | 467 | numPrecalcIdx = min( cvRound((double)_precalcIdxBufSize*1048576. / ((is_buf_16u ? sizeof(unsigned short) : sizeof (int))*sample_count)), var_count ); |
| 471 | - qDebug("MB required to cache all %d sorted indices: %llu", var_count, ((is_buf_16u ? sizeof(unsigned short) : sizeof (int))*(uint64_t)sample_count*var_count)/1048576); | |
| 472 | - qDebug("Indices cached: %.2f", float(numPrecalcIdx)/var_count); | |
| 473 | 468 | |
| 474 | 469 | assert( numPrecalcIdx >= 0 && numPrecalcVal >= 0 ); |
| 475 | 470 | |
| ... | ... | @@ -505,7 +500,7 @@ void CascadeBoostTrainData::setData( const FeatureEvaluator* _featureEvaluator, |
| 505 | 500 | |
| 506 | 501 | buf_size = -1; // the member buf_size is obsolete |
| 507 | 502 | |
| 508 | - effective_buf_size = (uint64)(work_var_count + 1)*(uint64)sample_count * buf_count; // this is the total size of "CvMat buf" to be allocated | |
| 503 | + effective_buf_size = (work_var_count + 1)*sample_count * buf_count; // this is the total size of "CvMat buf" to be allocated | |
| 509 | 504 | |
| 510 | 505 | effective_buf_width = sample_count; |
| 511 | 506 | effective_buf_height = work_var_count+1; |
| ... | ... | @@ -514,7 +509,7 @@ void CascadeBoostTrainData::setData( const FeatureEvaluator* _featureEvaluator, |
| 514 | 509 | else |
| 515 | 510 | effective_buf_width *= buf_count; |
| 516 | 511 | |
| 517 | - if ((uint64)effective_buf_width * (uint64)effective_buf_height != effective_buf_size) | |
| 512 | + if (effective_buf_width * effective_buf_height != effective_buf_size) | |
| 518 | 513 | { |
| 519 | 514 | CV_Error(CV_StsBadArg, "The memory buffer cannot be allocated since its size exceeds integer fields limit"); |
| 520 | 515 | } |
| ... | ... | @@ -548,9 +543,9 @@ void CascadeBoostTrainData::setData( const FeatureEvaluator* _featureEvaluator, |
| 548 | 543 | |
| 549 | 544 | // set sample labels |
| 550 | 545 | if (is_buf_16u) |
| 551 | - udst = (unsigned short*)(buf->data.s + (uint64)work_var_count*sample_count); | |
| 546 | + udst = (unsigned short*)(buf->data.s + (uint64_t)work_var_count*sample_count); | |
| 552 | 547 | else |
| 553 | - idst = buf->data.i + (uint64)work_var_count*sample_count; | |
| 548 | + idst = buf->data.i + (uint64_t)work_var_count*sample_count; | |
| 554 | 549 | |
| 555 | 550 | for (int si = 0; si < sample_count; si++) |
| 556 | 551 | { |
| ... | ... | @@ -635,9 +630,9 @@ void CascadeBoostTrainData::get_ord_var_data( CvDTreeNode* n, int vi, float* ord |
| 635 | 630 | // have we precalculated (presorted) the training samples by their feature response? |
| 636 | 631 | if (vi < numPrecalcIdx) { |
| 637 | 632 | if (!is_buf_16u) |
| 638 | - *sortedIndices = buf->data.i + n->buf_idx*get_length_subbuf() + (uint64)vi*sample_count + n->offset; | |
| 633 | + *sortedIndices = buf->data.i + n->buf_idx*get_length_subbuf() + (uint64_t)vi*sample_count + n->offset; | |
| 639 | 634 | else { |
| 640 | - const unsigned short* shortIndices = (const unsigned short*)(buf->data.s + n->buf_idx*get_length_subbuf() + (uint64)vi*sample_count + n->offset ); | |
| 635 | + const unsigned short* shortIndices = (const unsigned short*)(buf->data.s + n->buf_idx*get_length_subbuf() + (uint64_t)vi*sample_count + n->offset ); | |
| 641 | 636 | for (int i = 0; i < nodeSampleCount; i++) |
| 642 | 637 | sortedIndicesBuf[i] = shortIndices[i]; |
| 643 | 638 | *sortedIndices = sortedIndicesBuf; |
| ... | ... | @@ -746,16 +741,16 @@ struct IndexPrecalc : Precalc |
| 746 | 741 | idst = buf->data.i; |
| 747 | 742 | } |
| 748 | 743 | |
| 749 | - void setBuffer(int fi, int si) const | |
| 744 | + void setBuffer(uint64_t fi, uint64_t si) const | |
| 750 | 745 | { |
| 751 | - if (isBufShort) *(udst + (uint64)fi*sampleCount + si) = (unsigned short)si; | |
| 752 | - else *(idst + (uint64)fi*sampleCount + si) = si; | |
| 746 | + if (isBufShort) *(udst + fi*sampleCount + si) = (unsigned short)si; | |
| 747 | + else *(idst + fi*sampleCount + si) = si; | |
| 753 | 748 | } |
| 754 | 749 | |
| 755 | - void sortBuffer(int fi, float *valCachePtr) const | |
| 750 | + void sortBuffer(uint64_t fi, float *valCachePtr) const | |
| 756 | 751 | { |
| 757 | - if (isBufShort) icvSortUShAux(udst + (uint64)fi*sampleCount, sampleCount, valCachePtr); | |
| 758 | - else icvSortIntAux(idst + (uint64)fi*sampleCount, sampleCount, valCachePtr); | |
| 752 | + if (isBufShort) icvSortUShAux(udst + fi*sampleCount, sampleCount, valCachePtr); | |
| 753 | + else icvSortIntAux(idst + fi*sampleCount, sampleCount, valCachePtr); | |
| 759 | 754 | } |
| 760 | 755 | |
| 761 | 756 | virtual void operator()(const Range& range) const |
| ... | ... | @@ -1173,11 +1168,11 @@ void CascadeBoost::update_weights(CvBoostTree* tree) |
| 1173 | 1168 | // set the labels to find (from within weak tree learning proc) |
| 1174 | 1169 | // the particular sample weight, and where to store the response. |
| 1175 | 1170 | if (data->is_buf_16u) { |
| 1176 | - unsigned short* labels = (unsigned short*)(buf->data.s + data->data_root->buf_idx*length_buf_row + data->data_root->offset + (uint64)(data->work_var_count-1)*data->sample_count); | |
| 1171 | + unsigned short* labels = (unsigned short*)(buf->data.s + data->data_root->buf_idx*length_buf_row + data->data_root->offset + (uint64_t)(data->work_var_count-1)*data->sample_count); | |
| 1177 | 1172 | for (int i = 0; i < n; i++) |
| 1178 | 1173 | labels[i] = (unsigned short)i; |
| 1179 | 1174 | } else { |
| 1180 | - int* labels = buf->data.i + data->data_root->buf_idx*length_buf_row + data->data_root->offset + (uint64)(data->work_var_count-1)*data->sample_count; | |
| 1175 | + int* labels = buf->data.i + data->data_root->buf_idx*length_buf_row + data->data_root->offset + (uint64_t)(data->work_var_count-1)*data->sample_count; | |
| 1181 | 1176 | for( int i = 0; i < n; i++ ) |
| 1182 | 1177 | labels[i] = i; |
| 1183 | 1178 | } | ... | ... |