Commit cf6ae36bb1492d22029cdbc3ba085b06713836ec

Authored by Scott Klum
1 parent a3840e54

More cleanup

Showing 1 changed file with 15 additions and 13 deletions
openbr/core/boost.cpp
... ... @@ -464,10 +464,12 @@ 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("Features Cached: %f", float(numPrecalcVal)/var_count);
  467 + qDebug("MB required to cache all %d features: %d", var_count, (sizeof(float)*(uint64_t)sample_count*var_count)/1048576);
  468 + qDebug("Features cached: %.2f", float(numPrecalcVal)/var_count);
468 469  
469 470 numPrecalcIdx = min( cvRound((double)_precalcIdxBufSize*1048576. / ((is_buf_16u ? sizeof(unsigned short) : sizeof (int))*sample_count)), var_count );
470   - qDebug("Indices Cached: %f", float(numPrecalcIdx)/var_count);
  471 + qDebug("MB required to cache all %d sorted indices: %d", 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);
471 473  
472 474 assert( numPrecalcIdx >= 0 && numPrecalcVal >= 0 );
473 475  
... ... @@ -883,7 +885,7 @@ void CascadeBoostTree::split_node_data( CvDTreeNode* node )
883 885  
884 886 complete_node_dir(node);
885 887  
886   - for (int i = nLeft = nRight = 0; i < nodeSampleCount; i++)
  888 + for (uint64_t i = nLeft = nRight = 0; i < nodeSampleCount; i++)
887 889 {
888 890 int d = dir[i];
889 891 // initialize new indices for splitting ordered variables
... ... @@ -912,7 +914,7 @@ void CascadeBoostTree::split_node_data( CvDTreeNode* node )
912 914  
913 915 data->get_ord_var_data(node, vi, src_val_buf, src_sorted_idx_buf, &src_val, &src_sorted_idx, src_sample_idx_buf);
914 916  
915   - for(int i = 0; i < nodeSampleCount; i++)
  917 + for(uint64_t i = 0; i < nodeSampleCount; i++)
916 918 tempBuf[i] = src_sorted_idx[i];
917 919  
918 920 if (data->is_buf_16u) {
... ... @@ -933,7 +935,6 @@ void CascadeBoostTree::split_node_data( CvDTreeNode* node )
933 935 ldst++;
934 936 }
935 937 }
936   - CV_Assert( n1 == nodeSampleCount );
937 938 }
938 939 else
939 940 {
... ... @@ -958,7 +959,6 @@ void CascadeBoostTree::split_node_data( CvDTreeNode* node )
958 959 ldst++;
959 960 }
960 961 }
961   - CV_Assert( n1 == nodeSampleCount );
962 962 }
963 963 }
964 964  
... ... @@ -966,14 +966,14 @@ void CascadeBoostTree::split_node_data( CvDTreeNode* node )
966 966 int *src_lbls_buf = tempBuf + nodeSampleCount;
967 967 const int* src_lbls = data->get_cv_labels(node, src_lbls_buf);
968 968  
969   - for(int i = 0; i < nodeSampleCount; i++)
  969 + for(uint64_t i = 0; i < nodeSampleCount; i++)
970 970 tempBuf[i] = src_lbls[i];
971 971  
972 972 if (data->is_buf_16u) {
973 973 unsigned short *ldst = (unsigned short *)(buf->data.s + left->buf_idx*length_buf_row + (workVarCount-1)*sampleCount + left->offset);
974 974 unsigned short *rdst = (unsigned short *)(buf->data.s + right->buf_idx*length_buf_row + (workVarCount-1)*sampleCount + right->offset);
975 975  
976   - for( int i = 0; i < nodeSampleCount; i++ ) {
  976 + for( uint64_t i = 0; i < nodeSampleCount; i++ ) {
977 977 int idx = tempBuf[i];
978 978 if (dir[i]) {
979 979 *rdst = (unsigned short)idx;
... ... @@ -990,7 +990,7 @@ void CascadeBoostTree::split_node_data( CvDTreeNode* node )
990 990 int *ldst = buf->data.i + left->buf_idx*length_buf_row + (workVarCount-1)*sampleCount + left->offset;
991 991 int *rdst = buf->data.i + right->buf_idx*length_buf_row + (workVarCount-1)*sampleCount + right->offset;
992 992  
993   - for( int i = 0; i < nodeSampleCount; i++ )
  993 + for( uint64_t i = 0; i < nodeSampleCount; i++ )
994 994 {
995 995 int idx = tempBuf[i];
996 996 if (dir[i])
... ... @@ -1010,13 +1010,13 @@ void CascadeBoostTree::split_node_data( CvDTreeNode* node )
1010 1010 int *sampleIdx_src_buf = tempBuf + nodeSampleCount;
1011 1011 const int* sampleIdx_src = data->get_sample_indices(node, sampleIdx_src_buf);
1012 1012  
1013   - for(int i = 0; i < nodeSampleCount; i++)
  1013 + for(uint64_t i = 0; i < nodeSampleCount; i++)
1014 1014 tempBuf[i] = sampleIdx_src[i];
1015 1015  
1016 1016 if (data->is_buf_16u) {
1017 1017 unsigned short* ldst = (unsigned short*)(buf->data.s + left->buf_idx*length_buf_row + workVarCount*sampleCount + left->offset);
1018 1018 unsigned short* rdst = (unsigned short*)(buf->data.s + right->buf_idx*length_buf_row + workVarCount*sampleCount + right->offset);
1019   - for (int i = 0; i < nodeSampleCount; i++) {
  1019 + for (uint64_t i = 0; i < nodeSampleCount; i++) {
1020 1020 unsigned short idx = (unsigned short)tempBuf[i];
1021 1021 if (dir[i]) {
1022 1022 *rdst = idx;
... ... @@ -1031,11 +1031,12 @@ void CascadeBoostTree::split_node_data( CvDTreeNode* node )
1031 1031 {
1032 1032 int* ldst = buf->data.i + left->buf_idx*length_buf_row + workVarCount*sampleCount + left->offset;
1033 1033 int* rdst = buf->data.i + right->buf_idx*length_buf_row + workVarCount*sampleCount + right->offset;
1034   - for (int i = 0; i < nodeSampleCount; i++)
  1034 + for (uint64_t i = 0; i < nodeSampleCount; i++)
1035 1035 {
1036 1036 int idx = tempBuf[i];
1037 1037 if (dir[i])
1038 1038 {
  1039 +
1039 1040 *rdst = idx;
1040 1041 rdst++;
1041 1042 }
... ... @@ -1061,7 +1062,8 @@ void CascadeBoostTree::split_node_data( CvDTreeNode* node )
1061 1062  
1062 1063 void CascadeBoost::train(const FeatureEvaluator* _featureEvaluator,
1063 1064 int _numSamples,
1064   - int _precalcValBufSize, int _precalcIdxBufSize,
  1065 + int _precalcValBufSize,
  1066 + int _precalcIdxBufSize,
1065 1067 int _channels,
1066 1068 const CascadeBoostParams& _params)
1067 1069 {
... ...