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


C++ vector::push_back方法代码示例

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


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

示例1: load

inline void load(
    Archive & ar,
    STD::vector<bool, Allocator> &t,
    const unsigned int /* file_version */
){
    // retrieve number of elements
    unsigned int count;
    ar >> BOOST_SERIALIZATION_NVP(count);
    t.clear();
    while(count-- > 0){
        bool i;
        ar >> boost::serialization::make_nvp("item", i);
        t.push_back(i);
    }
}
开发者ID:Albermg7,项目名称:boost,代码行数:15,代码来源:vector.hpp

示例2: DoItem

 virtual bool DoItem(Item &Itm,int &Fd) override {
     Fd = -1;
     files.push_back(Itm.Name);
     return true;
 }
开发者ID:DimStar77,项目名称:PackageKit,代码行数:5,代码来源:deb-file.cpp

示例3: main

int main()
{
  labels.push_back("LLT");
  labels.push_back("LDLT");
  labels.push_back("PartialPivLU");
  labels.push_back("FullPivLU");
  labels.push_back("HouseholderQR");
  labels.push_back("ColPivHouseholderQR");
  labels.push_back("CompleteOrthogonalDecomposition");
  labels.push_back("FullPivHouseholderQR");
  labels.push_back("JacobiSVD");
  labels.push_back("BDCSVD");

  for(int i=0; i<labels.size(); ++i)
    results[labels[i]].fill(-1);

  const int small = 8;
  sizes.push_back(Array2i(small,small));
  sizes.push_back(Array2i(100,100));
  sizes.push_back(Array2i(1000,1000));
  sizes.push_back(Array2i(4000,4000));
  sizes.push_back(Array2i(10000,small));
  sizes.push_back(Array2i(10000,100));
  sizes.push_back(Array2i(10000,1000));
  sizes.push_back(Array2i(10000,4000));

  using namespace std;

  for(int k=0; k<sizes.size(); ++k)
  {
    cout << sizes[k](0) << "x" << sizes[k](1) << "...\n";
    bench<float,Dynamic>(k,sizes[k](0),sizes[k](1));
  }

  cout.width(32);
  cout << "solver/size";
  cout << "  ";
  for(int k=0; k<sizes.size(); ++k)
  {
    std::stringstream ss;
    ss << sizes[k](0) << "x" << sizes[k](1);
    cout.width(10); cout << ss.str(); cout << " ";
  }
  cout << endl;


  for(int i=0; i<labels.size(); ++i)
  {
    cout.width(32); cout << labels[i]; cout << "  ";
    ArrayXf r = (results[labels[i]]*100000.f).floor()/100.f;
    for(int k=0; k<sizes.size(); ++k)
    {
      cout.width(10);
      if(r(k)>=1e6)  cout << "-";
      else           cout << r(k);
      cout << " ";
    }
    cout << endl;
  }

  // HTML output
  cout << "<table class=\"manual\">" << endl;
  cout << "<tr><th>solver/size</th>" << endl;
  for(int k=0; k<sizes.size(); ++k)
    cout << "  <th>" << sizes[k](0) << "x" << sizes[k](1) << "</th>";
  cout << "</tr>" << endl;
  for(int i=0; i<labels.size(); ++i)
  {
    cout << "<tr";
    if(i%2==1) cout << " class=\"alt\"";
    cout << "><td>" << labels[i] << "</td>";
    ArrayXf r = (results[labels[i]]*100000.f).floor()/100.f;
    for(int k=0; k<sizes.size(); ++k)
    {
      if(r(k)>=1e6) cout << "<td>-</td>";
      else
      {
        cout << "<td>" << r(k);
        if(i>0)
          cout << " (x" << numext::round(10.f*results[labels[i]](k)/results["LLT"](k))/10.f << ")";
        if(i<4 && sizes[k](0)!=sizes[k](1))
          cout << " <sup><a href=\"#note_ls\">*</a></sup>";
        cout << "</td>";
      }
    }
    cout << "</tr>" << endl;
  }
  cout << "</table>" << endl;

//   cout << "LLT                             (ms)  " << (results["LLT"]*1000.).format(fmt) << "\n";
//   cout << "LDLT                             (%)  " << (results["LDLT"]/results["LLT"]).format(fmt) << "\n";
//   cout << "PartialPivLU                     (%)  " << (results["PartialPivLU"]/results["LLT"]).format(fmt) << "\n";
//   cout << "FullPivLU                        (%)  " << (results["FullPivLU"]/results["LLT"]).format(fmt) << "\n";
//   cout << "HouseholderQR                    (%)  " << (results["HouseholderQR"]/results["LLT"]).format(fmt) << "\n";
//   cout << "ColPivHouseholderQR              (%)  " << (results["ColPivHouseholderQR"]/results["LLT"]).format(fmt) << "\n";
//   cout << "CompleteOrthogonalDecomposition  (%)  " << (results["CompleteOrthogonalDecomposition"]/results["LLT"]).format(fmt) << "\n";
//   cout << "FullPivHouseholderQR             (%)  " << (results["FullPivHouseholderQR"]/results["LLT"]).format(fmt) << "\n";
//   cout << "JacobiSVD                        (%)  " << (results["JacobiSVD"]/results["LLT"]).format(fmt) << "\n";
//   cout << "BDCSVD                           (%)  " << (results["BDCSVD"]/results["LLT"]).format(fmt) << "\n";
}
开发者ID:13221325403,项目名称:openbr,代码行数:100,代码来源:dense_solvers.cpp

示例4: findIllegalEdge

void ReTriangulation::findIllegalEdge(std::vector<Vec3f>* point, std::vector<int>& pointOnEdge, std::vector<int>& pointOnFace, std::vector<Vec2i>& illegalEdge)
{
	Vec3f v1=(*point)[pointOnEdge[1]]-(*point)[pointOnEdge[0]]; v1.normalize();
	std::vector<float> dis;
	std::vector<int> pointOrder;
	for(int i=0;i<pointOnFace.size();i++)
	{
		float a=v1*((*point)[pointOnFace[i]]-(*point)[pointOnEdge[0]]);
		dis.push_back(a);
	}

	if(pointOnFace.size()==1)
	{
		illegalEdge.push_back(Vec2i(pointOnEdge[0], pointOnEdge[1]));
		return;
	}
	if(pointOnFace.size()==2)
	{
		pointOrder.resize(4);
		pointOrder[0]=pointOnEdge[0];
		if(dis[0]>dis[1])
		{
			pointOrder[1]=pointOnFace[1];
			pointOrder[2]=pointOnFace[0];
		}
		else
		{
			pointOrder[1]=pointOnFace[0];
			pointOrder[2]=pointOnFace[1];
		}
		pointOrder[3]=pointOnEdge[1];

		illegalEdge.push_back(Vec2i(pointOrder[0],pointOrder[3]));
		illegalEdge.push_back(Vec2i(pointOrder[0],pointOrder[2]));
		illegalEdge.push_back(Vec2i(pointOrder[1],pointOrder[3]));
		return;
	}
	if(pointOnFace.size()==3)
	{
		pointOrder.resize(5);
		pointOrder[0]=pointOnEdge[0];
		if(dis[0]<dis[1])
		{
			if(dis[0]<dis[2])
			{
				if(dis[1]<dis[2])
				{
					pointOrder[1]=pointOnFace[0];
					pointOrder[2]=pointOnFace[1];
					pointOrder[3]=pointOnFace[2];
				}
				else
				{
					pointOrder[1]=pointOnFace[0];
					pointOrder[2]=pointOnFace[2];
					pointOrder[3]=pointOnFace[1];
				}	
			}
			else
			{
				pointOrder[1]=pointOnFace[2];
				pointOrder[2]=pointOnFace[0];
				pointOrder[3]=pointOnFace[1];
			}
		}
		else
		{
			if(dis[0]<dis[2])
			{
				pointOrder[1]=pointOnFace[1];
				pointOrder[2]=pointOnFace[0];
				pointOrder[3]=pointOnFace[2];
			}
			else
			{
				if(dis[1]<dis[2])
				{
					pointOrder[1]=pointOnFace[1];
					pointOrder[2]=pointOnFace[2];
					pointOrder[3]=pointOnFace[0];
				}
				else
				{
					pointOrder[1]=pointOnFace[2];
					pointOrder[2]=pointOnFace[1];
					pointOrder[3]=pointOnFace[0];
				}	
			}
		}
		pointOrder[4]=pointOnEdge[1];

		illegalEdge.push_back(Vec2i(pointOrder[0],pointOrder[4]));
		illegalEdge.push_back(Vec2i(pointOrder[0],pointOrder[3]));
		illegalEdge.push_back(Vec2i(pointOrder[1],pointOrder[4]));
		illegalEdge.push_back(Vec2i(pointOrder[0],pointOrder[2]));
		illegalEdge.push_back(Vec2i(pointOrder[1],pointOrder[3]));
		illegalEdge.push_back(Vec2i(pointOrder[2],pointOrder[4]));
	}
}
开发者ID:pigoblock,项目名称:TFYP,代码行数:99,代码来源:ReTriangulation.cpp

示例5: addChild

void AlnusPhyolgeticBranch::addChild(AlnusPhyolgeticBranch *child)
{
    mChildren.push_back(child);
}
开发者ID:goshng,项目名称:cocoa,代码行数:4,代码来源:main-string.cpp

示例6: ICPFindCorrespondance

    void Registration::ICPFindCorrespondance(const Point3DSet* pRef, const Point3DSet* pOrigin, const MagicMath::HomoMatrix4* pTransInit,
            std::vector<int>& sampleIndex,  std::vector<int>& correspondIndex)
    {
        //DebugLog << "Registration::ICPFindCorrespondance" << std::endl;
        //float timeStart = MagicCore::ToolKit::GetTime();
        /*int dim = 3;
        int refNum = pRef->GetPointNumber();
        float* dataSet = new float[refNum * dim];
        for (int i = 0; i < refNum; i++)
        {
            MagicMath::Vector3 pos = pRef->GetPoint(i)->GetPosition();
            dataSet[dim * i + 0] = pos[0];
            dataSet[dim * i + 1] = pos[1];
            dataSet[dim * i + 2] = pos[2];
        }*/
        
        /*FLANNParameters searchPara;
        searchPara = DEFAULT_FLANN_PARAMETERS;
        searchPara.algorithm = FLANN_INDEX_KDTREE;
        searchPara.trees = 8;
        searchPara.log_level = FLANN_LOG_INFO;
	    searchPara.checks = 64;
        float speedup;
        flann_index_t indexId = flann_build_index(dataSet, refNum, dim, &speedup, &searchPara);
        DebugLog << "        Flann: " << MagicCore::ToolKit::GetTime() - timeStart << std::endl;*/
        int nn = 1;
        int dim = 3;
        int searchNum = sampleIndex.size();
        float* searchSet = new float[searchNum * dim];
        for (int i = 0; i < searchNum; i++)
        {
            MagicMath::Vector3 pos = pTransInit->TransformPoint( pOrigin->GetPoint(sampleIndex.at(i))->GetPosition() );
            searchSet[dim * i + 0] = pos[0];
            searchSet[dim * i + 1] = pos[1];
            searchSet[dim * i + 2] = pos[2];
        }
        int* pIndex = new int[searchNum * nn];
        float* pDist = new float[searchNum * nn];
        flann_find_nearest_neighbors_index(mFlannIndex, searchSet, searchNum, pIndex, pDist, nn, &mSearchPara);
        //flann_free_index(indexId, &searchPara);
        //delete []dataSet;
        delete []searchSet;
        

        //delete wrong correspondance
        float distThre = 500.f;
        float norThre = 0.1f; //cos(85);
        std::vector<int> sampleIndexBak = sampleIndex;
        sampleIndex.clear();
        correspondIndex.clear();
        for (int i = 0; i < searchNum; i++)
        {
            if (pDist[i] > distThre)
            {
        //        DebugLog << "Large dist: " << pDist[i] << std::endl;
                continue;
            }
            float norDist = pRef->GetPoint(pIndex[i])->GetNormal() * (pTransInit->RotateVector( pOrigin->GetPoint(sampleIndexBak.at(i))->GetNormal() ));
            if (norDist < norThre || norDist > 1.0)
            {
         //       DebugLog << "Large Nor: " << norDist << std::endl;
                continue;
            }
            sampleIndex.push_back(sampleIndexBak.at(i));
            correspondIndex.push_back(pIndex[i]);
        }
        //DebugLog << "Sample Number: " << sampleIndex.size() << std::endl;
        delete []pIndex;
        delete []pDist;
    }
开发者ID:jinghuaguo,项目名称:magic3d,代码行数:70,代码来源:Registration.cpp

示例7: parseCommandLine

/**
 * Split shell command line into a list of arguments. Aims to emulate \c bash and friends.
 *
 * - Arguments are delimited with whitespace
 * - Extra whitespace at the beginning and end and between arguments will be ignored
 * - Text can be "double" or 'single' quoted
 * - The backslash \c \ is used as escape character
 *   - Outside quotes, any character can be escaped
 *   - Within double quotes, only escape \c " and backslashes before a \c " or another backslash
 *   - Within single quotes, no escaping is possible and no special interpretation takes place
 *
 * @param[out]   args        Parsed arguments will be appended to this list
 * @param[in]    strCommand  Command line to split
 */
bool parseCommandLine(std::vector<std::string> &args, const std::string &strCommand)
{
    enum CmdParseState
    {
        STATE_EATING_SPACES,
        STATE_ARGUMENT,
        STATE_SINGLEQUOTED,
        STATE_DOUBLEQUOTED,
        STATE_ESCAPE_OUTER,
        STATE_ESCAPE_DOUBLEQUOTED
    } state = STATE_EATING_SPACES;
    std::string curarg;
    foreach(char ch, strCommand)
    {
        switch(state)
        {
        case STATE_ARGUMENT: // In or after argument
        case STATE_EATING_SPACES: // Handle runs of whitespace
            switch(ch)
            {
            case '"': state = STATE_DOUBLEQUOTED; break;
            case '\'': state = STATE_SINGLEQUOTED; break;
            case '\\': state = STATE_ESCAPE_OUTER; break;
            case ' ': case '\n': case '\t':
                if(state == STATE_ARGUMENT) // Space ends argument
                {
                    args.push_back(curarg);
                    curarg.clear();
                }
                state = STATE_EATING_SPACES;
                break;
            default: curarg += ch; state = STATE_ARGUMENT;
            }
            break;
        case STATE_SINGLEQUOTED: // Single-quoted string
            switch(ch)
            {
            case '\'': state = STATE_ARGUMENT; break;
            default: curarg += ch;
            }
            break;
        case STATE_DOUBLEQUOTED: // Double-quoted string
            switch(ch)
            {
            case '"': state = STATE_ARGUMENT; break;
            case '\\': state = STATE_ESCAPE_DOUBLEQUOTED; break;
            default: curarg += ch;
            }
            break;
        case STATE_ESCAPE_OUTER: // '\' outside quotes
            curarg += ch; state = STATE_ARGUMENT;
            break;
        case STATE_ESCAPE_DOUBLEQUOTED: // '\' in double-quoted text
            if(ch != '"' && ch != '\\') curarg += '\\'; // keep '\' for everything but the quote and '\' itself
            curarg += ch; state = STATE_DOUBLEQUOTED;
            break;
        }
    }
    switch(state) // final state
    {
    case STATE_EATING_SPACES:
        return true;
    case STATE_ARGUMENT:
        args.push_back(curarg);
        return true;
    default: // ERROR to end in one of the other states
        return false;
    }
}
开发者ID:AuroracoinDev,项目名称:Auroracoin-core,代码行数:83,代码来源:rpcconsole.cpp

示例8: TestForExistingItem

/**
 * Function TestForExistingItem
 * test if aItem exists somewhere in lists of items
 * This is a function used by PutDataInPreviousState to be sure an item was not deleted
 * since an undo or redo.
 * This could be possible:
 *   - if a call to SaveCopyInUndoList was forgotten in Pcbnew
 *   - in zones outlines, when a change in one zone merges this zone with an other
 * This function avoids a Pcbnew crash
 * Before using this function to test existence of items,
 * it must be called with aItem = NULL to prepare the list
 * @param aPcb = board to test
 * @param aItem = item to find
 *              = NULL to build the list of existing items
 */
static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
{
    static std::vector<BOARD_ITEM*> itemsList;

    if( aItem == NULL ) // Build list
    {
        // Count items to store in itemsList:
        int icnt = 0;
        BOARD_ITEM* item;

        // Count tracks:
        for( item = aPcb->m_Track; item != NULL; item = item->Next() )
            icnt++;

        // Count modules:
        for( item = aPcb->m_Modules; item != NULL; item = item->Next() )
            icnt++;

        // Count drawings
        for( item = aPcb->m_Drawings; item != NULL; item = item->Next() )
            icnt++;

        // Count zones outlines
        icnt +=  aPcb->GetAreaCount();

        // Count zones segm (now obsolete):
        for( item = aPcb->m_Zone; item != NULL; item = item->Next() )
             icnt++;

        // Build candidate list:
        itemsList.clear();
        itemsList.reserve(icnt);

        // Store items in list:
        // Append tracks:
        for( item = aPcb->m_Track; item != NULL; item = item->Next() )
            itemsList.push_back( item );

        // Append modules:
        for( item = aPcb->m_Modules; item != NULL; item = item->Next() )
            itemsList.push_back( item );

        // Append drawings
        for( item = aPcb->m_Drawings; item != NULL; item = item->Next() )
            itemsList.push_back( item );

        // Append zones outlines
        for( int ii = 0; ii < aPcb->GetAreaCount(); ii++ )
            itemsList.push_back( aPcb->GetArea( ii ) );

        // Append zones segm:
        for( item = aPcb->m_Zone; item != NULL; item = item->Next() )
            itemsList.push_back( item );

        // Sort list
        std::sort( itemsList.begin(), itemsList.end() );
        return false;
    }

    // search in list:
    return std::binary_search( itemsList.begin(), itemsList.end(), aItem );
}
开发者ID:BTR1,项目名称:kicad-source-mirror,代码行数:77,代码来源:board_undo_redo.cpp

示例9: extractNegPatches

void extractNegPatches(std::vector<CNegDataset> &negSet,
                       std::vector<CNegPatch> &negPatch,
                       CConfig conf){
    cv::Rect tempRect;

    std::vector<CNegPatch> tNegPatch(0);//, posPatch(0);
    nCk nck;
    int negPatchNum;

    negPatch.clear();

    tempRect.width  = conf.p_width;
    tempRect.height = conf.p_height;

    // extract negative patch
    std::cout << negSet.size() << std::endl;
    std::cout << negSet.at(0).img.at(0)->cols << std::endl;
    std::cout << negSet.at(0).img.at(0)->rows << std::endl;
    for(int i = 0; i < negSet.size(); ++i){
        for(int j = 0; j < negSet.at(i).img.at(0)->cols - conf.p_width; j += conf.stride){
            for(int k = 0; k < negSet.at(i).img.at(0)->rows - conf.p_height; k += conf.stride){

                tempRect.x = j;
                tempRect.y = k;
                int pix = 0;

                // detect negative patch
//                if(conf.learningMode != 2 && negSet.at(i).img.at(1)->at<ushort>(k + (conf.p_height / 2) + 1, j + (conf.p_width / 2) + 1 ) != 0){
//                    cv::Mat roi;
//                    roi = (*negSet.at(i).img.at(1))(cv::Rect(j, k, conf.p_width, conf.p_height));
//                    pix = calcSumOfDepth(roi,conf);
//                }

                //tPatch.setPatch(temp, negImage.at(i));
                //if(conf.learningMode == 2 || pix > 0){
                    CNegPatch negTemp(&negSet.at(i),tempRect);
                    tNegPatch.push_back(negTemp);
                //}
            }//x
        }//y
    } // every image

    // choose negative patch randamly
    negPatchNum = conf.patchRatio * conf.pnRatio;
    //std::cout << "pos patch num : " << posPatch.size() << " neg patch num : " << negPatchNum << std::endl;

    if(negPatchNum < tNegPatch.size()){
        std::set<int> chosenPatch = nck.generate(tNegPatch.size(), negPatchNum);//totalPatchNum * conf.patchRatio);
        std::set<int>::iterator ite = chosenPatch.begin();

        while(ite != chosenPatch.end()){
            negPatch.push_back(tNegPatch.at(*ite));
            ite++;
        }
    }else{
        std::cout << "only " << tNegPatch.size() << " pathes extracted from negative images" << std::endl;
        std::cout << "can't extract enogh negative patch please set pnratio more low!" << std::endl;
        exit(-1);
    }

//    patches.push_back(posPatch);
//    patches.push_back(negPatch);
}
开发者ID:yoshimasa1700,项目名称:HFMD_evaluate,代码行数:63,代码来源:util.cpp

示例10: loadTrainPosFile

void loadTrainPosFile(CConfig conf, std::vector<CPosDataset> &posSet)
{
    std::string traindatafilepath = conf.trainpath + PATH_SEP +  conf.traindatafile;
    int n_folders;
    int n_files;
    std::vector<std::string> trainimagefolder;
    std::vector<CPosDataset> tempDataSet;
    std::string trainDataListPath;
    int dataSetNum;
    CClassDatabase database;
    cv::Point tempPoint;
    nCk nck;

    posSet.clear();

    //read train data folder list
    std::ifstream in(traindatafilepath.c_str());
    if(!in.is_open()){
        std::cout << "train data floder list is not found!" << std::endl;
        exit(1);
    }

    // read train pos folder
    in >> n_folders;
    std::cout << "number of training data folders : " << n_folders << std::endl;
    trainimagefolder.resize(n_folders);
    for(int i = 0;i < n_folders; ++i)
        in >> trainimagefolder.at(i);
    std::cout << trainimagefolder.at(0) << std::endl;

    // close train pos data folder list
    in.close();

    std::cout << "train folders lists : " << std::endl;
    //read train file name and grand truth from file
    tempDataSet.clear();
    for(int i = 0;i < n_folders; ++i){
        trainDataListPath
                = conf.trainpath + PATH_SEP + trainimagefolder.at(i) + PATH_SEP + conf.traindatalist;

        std::cout << trainDataListPath << std::endl;
        std::string imageFilePath
                = conf.trainpath + PATH_SEP + trainimagefolder.at(i) + PATH_SEP;

        std::ifstream trainDataList(trainDataListPath.c_str());
        if(!trainDataList.is_open()){
            std::cout << "can't read " << trainDataListPath << std::endl;
            exit(1);
        }

        trainDataList >> n_files;

        for(int j = 0;j < n_files; ++j){
            CPosDataset posTemp;
            std::string nameTemp;


            //            posTemp.angles.clear();
            //            posTemp.centerPoint.clear();

            //read file names
            trainDataList >> nameTemp;
            posTemp.setRgbImagePath(imageFilePath + nameTemp);
	    

            trainDataList >> nameTemp;
            posTemp.setDepthImagePath(imageFilePath + nameTemp);

            trainDataList >> nameTemp;// dummy

            //read class name
            std::string tempClassName;
            trainDataList >> tempClassName;
            //temp.className.push_back(tempClassName);
            posTemp.setClassName(tempClassName);

            // read image size
            cv::Mat tempImage = cv::imread(posTemp.getRgbImagePath(),3);
            cv::Size tempSize = cv::Size(tempImage.cols, tempImage.rows);

            // set center point
            tempPoint = cv::Point(tempImage.cols / 2, tempImage.rows / 2);
            posTemp.setCenterPoint(tempPoint);

            // registre class param to class database
            database.add(posTemp.getParam()->getClassName(), tempSize, 0);

            //read angle grand truth
            double tempAngle;
            trainDataList >> tempAngle;
            posTemp.setAngle(tempAngle);

            tempDataSet.push_back(posTemp);
        }

        trainDataList.close();
    }

    dataSetNum = tempDataSet.size();
    int dataOffset = 0;
//.........这里部分代码省略.........
开发者ID:yoshimasa1700,项目名称:HFMD_evaluate,代码行数:101,代码来源:util.cpp

示例11: extractPosPatches

// extract patch from images
// !!!!!!coution!!!!!!!
// this function is use for negatime mode!!!!!
void extractPosPatches(std::vector<CPosDataset> &posSet,
                       std::vector<CPosPatch> &posPatch,
                       CConfig conf,
                       const int treeNum,
                       const CClassDatabase &classDatabase){
    cv::Rect tempRect;

    std::vector<CPosPatch> tPosPatch(0);//, posPatch(0);
    std::vector<std::vector<CPosPatch> > patchPerClass(classDatabase.vNode.size());
    int pixNum;
    nCk nck;
    int classNum = 0;
    cv::Mat roi;

    posPatch.clear();

    tempRect.width  = conf.p_width;
    tempRect.height = conf.p_height;

    std::cout << "image num is " << posSet.size();

    std::cout << "extracting patch from image" << std::endl;
    for(int l = 0;l < posSet.size(); ++l){
        std::cout << posSet.at(l).getRgbImagePath() << std::endl;
//                    cv::namedWindow("test");
//                    cv::imshow("test", *posSet.at(l).img.at(0));
//                    cv::waitKey(0);
//                    cv::destroyWindow("test");
        for(int j = 0; j < posSet.at(l).img.at(0)->cols - conf.p_width; j += conf.stride){
            for(int k = 0; k < posSet.at(l).img.at(0)->rows - conf.p_height; k += conf.stride){
                tempRect.x = j;
                tempRect.y = k;
                pixNum = 0;
                int centerDepthFlag = 1;

                // detect negative patch
//                if(conf.learningMode != 2 && posSet.at(l).img.at(1)->at<ushort>(k + (conf.p_height / 2) + 1, j + (conf.p_width / 2) + 1 ) != 0){

//                    roi = (*posSet.at(l).img.at(1))(cv::Rect(j, k, conf.p_width, conf.p_height));
//                    pixNum = calcSumOfDepth(roi,conf);
//                }
//                    for(int m = j; m < j + conf.p_width; ++m){
//                        for(int n = k; n < k + conf.p_height; ++n){
//                            if(posSet.at(l).img.at(1)->at<ushort>(k + (conf.p_height / 2) + 1, j + (conf.p_width / 2) + 1 ) != 0)
//                                pixNum += (int)(posSet.at(l).img.at(1)->at<ushort>(n, m));
//                        }
//                    }

                // set patch class
                classNum = classDatabase.search(posSet.at(l).getParam()->getClassName());//dataSet.at(l).className.at(0));
                if(classNum == -1){
                    std::cout << "class not found!" << std::endl;
                    exit(-1);
                }

                //tPatch.setPatch(temp, image.at(l), dataSet.at(l), classNum);


                CPosPatch posTemp(&posSet.at(l),tempRect);
                //if (conf.learningMode == 2){// || pixNum > 0){
                    tPosPatch.push_back(posTemp);
                    patchPerClass.at(classNum).push_back(posTemp);

                //} // if
            }//x
        }//y
    }//allimages

    for(int w = 0; w < patchPerClass.size(); ++w){
        std::cout << patchPerClass.at(w).size() << " ";
    }
    std::cout << std::endl;

    std::vector<int> patchNum(patchPerClass.size(),conf.patchRatio);

    for(int i = 0; i < patchPerClass.size(); ++i){
        if(i == treeNum % patchPerClass.size())
            patchNum.at(i) = conf.patchRatio;
        else
            patchNum.at(i) = conf.patchRatio * conf.acPatchRatio;
    }

    for(int w = 0; w < patchPerClass.size(); ++w){
        std::cout << patchPerClass.at(w).size() << " ";
    }

    // choose patch from each image
    for(int i = 0; i < patchPerClass.size(); ++i){
        if(patchPerClass.at(i).size() > conf.patchRatio){

            std::set<int> chosenPatch = nck.generate(patchPerClass.at(i).size(),patchNum.at(i));// conf.patchRatio);//totalPatchNum * conf.patchRatio);
            std::set<int>::iterator ite = chosenPatch.begin();

            while(ite != chosenPatch.end()){
                //std::cout << "this is for debug ite is " << tPosPatch.at(*ite).center << std::endl;
                //std::cout <<posPatch.at(i)
                //std::cout << patchPerClass.at(i).at(*ite).getRgbImageFilePath() << std::endl;
//.........这里部分代码省略.........
开发者ID:yoshimasa1700,项目名称:HFMD_evaluate,代码行数:101,代码来源:util.cpp

示例12: exec

 static void exec(std::vector<unsigned> &v, std::vector<GLenum> &e)
 {
     v.push_back(createShadowSampler());
     e.push_back(GL_TEXTURE_2D_ARRAY);
     CreateSamplers<tp...>::exec(v, e);
 }
开发者ID:ChristophHaag,项目名称:stk-code,代码行数:6,代码来源:shaders_util.hpp

示例13: ShaderHelperSingleton

 ShaderHelperSingleton()
 {
     CleanTable.push_back(this->kill);
 }
开发者ID:ChristophHaag,项目名称:stk-code,代码行数:4,代码来源:shaders_util.hpp

示例14: AssignUniforms_impl

 void AssignUniforms_impl(const char* name, U... rest)
 {
     uniforms.push_back(glGetUniformLocation(Program, name));
     AssignUniforms_impl(rest...);
 }
开发者ID:ChristophHaag,项目名称:stk-code,代码行数:5,代码来源:shaders_util.hpp

示例15: getAttributes

void IfcConstructionProductResourceType::getAttributes( std::vector<std::pair<std::string, shared_ptr<IfcPPObject> > >& vec_attributes )
{
	IfcConstructionResourceType::getAttributes( vec_attributes );
	vec_attributes.push_back( std::make_pair( "PredefinedType", m_PredefinedType ) );
}
开发者ID:PanicSheep,项目名称:ifcplusplus,代码行数:5,代码来源:IfcConstructionProductResourceType.cpp


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