tensorflow/tools/android/test/jni/object_tracking/frame_pair.cc
// Returns the median delta from a sorted set of weighted deltas.
Returns the median delta from a sorted set of weighted deltas.
Returns the median delta from a sorted set of weighted deltas .
static float GetMedian(const int num_items,
                       const WeightedDelta* const weighted_deltas,
                       const float sum) {
  if (num_items == 0 || sum < EPSILON) {
    return 0.0f;
  }
  float current_weight = 0.0f;
  const float target_weight = sum / 2.0f;
  for (int i = 0; i < num_items; ++i) {
    if (weighted_deltas[i].weight > 0.0f) {
      current_weight += weighted_deltas[i].weight;
      if (current_weight >= target_weight) {
        return weighted_deltas[i].delta;
      }
    }
  }
  LOGW("Median not found! %d points, sum of %.2f", num_items, sum);
  return 0.0f;
}
static float GetMedian ( const int num_items , const WeightedDelta * const weighted_deltas , const float sum ) { if ( num_items == 0 || sum < EPSILON ) { return 0.0f ; } float current_weight = 0.0f ; const float target_weight = sum / 2.0f ; for ( int i = 0 ; i < num_items ; ++ i ) { if ( weighted_deltas [ i ] . weight > 0.0f ) { current_weight += weighted_deltas [ i ] . weight ; if ( current_weight >= target_weight ) { return weighted_deltas [ i ] . delta ; } } } LOGW ( " " , num_items , sum ) ; return 0.0f ; }
Returns the median delta from a sorted set of weighted deltas.
Returns the median delta from a sorted set of weighted deltas .