FACT++  1.0
void BasicGlCamera::UpdateText ( )
protectedvirtual

Definition at line 350 of file BasicGlCamera.cc.

References ACTUAL_NUM_PIXELS, dataText, fData, fmax, fmean, fmedian, fmin, frms, i, str, and unitsText.

Referenced by QCameraWidget::CalculatePixelsColor().

351  {
352  ostringstream str;
353  float min, max, median;
354  int ii=0;
355  for (;ii<ACTUAL_NUM_PIXELS;ii++)
356  {
357  if (finite(fData[ii]))
358  {
359  min = max = fData[ii];
360  break;
361  }
362  }
363  double mean = 0;
364  double rms = 0;
365  median = 0;
366  if (ii==ACTUAL_NUM_PIXELS)
367  {
368  fmin = fmax = fmean = frms = fmedian = 0;
369  return;
370  }
371 
372  vector<double> medianVec;
373  medianVec.resize(ACTUAL_NUM_PIXELS);
374  auto it = medianVec.begin();
375  int numSamples = 0;
376  for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
377  {
378  if (!finite(fData[i]))
379  continue;
380  if (fData[i] < min)
381  min = fData[i];
382  if (fData[i] > max)
383  max = fData[i];
384  mean += fData[i];
385  rms += fData[i]*fData[i];
386  //medianSet.insert(fData[i]);
387  *it = fData[i];
388  it++;
389  numSamples++;
390  }
391 
392 // vector<double> medianVec;
393 // medianVec.resize(ACTUAL_NUM_PIXELS);
394 // int iii=0;
395 // for (auto it=medianVec.begin(); it != medianVec.end(); it++) {
396 // *it = fData[iii];
397 // iii++;
398 // }
399  sort(medianVec.begin(), medianVec.begin()+numSamples);
400 
401 
402  mean /= numSamples;
403  rms = sqrt((rms/numSamples) - (mean * mean));
404 
405 // multiset<double>::iterator it = medianSet.begin();
406  auto jt = medianVec.begin();
407  for (int i=0;i<(numSamples/2)-1;i++)
408  {
409 // it++;
410  jt++;
411  }
412  median = *jt;
413  // cout << *it << " " << *jt << endl;
414  if (numSamples%2==0){
415  jt++;
416  median += *jt;
417  median /= 2;}
418 
419  str << "Min: " << min << endl << " Max: " << max << " Mean: " << mean << " RMS: " << rms << " Median: " << median;
420  str << " Units: " << unitsText;
421  dataText = str.str();
422 
423  fmin = min;
424  fmax = max;
425  fmean = mean;
426  frms = rms;
427  fmedian = median;
428  }
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
std::string dataText
Definition: BasicGlCamera.h:73
std::vector< double > fData
#define ACTUAL_NUM_PIXELS
Definition: BasicGlCamera.h:9
std::string unitsText
Definition: BasicGlCamera.h:74

+ Here is the caller graph for this function: