当前位置: 首页>>代码示例>>C++>>正文


C++ Sample::GetImage方法代码示例

本文整理汇总了C++中Sample::GetImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Sample::GetImage方法的具体用法?C++ Sample::GetImage怎么用?C++ Sample::GetImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sample的用法示例。


在下文中一共展示了Sample::GetImage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateFeatureVector

void HistogramFeatures::UpdateFeatureVector(const Sample& s)
{
	//IntRect rect = s.GetROI(); // note this truncates to integers
	//cv::Rect roi(rect.XMin(), rect.YMin(), rect.Width(), rect.Height());
	//cv::resize(s.GetImage().GetImage(0)(roi), m_patchImage, m_patchImage.size());
	
	m_featVec.setZero();
	VectorXd hist(kNumBins);
	
	int histind = 0;
	for (int il = 0; il < kNumLevels; ++il)
	{
		int nc = il+1;
		float w = s.GetROI().Width()/nc;
		float h = s.GetROI().Height()/nc;
		FloatRect cell(0.f, 0.f, w, h);
		for (int iy = 0; iy < nc; ++iy)
		{
			cell.SetYMin(s.GetROI().YMin()+iy*h);
			for (int ix = 0; ix < nc; ++ix)
			{
				cell.SetXMin(s.GetROI().XMin()+ix*w);
				s.GetImage().Hist(cell, hist);
				m_featVec.segment(histind*kNumBins, kNumBins) = hist;
				++histind;
			}
		}
	}
	m_featVec /= histind;
}
开发者ID:CuriosityCreations,项目名称:vivaTracker,代码行数:30,代码来源:HistogramFeatures.cpp

示例2: UpdateFeatureVector

void HsvFeatures::UpdateFeatureVector(const Sample &s)
{
    IntRect rect = s.GetROI();
    cv::Rect roi(rect.XMin(), rect.YMin(), rect.Width(), rect.Height());

    m_featVec.setZero();
    cv::Mat hsv_img = s.GetImage().GetHsvImage()(roi);

    int height = rect.Height();
    int width = rect.Width();

    // continuous?
    if(hsv_img.isContinuous())
    {
        width *= height;
        height = 1;
    }

    int ix, iy;
    uchar *p;
    for(iy=0; iy < height; ++iy)
    {
        p = hsv_img.ptr<uchar>(iy);

        for(ix=0; ix < width; ++ix)
        {
            cv::Vec3b pixel(p[3*ix+0], p[3*ix+1], p[3*ix+2]);
            auto bin_idx = compBinIdx(pixel);
            m_featVec[bin_idx]++;
        }
    }

    m_featVec /= rect.Area();

}
开发者ID:duxiaofei283,项目名称:struck-1,代码行数:35,代码来源:HsvFeatures.cpp

示例3: Eval

float HaarFeature::Eval(const Sample& s) const {
    const ImageRep& image = s.GetImage();
    const FloatRect& roi = s.GetROI();
    float value = 0.f;

    for (int i = 0; i < (int)m_rects.size(); ++i) {
        const FloatRect& r = m_rects[i];
        IntRect sampleRect((int)(roi.XMin() + r.XMin()*roi.Width() + 0.5f), (int)(roi.YMin() + r.YMin()*roi.Height() + 0.5f),
                           (int)(r.Width()*roi.Width()), (int)(r.Height()*roi.Height()));
        value += m_weights[i] * image.Sum(sampleRect);
    }

    return value / (m_factor * roi.Area() * m_bb.Area());
}
开发者ID:tracedev,项目名称:STRUCK,代码行数:14,代码来源:HaarFeature.cpp

示例4: UpdateFeatureVector

void RawFeatures::UpdateFeatureVector(const Sample& s)
{
	IntRect rect = s.GetROI(); // note this truncates to integers
	cv::Rect roi(rect.XMin(), rect.YMin(), rect.Width(), rect.Height());
	cv::resize(s.GetImage().GetImage(0)(roi), m_patchImage, m_patchImage.size());
	//equalizeHist(m_patchImage, m_patchImage);
	
	int ind = 0;
	for (int i = 0; i < kPatchSize; ++i)
	{
		uchar* pixel = m_patchImage.ptr(i);
		for (int j = 0; j < kPatchSize; ++j, ++pixel, ++ind)
		{
			m_featVec[ind] = ((double)*pixel)/255;
		}
	}
}
开发者ID:Barbakas,项目名称:VOTR,代码行数:17,代码来源:RawFeatures.cpp

示例5: Eval

float SingFeature::Eval(const Sample& s) const
{

	const ImageSto& image = s.GetImage();
	const FtRec& roi = s.GetROI();
	float value = 0.f;

	for (int i = 0; i < (int)o_rects.size(); ++i)
	{
      
		const FtRec& r = o_rects[i];
		ItRec sampleRect((int)(roi.XMin()+r.XMin()*roi.Width()+0.5f), (int)(roi.YMin()+r.YMin()*roi.Height()+0.5f),
			(int)(r.Width()*roi.Width()), (int)(r.Height()*roi.Height()));
		value += o_weights[i]*image.Sum(sampleRect);
	}

	return value / (o_factor*roi.Area()*o_bb.Area());
}
开发者ID:kinjad,项目名称:cogito_petuum,代码行数:18,代码来源:SingFeature.cpp

示例6: MFEval

float MFEval(const Sample& s, petuum::Table<float>& Fec_table, int ind) 
{
  //Get table  
  petuum::RowAccessor fec_acc;
  Fec_table.Get(ind, &fec_acc);
  const petuum::DenseRow<float>& ref_fec = fec_acc.Get<petuum::DenseRow<float> >();
  const ImageSto& image = s.GetImage();
  const FtRec& roi = s.GetROI();
  float mf_factor = 0;
  float value = 0.f;
  switch((int)ref_fec[0])
    {
    case 0:
      {
        ItRec sampleRect_1((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]*roi.Width()), (int)(ref_fec[4]/2*roi.Height()));
        value += 1.f*image.Sum(sampleRect_1);

        ItRec sampleRect_2((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+(ref_fec[2]+ref_fec[4]/2)*roi.Height()+0.5f),
                             (int)(ref_fec[3]*roi.Width()), (int)(ref_fec[4]/2*roi.Height()));
        value += -1.f*image.Sum(sampleRect_2);
        mf_factor = 255*1.f/2;
        break;
      }
    case 1:
      {
        ItRec sampleRect_1((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]/2*roi.Width()), (int)(ref_fec[4]*roi.Height()));
        value += 1.f*image.Sum(sampleRect_1);

        ItRec sampleRect_2((int)(roi.XMin()+(ref_fec[1]+ref_fec[3]/2)*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]/2*roi.Width()), (int)(ref_fec[4]*roi.Height()));
        value += -1.f*image.Sum(sampleRect_2);
        mf_factor = 255*1.f/2;
        break;
      }
    case 2:
      {
        ItRec sampleRect_1((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]/3*roi.Width()), (int)(ref_fec[4]*roi.Height()));
        value += 1.f*image.Sum(sampleRect_1);

        ItRec sampleRect_2((int)(roi.XMin()+(ref_fec[1]+ref_fec[3]/3)*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]/3*roi.Width()), (int)(ref_fec[4]*roi.Height()));
        value += -2.f*image.Sum(sampleRect_2);

        ItRec sampleRect_3((int)(roi.XMin()+(ref_fec[1]+2*ref_fec[3]/3)*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]/3*roi.Width()), (int)(ref_fec[4]*roi.Height()));
        value += 1.f*image.Sum(sampleRect_3);


        mf_factor = 255*2.f/3;
        break;
      }
    case 3:
      {
        ItRec sampleRect_1((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]*roi.Width()), (int)(ref_fec[4]/3*roi.Height()));
        value += 1.f*image.Sum(sampleRect_1);

        ItRec sampleRect_2((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+(ref_fec[2]+ref_fec[4]/3)*roi.Height()+0.5f),
                             (int)(ref_fec[3]*roi.Width()), (int)(ref_fec[4]/3*roi.Height()));
        value += -2.f*image.Sum(sampleRect_2);

        ItRec sampleRect_3((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+(ref_fec[2]+2*ref_fec[4]/3)*roi.Height()+0.5f),
                             (int)(ref_fec[3]*roi.Width()), (int)(ref_fec[4]/3*roi.Height()));
        value += 1.f*image.Sum(sampleRect_3);
        mf_factor = 255*2.f/3;
        break;
      }
    case 4:
      {
        ItRec sampleRect_1((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]/2*roi.Width()), (int)(ref_fec[4]/2*roi.Height()));
        value += 1.f*image.Sum(sampleRect_1);

        ItRec sampleRect_2((int)(roi.XMin()+(ref_fec[1]+ref_fec[3]/2)*roi.Width()+0.5f), (int)(roi.YMin()+(ref_fec[2]+ref_fec[4]/2)*roi.Height()+0.5f),
                             (int)(ref_fec[3]/2*roi.Width()), (int)(ref_fec[4]/2*roi.Height()));
        value += 1.f*image.Sum(sampleRect_2);

        ItRec sampleRect_3((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+(ref_fec[2]+ref_fec[4]/2)*roi.Height()+0.5f),
                             (int)(ref_fec[3]/2*roi.Width()), (int)(ref_fec[4]/2*roi.Height()));
        value += -1.f*image.Sum(sampleRect_3);

        ItRec sampleRect_4((int)(roi.XMin()+(ref_fec[1]+ref_fec[3]/2)*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]/2*roi.Width()), (int)(ref_fec[4]/2*roi.Height()));
          
        value += -1.f*image.Sum(sampleRect_4);
        mf_factor = 255*1.f/2;
        break;
      }

    case 5:
      {
        ItRec sampleRect_1((int)(roi.XMin()+ref_fec[1]*roi.Width()+0.5f), (int)(roi.YMin()+ref_fec[2]*roi.Height()+0.5f),
                             (int)(ref_fec[3]*roi.Width()), (int)(ref_fec[4]*roi.Height()));
        value += 1.f*image.Sum(sampleRect_1);

        ItRec sampleRect_2((int)(roi.XMin()+(ref_fec[1]+ref_fec[3]/4)*roi.Width()+0.5f), (int)(roi.YMin()+(ref_fec[2]+ref_fec[4]/4)*roi.Height()+0.5f),
                             (int)(ref_fec[3]/2*roi.Width()), (int)(ref_fec[4]/2*roi.Height()));
//.........这里部分代码省略.........
开发者ID:kinjad,项目名称:cogito_petuum,代码行数:101,代码来源:MFeatures.cpp


注:本文中的Sample::GetImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。