void WorldDrawer::drawParticles(Particle averageParticle, std::vector<Particle> * particles)
{
    for(unsigned int i = 0; i < particles->size(); i++)
    {
        int r, g, b;
        getHeatMapColor(particles->at(i).weight, r, g, b);
        drawSample(particles->at(i).position, CV_RGB(r, g, b));
    }

    drawSample(WorldModel::currentPose, CV_RGB(255, 255, 255));

    drawSample(averageParticle.position, CV_RGB(255, 0, 0));
}
/*!
  Draw an interval of the bar chart

  \param painter Painter
  \param xMap Maps x-values into pixel coordinates.
  \param yMap Maps y-values into pixel coordinates.
  \param canvasRect Contents rectangle of the canvas
  \param from Index of the first point to be painted
  \param to Index of the last point to be painted. If to < 0 the
         curve will be painted to its last point.

  \sa drawSymbols()
*/
void QwtPlotMultiBarChart::drawSeries( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect, int from, int to ) const
{
    if ( to < 0 )
        to = dataSize() - 1;

    if ( from < 0 )
        from = 0;

    if ( from > to )
        return;


    const QRectF br = data()->boundingRect();
    const QwtInterval interval( br.left(), br.right() );

    painter->save();

    for ( int i = from; i <= to; i++ )
    {
        drawSample( painter, xMap, yMap,
            canvasRect, interval, i, sample( i ) );
    }

    painter->restore();
}
Mat PcaModel::drawSample(float sigma /*= 1.0f*/)
{
	std::normal_distribution<float> distribution(0.0f, sigma); // TODO: c'tor takes the stddev. Update all the documentation!!!

	vector<float> alphas(getNumberOfPrincipalComponents());

	for (auto& a : alphas) {
		a = distribution(engine);
	}

	return drawSample(alphas);

	/* without calling drawSample(alphas): (maybe if we add noise)
	Mat alphas = Mat::zeros(getNumberOfPrincipalComponents(), 1, CV_32FC1);
	for (int row=0; row < alphas.rows; ++row) {
		alphas.at<float>(row, 0) = distribution(engine);
	}
	*/

	/* with noise: (does the noise make sense in drawSample(vector<float> coefficients)?)
	unsigned int vsize = mean.size();
	vector epsilon = Utils::generateNormalVector(vectorSize) * sqrt(m_noiseVariance);
	return m_mean + m_pcaBasisMatrix * coefficients + epsilon;
	*/
}
Exemple #4
0
void ImageViewer::paintEvent(QPaintEvent* event) {
	if (!_draw) {
		return;
	}

    if (_core == NULL) {
        drawSample(event);
    } else {
        drawSlice(event);
    }
}
Exemple #5
0
void GLLUTWidget::samplePixel(const yuv & color) {
  //compute slice it sits on:
  int i=_lut->norm2lutX(color.y);
  if (i >= 0 && i < (int)slices.size()) {
    //old:
    //slices[i]->sampler->surface.setPixel(_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v),rgba(255,255,255,255));
    //new: draw an X
    drawSample(i,_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v));
    slices[i]->sampler_update_pending=true;
    redraw();
  }
  
}
Exemple #6
0
static void
display(void)
{
  int numX = NUM_ENV_MODES, numY = NUM_BASE_FORMATS;
  float xBase = (float) winWidth * 0.01;
  float xOffset = (winWidth - xBase) / numX;
  float xSize = max(xOffset - xBase, 1);
  float yBase = (float) winHeight * 0.01;
  float yOffset = (winHeight - yBase) / numY;
  float ySize = max(yOffset - yBase, 1);
  float x, y;
  int i, j;

  glViewport(0, 0, winWidth, winHeight);
  glDisable(GL_SCISSOR_TEST);
  glClearColor(0.0, 0.0, 0.0, 0.0);
  glClear(GL_COLOR_BUFFER_BIT);
  glEnable(GL_SCISSOR_TEST);

  x = xBase;
  y = (winHeight - 1) - yOffset;
  for (i = 0; i < NUM_BASE_FORMATS; ++i) {
    struct formatInfo *format;

    if (i == baseFormat) {
      labelInfoColor = labelColor1;
    } else {
      labelInfoColor = labelColor0;
    }

    format = &baseFormats[i].format[baseFormats[i].current];
    for (j = 0; j < NUM_ENV_MODES; ++j) {
      struct envModeInfo *envMode;

      envMode = &envModes[j];
      drawSample(x, y, xSize, ySize, format, envMode);
      x += xOffset;
    }
    x = xBase;
    y -= yOffset;
  }

  if (doubleBuffered) {
    glutSwapBuffers();
  } else {
    glFlush();
  }

  checkErrors();
}
static void display( void )
{
   int		numX = 3, numY = 3;
   float	xBase = (float) winWidth * 0.01;
   float	xOffset = (winWidth - xBase) / numX;
   float	xSize = max( xOffset - xBase, 1 );
   float	yBase = (float) winHeight * 0.01;
   float	yOffset = (winHeight - yBase) / numY;
   float	ySize = max( yOffset - yBase, 1 );
   float	x, y;
   int		i, j;

   glViewport( 0, 0, winWidth, winHeight );
   glDisable( GL_SCISSOR_TEST );
   glClearColor( 0.0, 0.0, 0.0, 0.0 );
   glClear( GL_COLOR_BUFFER_BIT );
   glEnable( GL_SCISSOR_TEST );

   x = xBase;
   y = (winHeight - 1) - yOffset;

   for ( i = 0 ; i < numY ; i++ )
   {

      labelInfoColor = labelColor1;


      for ( j = 0 ; j < numX ; j++ ) {
	 drawSample( x, y, xSize, ySize, i, j+2 );
	 x += xOffset;
      }

      x = xBase;
      y -= yOffset;
   }

   if ( doubleBuffered ) {
      glutSwapBuffers();
   } else {
      glFlush();
   }

   checkErrors();
}
Exemple #8
0
void GLLUTWidget::sampleImage(const RawImage & img) {
  //compute slice it sits on:
  ColorFormat source_format=img.getColorFormat();
  
  int n=img.getNumPixels();
  
  yuv color;
  int i=0;
  
  if (img.getWidth() > 1 && img.getHeight() > 1) {
    if (source_format==COLOR_RGB8) {
      rgbImage rgb_img(img);
      rgb * color_rgb=rgb_img.getPixelData();
      for (int j=0;j<n;j++) {
        color=Conversions::rgb2yuv(*color_rgb);
        i=_lut->norm2lutX(color.y);
        if (i >= 0 && i < (int)slices.size()) {
          drawSample(i,_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v));
          //slices[i]->sampler->surface.setPixel(_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v),rgba(255,255,255,255));
          slices[i]->sampler_update_pending=true;
        }
        color_rgb++;
      }
    } else if (source_format==COLOR_YUV444) {    
      yuvImage yuv_img(img);
      yuv * color_yuv=yuv_img.getPixelData();
      for (int j=0;j<n;j++) {
        color=(*color_yuv);
        i=_lut->norm2lutX(color.y);
        if (i >= 0 && i < (int)slices.size()) {
          //slices[i]->sampler->surface.setPixel(_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v),rgba(255,255,255,255));
          drawSample(i,_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v));
          slices[i]->sampler_update_pending=true;
        }
        color_yuv++;
      }
    } else if (source_format==COLOR_YUV422_UYVY) {
        uyvy * color_uyvy = (uyvy*)img.getData();
        uyvy color_uyvy_tmp;
        for (int j=0;j<n;j+=2) {
          color_uyvy_tmp=(*color_uyvy);
          color.u=color_uyvy_tmp.u;
          color.v=color_uyvy_tmp.v;
  
          color.y=color_uyvy_tmp.y1;
          i=_lut->norm2lutX(color.y);
          if (i >= 0 && i < (int)slices.size()) {
            //slices[i]->sampler->surface.setPixel(_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v),rgba(255,255,255,255));
            drawSample(i,_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v));
            slices[i]->sampler_update_pending=true;
          }
  
          color.y=color_uyvy_tmp.y2;
          i=_lut->norm2lutX(color.y);
          if (i >= 0 && i < (int)slices.size()) {
            //slices[i]->sampler->surface.setPixel(_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v),rgba(255,255,255,255));
            drawSample(i,_lut->norm2lutY(color.u),_lut->norm2lutZ(color.v));
            slices[i]->sampler_update_pending=true;
          }
          color_uyvy++;
        }
    } else {
      fprintf(stderr,"Unable to sample colors from frame of format: %s\n",Colors::colorFormatToString(source_format).c_str());
      fprintf(stderr,"Currently supported are rgb8, yuv444, and yuv422 (UYVY).\n");
      fprintf(stderr,"(Feel free to add more conversions to glLUTwidget.cpp).\n");
    }
   }
  redraw();

}
void compareDataCard(
		     TString channel="muTau",
		     TString year="2011",
		     TString Group1="CERN",
		     TString Path1="/afs/cern.ch/user/b/benitezj/public/datacards/2011/Aug4",
		     TString File1="muTauSM_svfitmass",
		     TString Group2="Saclay",
		     TString Path2="/afs/cern.ch/user/b/bianchi/public/Roger/datacards2011v3",
		     TString File2="muTauSM"
		     ){

  TFile F1(Path1+"/"+File1+".root","read");
  TFile F2(Path2+"/"+File2+".root","read");
  
  F1.ls();
  F2.ls();

  TString fname="Diff_"+channel+"_"+year+"_"+Group1+"_"+Group2;
  TCanvas C(fname);
  
  C.Print(TString(C.GetName())+".pdf[");
  
  //cout<<" | 0jet_low Data | 0jet_low ZTT | 0jet_low W | 0jet_low QCD | 0jet_low TT | 0jet_low  ggH | 0jet_low  qqH | Boosted_high Data | Boosted_high ZTT | Boosted_high W | Boosted_high QCD | Boosted_high TT | Boosted_high ggH | Boosted_high qqH | VBF Data| VBF ZTT | VBF W | VBF QCD | VBF TT | VBF qqH | VBF ggH |"<<endl;


//   drawCategory(&C,Group1,&F1,Group2,&F2,channel,"0jet_low",1);
//   drawCategory(&C,Group1,&F1,Group2,&F2,channel,"0jet_high",0);
//   drawCategory(&C,Group1,&F1,Group2,&F2,channel,"boost_low",0);
//   drawCategory(&C,Group1,&F1,Group2,&F2,channel,"boost_high",1);
//   drawCategory(&C,Group1,&F1,Group2,&F2,channel,"vbf",1);



  drawSample(&C,Group1,&F1,Group2,&F2,channel,"data_obs",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"ZTT",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"W",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"QCD",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"TT",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"ZL",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"ZJ",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"ZLL",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"VV",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"ggH125",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"qqH125",0);
  drawSample(&C,Group1,&F1,Group2,&F2,channel,"VH125",0);


//   drawSignalDiff(&C,Group1,&F1,Group2,&F2,channel,"boost_high","ggH");
//   drawSignalDiff(&C,Group1,&F1,Group2,&F2,channel,"boost_high","qqH");
//   drawSignalDiff(&C,Group1,&F1,Group2,&F2,channel,"boost_high","VH");

//   drawSignalDiff(&C,Group1,&F1,Group2,&F2,channel,"vbf","ggH");
//   drawSignalDiff(&C,Group1,&F1,Group2,&F2,channel,"vbf","qqH");
//   drawSignalDiff(&C,Group1,&F1,Group2,&F2,channel,"vbf","VH");

  //drawSample(&C,Group1,&F1,Group2,&F2,channel,"ZTT_CMS_scale_t_mutau_8TeVUp",0);
  //drawSample(&C,Group1,&F1,Group2,&F2,channel,"ZTT_CMS_scale_t_mutau_8TeVDown",0);


  C.Print(TString(C.GetName())+".pdf]");
  
  //cout<<"|"<<endl;

//   gROOT->ProcessLine(".q");
}
Exemple #10
0
void EEGPlot::dataReceived(const CentData::AnalogData& data)
{
	drawSample(data);
}