<commit_before>/*
 * File:   SimpleFieldColorClassifier.cpp
 * Author: claas
 * 
 * Created on 15. Mrz 2011, 15:56
 */

#include "SimpleFieldColorClassifier.h"

// Debug
#include "Tools/Debug/DebugRequest.h"
#include "Tools/Debug/DebugImageDrawings.h"
#include "Tools/Debug/Stopwatch.h"
#include "Tools/Debug/DebugModify.h"
#include "Tools/Debug/DebugBufferedOutput.h"

using namespace std;

SimpleFieldColorClassifier::SimpleFieldColorClassifier()
: 
  cameraID(CameraInfo::Bottom),
  uniformGrid(getImage().width(), getImage().height(), 60, 40)
{
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:TopCam:markCrClassification", "", false);
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:TopCam:markYClassification", "", false);
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:BottomCam:markYClassification", "", false);
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:BottomCam:markCrClassification", "", false);

  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:TopCam:mark_green", "", false);
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:BottomCam:mark_green", "", false);

  //collect only last x seconds of histogram data
  filteredHistogramY.setMaxTotalSum(uniformGrid.size() * 30 * parameters.collectionTimeSpan);
  filteredHistogramU.setMaxTotalSum(uniformGrid.size()/* * 30 * parameters.collectionTimeSpan*/);
  filteredHistogramV.setMaxTotalSum(uniformGrid.size() /** 30 * parameters.collectionTimeSpan*/);  
}

void SimpleFieldColorClassifier::execute(const CameraInfo::CameraID id)
{
  cameraID = id;
  CANVAS_PX(cameraID);

  // check if a fresh histogram is avaliable
  if(!getColorChannelHistograms().colorChannelIsUptodate) {
    return;
  }

  const Statistics::HistogramX& histY = getColorChannelHistograms().histogramY;
  double start = histY.min;
  double end = histY.max;
  double halfSpan = histY.spanWidth / 2.0;
  double quadSpan = histY.spanWidth / 4.0;

  double common = histY.median;

  if(filteredHistogramY.sum != 0)
  {
      common = filteredHistogramY.median;
      start = (filteredHistogramY.min + start) /2;
      end = (filteredHistogramY.max + end) / 2;
  }

  for(int i = 0; i < getColorChannelHistograms().histogramY.size; i++)
  {
    double f = 1.0;
    if(filteredHistogramY.spanWidth > 0 /*&& ((int) getFrameInfo().getTimeInSeconds()) % 2 == 0*/)
    {
      double s = 0.0;
      if(i <= common)
      {<commit_msg>clear U channel histogram every frame (collect it only for that frame)<commit_after>/*
 * File:   SimpleFieldColorClassifier.cpp
 * Author: claas
 * 
 * Created on 15. Mrz 2011, 15:56
 */

#include "SimpleFieldColorClassifier.h"

// Debug
#include "Tools/Debug/DebugRequest.h"
#include "Tools/Debug/DebugImageDrawings.h"
#include "Tools/Debug/Stopwatch.h"
#include "Tools/Debug/DebugModify.h"
#include "Tools/Debug/DebugBufferedOutput.h"

using namespace std;

SimpleFieldColorClassifier::SimpleFieldColorClassifier()
: 
  cameraID(CameraInfo::Bottom),
  uniformGrid(getImage().width(), getImage().height(), 60, 40)
{
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:TopCam:markCrClassification", "", false);
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:TopCam:markYClassification", "", false);
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:BottomCam:markYClassification", "", false);
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:BottomCam:markCrClassification", "", false);

  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:TopCam:mark_green", "", false);
  DEBUG_REQUEST_REGISTER("Vision:ColorClassifiers:SimpleFieldColorClassifier:BottomCam:mark_green", "", false);

  //collect only last x seconds of histogram data
  filteredHistogramY.setMaxTotalSum(uniformGrid.size() * 30 * parameters.collectionTimeSpan);
  //filteredHistogramU.setMaxTotalSum(uniformGrid.size()/* * 30 * parameters.collectionTimeSpan*/);
  filteredHistogramV.setMaxTotalSum(uniformGrid.size() * 30 * parameters.collectionTimeSpan);  
}

void SimpleFieldColorClassifier::execute(const CameraInfo::CameraID id)
{
  cameraID = id;
  CANVAS_PX(cameraID);

  // check if a fresh histogram is avaliable
  if(!getColorChannelHistograms().colorChannelIsUptodate) {
    return;
  }

  filteredHistogramU.clear();
  //filteredHistogramV.clear();

  const Statistics::HistogramX& histY = getColorChannelHistograms().histogramY;
  double start = histY.min;
  double end = histY.max;
  double halfSpan = histY.spanWidth / 2.0;
  double quadSpan = histY.spanWidth / 4.0;

  double common = histY.median;

  if(filteredHistogramY.sum != 0)
  {
      common = filteredHistogramY.median;
      start = (filteredHistogramY.min + start) /2;
      end = (filteredHistogramY.max + end) / 2;
  }

  for(int i = 0; i < getColorChannelHistograms().histogramY.size; i++)
  {
    double f = 1.0;
    if(filteredHistogramY.spanWidth > 0 /*&& ((int) getFrameInfo().getTimeInSeconds()) % 2 == 0*/)
    {
      double s = 0.0;
      if(i <= common)
      {
{'fraction_non_alphanumeric': 0.12528912875867387, 'fraction_numerical': 0.013492675404780262, 'mean_word_length': 5.593392630241423, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6547087', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1619, 'n_words': 275}