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


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

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


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

示例1: addTrainingSet

void TestObjectRecognition::addTrainingSet(cv::Mat &trainingData, cv::Mat &labels, int elemCount, int label,
                                           int offset) {
	for (int i = offset; i < elemCount + offset; i++) {
		trainingData.push_back(featureDetector->detectImageFeatures(i + 1, label));
		labels.push_back(label);
	}
}
开发者ID:stevespiss,项目名称:computervision_assignment3,代码行数:7,代码来源:TestObjectRecognition.cpp

示例2: bow_encode

//codification of the images with the BOW vocabulary
void bow_encode(const fs::path& basepath, cv::Mat& descriptors, cv::Mat& labels)
{
	int no_files = 0;
	std::string class_name = basepath.string();
	class_name.erase(class_name.begin(),class_name.end()-2);

	for(fs::directory_iterator iter(basepath), end; iter != end; ++iter)
	{
		fs::directory_entry entry = *iter;
		if(fs::is_directory(entry.path()))
		{
			std::cout << "Processing directory: " << entry.path().string() << std::endl;
			bow_encode(entry.path(),descriptors,labels);
		}
		else
		{
			fs::path entryPath = entry.path();
			if(entryPath.extension()==".jpg")
			{
			//	std::cout << "Processing file: " << entry.path().string() << std::endl;
				no_files++;
				cv::Mat img = cv::imread(entryPath.string(),CV_LOAD_IMAGE_COLOR);
				if(!img.empty())
				{
					std::vector<cv::KeyPoint> feature_keypoints;
					feature_detector.detect(img,feature_keypoints);
					if(feature_keypoints.empty())
					{
						std::cerr << "Could not find points in image: " << entryPath.string();
						std::cerr << std::endl;
					}
					else
					{

						cv::Mat bowDescriptor;
						bowDE.compute(img,feature_keypoints,bowDescriptor);
						descriptors.push_back(bowDescriptor);
						//std::cout << class_name.c_str() << std::endl;
						labels.push_back( float( atoi(class_name.c_str()) ) );
						feature_keypoints.clear();
						//std::cout << local_descriptors.rows << std::endl;	
						~bowDescriptor;

					}
				}
				else
				{
					std::cerr << "Could not read image: " << entryPath.string() << std::endl;
				}
												
			}												
		}							
		
	}		
	std::cout << "No files: " << no_files << std::endl;

}
开发者ID:animecomico,项目名称:BagOfWords,代码行数:58,代码来源:bow_main.cpp

示例3: predict

    // TextureFeature::Classifier
    virtual int predict(const cv::Mat &testFeature, cv::Mat &results) const
    {
        int best = -1;
        double mind=DBL_MAX;
        nearest(testFeature, features, best, mind, *this);

        int found = best>-1 ? labels.at<int>(best) : -1;
        results.push_back(float(found));
        results.push_back(float(mind));
        results.push_back(float(best));
        return 3;
    }
开发者ID:zbxzc35,项目名称:uniform-lbp,代码行数:13,代码来源:classifier.cpp

示例4: key

  void ODFeatureDetector2D::findSiftGPUDescriptors(char const *image_name, cv::Mat &descriptors, vector<cv::KeyPoint> &keypoints)
  {
    sift_gpu_->RunSIFT(image_name);

    int nFeat = sift_gpu_->GetFeatureNum();//get feature count
    //allocate memory for readback
    vector<SiftGPU::SiftKeypoint> keys(nFeat);
    //read back keypoints and normalized descritpros
    //specify NULL if you don’t need keypoints or descriptors
    vector<float> imageDescriptors(128 * nFeat);
    sift_gpu_->GetFeatureVector(&keys[0], &imageDescriptors[0]);

    sift_gpu_->SaveSIFT("1.sift");

    //to opencv format
    keypoints.clear();
    descriptors.create(0, 128, CV_32FC1);
    for(int i = 0; i < nFeat; ++i) {
      cv::KeyPoint key(keys[i].x, keys[i].y, keys[i].s, keys[i].o);
      keypoints.push_back(key);
      cv::Mat descriptor(1, 128, CV_32FC1);
      for(int x = 0; x < 128; x++) descriptor.at<float>(x) = floor(0.5 + 512.0f * imageDescriptors[(i << 7) + x]);
      descriptors.push_back(descriptor);
    }
    cv::Mat image = cv::imread(image_name);
  }
开发者ID:Aravind-Suresh,项目名称:opendetection,代码行数:26,代码来源:ODFeatureDetector2D.cpp

示例5: prohog

cv::Mat_<int> extractProHOGFeatures( const vector<TrainingSet> &xs,
                    int nbins, const cv::Size &cdims, cv::Mat &trows)
{
    cerr << "Extracting feature vectors from " << xs.size() << " training sets..." << endl;
    cv::Mat_<int> labels(0,0,CV_32SC1);
    trows.create(0,0,CV_32FC1);

    int fvsz = 0;
    int dataCount = 0;
    int lab = -1;
    BOOST_FOREACH( const TrainingSet &ts, xs)
    {
        lab++;  // New dataset label
        BOOST_FOREACH( const cv::Mat &x, ts)
        {
            RFeatures::ProHOG prohog( x, nbins);
            const cv::Mat pfvRaw = prohog( cdims);
            cv::Mat pfv32;
            pfvRaw.convertTo( pfv32, CV_32F);
            const cv::Mat pfv = pfv32.reshape(1,1); // Single row CV_32FC1
            if ( fvsz == 0)
                fvsz = pfv.cols;
            assert( fvsz == pfv.cols);
            trows.push_back(pfv);
            labels.push_back(lab);
            dataCount++;
        }   // end foreach
开发者ID:richeytastic,项目名称:rlearning,代码行数:27,代码来源:main.cpp

示例6: SURFExtractor_GPU

void Feature::SURFExtractor_GPU(vector<cv::KeyPoint> &feature_pts,
	vector_eigen_vector3f &feature_pts_3d,
	cv::Mat &feature_descriptors,
	const cv::Mat &imgRGB, const cv::Mat &imgDepth)
{
	cv::Mat grey;
	cv::cvtColor(imgRGB, grey, CV_BGR2GRAY);
	//cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
	cv::gpu::GpuMat gpuRGB, gpuKeypoints, gpuDescriptors;
	gpuRGB.upload(grey);
	cv::gpu::SURF_GPU surf;

	surf(gpuRGB, cv::gpu::GpuMat(), gpuKeypoints, gpuDescriptors);

	vector<cv::KeyPoint> fpts;
	cv::Mat descriptors;
	surf.downloadKeypoints(gpuKeypoints, fpts);
	gpuDescriptors.download(descriptors);

	for (int i = 0; i < fpts.size(); i++)
	{
		if (imgDepth.at<ushort>(cvRound(fpts[i].pt.y), cvRound(fpts[i].pt.x)) == 0)
			continue;
		feature_pts.push_back(fpts[i]);
		Eigen::Vector3f pt = ConvertPointTo3D(fpts[i].pt.x, fpts[i].pt.y, imgDepth);
		feature_pts_3d.push_back(pt);
		feature_descriptors.push_back(descriptors.row(i));
	}
}
开发者ID:weeks-yu,项目名称:WReg,代码行数:29,代码来源:Feature.cpp

示例7: SIFTExtractor

void Feature::SIFTExtractor(vector<cv::KeyPoint> &feature_pts,
	vector_eigen_vector3f &feature_pts_3d,
	cv::Mat &feature_descriptors,
	const cv::Mat &imgRGB, const cv::Mat &imgDepth)
{
	cv::SIFT sift_detector;
	cv::Mat mask, descriptors;
	vector<cv::KeyPoint> fpts;

	sift_detector(imgRGB, mask, fpts, descriptors);

	for (int i = 0; i < fpts.size(); i++)
	{
		if (imgDepth.at<ushort>(cvRound(fpts[i].pt.y), cvRound(fpts[i].pt.x)) == 0)
			continue;
		
		feature_pts.push_back(fpts[i]);
		Eigen::Vector3f pt = ConvertPointTo3D(fpts[i].pt.x, fpts[i].pt.y, imgDepth);
		feature_pts_3d.push_back(pt);

		double norm = 0.0;
		for (int j = 0; j < descriptors.cols; j++)
		{
			norm += descriptors.at<float>(i, j) * descriptors.at<float>(i, j);
		}
		norm = sqrt(norm);
		for (int j = 0; j < descriptors.cols; j++)
		{
			descriptors.at<float>(i, j) /= norm;
		}
		feature_descriptors.push_back(descriptors.row(i));
	}
}
开发者ID:weeks-yu,项目名称:WReg,代码行数:33,代码来源:Feature.cpp

示例8: concatChannels

void concatChannels(const cv::Mat& src, cv::Mat& dst) {
    std::vector<cv::Mat> channels;
    cv::split(src, channels);
    dst = cv::Mat();
    for (VMit vmit = channels.begin(); vmit != channels.end(); ++vmit) {
        dst.push_back(*vmit);
    }
}
开发者ID:OsipovStas,项目名称:ImageAnalysis,代码行数:8,代码来源:main.cpp

示例9: analyse

//analysis operator: action analyse; takes the phase signal and gives the sequence of coefficients (representation realm)
//from phase signal space to zernike representation
void Zernike::analyse(const cv::Mat& sig, cv::Mat& z_coeffs)
{
  z_coeffs.release();
  for(cv::Mat z_j : base_)
  {
    double l2 = cv::norm(z_j, cv::NORM_L2);
    double inner_prod = z_j.dot(sig)/(l2*l2);
    z_coeffs.push_back( inner_prod );
  }
}
开发者ID:dguerra,项目名称:pdmaster,代码行数:12,代码来源:Zernike.cpp

示例10: randomFat

static void randomFat(const vector<cv::Mat> &input, cv::Mat &fat)
{
    cv::Mat_<int> randIdx(1, input.size());
    randomIndex(randIdx);

    for (size_t i=0; i<input.size(); i++)
    {
        int idx = randIdx(i);
        fat.push_back(input[idx].reshape(1,1));
    }
}
开发者ID:serge-m,项目名称:uniform-lbp,代码行数:11,代码来源:net.cpp

示例11: concatVectorToMatVertical

 //
 // concatVectorToMatVertical
 //
 bool concatVectorToMatVertical (const std::vector<float> &vector, cv::Mat &mat)
 {
   if (vector.size () != mat.cols) {
     std::cout << "### Size of vector should be equal to cols of Mat." << std::endl;
     debug (vector.size ());  debug (mat.cols);
     return false;
   }
   cv::Mat temp (vector);
   cv::Mat temp_t = temp.t ();
   mat.push_back (temp_t);
   return true;
 }
开发者ID:shingt,项目名称:cvutils,代码行数:15,代码来源:cvutils.cpp

示例12: compute_histogram

void histogram_generator_eyes::compute_histogram(cv::Mat& image, cv::Mat& histogram){

    //Releasing the memory
    histogram.release();

    //Mat aux individual descriptor
    cv::Mat aux_descriptors;
    cv::Mat aux_histogram;
    cv::Mat aux_histogram2;

    //Aux info to compute the boxes
    int aux_cols;
    int aux_rows;
    //Boxes
    std::vector<box> boxes;

    //Cropped aux image
    cv::Mat cropped_image;

    //getting the size of the image
    aux_cols=image.cols;
    aux_rows=image.rows;

    //Getting the boxes

    std::vector<int> binx;
    std::vector<int> biny;
    binx.push_back(1);
    biny.push_back(1);
    boxes=generateSpatialBoxes(aux_rows, aux_cols, binx , biny);


    //Crop the images and extraction features
    for(unsigned int j=0;j<boxes.size();j++){

        cropped_image= image(cv::Range(boxes.at(j).minY, boxes.at(j).maxY), cv::Range(boxes.at(j).minX, boxes.at(j).maxX));
        aux_descriptors=feature_extract->extract_dsift(cropped_image,2,4);
        aux_histogram2=clustering->get_histogram(aux_descriptors);

        transpose(aux_histogram2, aux_histogram2);
        aux_histogram.push_back(aux_histogram2);

    }

    transpose(aux_histogram, aux_histogram);
    histogram.push_back(aux_histogram);
    aux_histogram.release();

}
开发者ID:kukuruza,项目名称:DrowsyDriver,代码行数:49,代码来源:histogram_generator_eyes.cpp

示例13: shuffleRows

void shuffleRows(const cv::Mat &matrix, cv::Mat& shuffleMatrix)
{
  shuffleMatrix.release();
  std::vector <int> seeds;
  for (int cont = 0; cont < matrix.rows; cont++)
  {
    seeds.push_back(cont);
  }
  cv::theRNG() = cv::RNG( cv::getTickCount() );
  cv::randShuffle(seeds);

  for (int cont = 0; cont < matrix.rows; cont++)
  {
    shuffleMatrix.push_back(matrix.row(seeds[cont]));
  }
}
开发者ID:dguerra,项目名称:pdmaster,代码行数:16,代码来源:ToolBox.cpp

示例14: ORBExtractor

void Feature::ORBExtractor(vector<cv::KeyPoint> &feature_pts,
	vector_eigen_vector3f &feature_pts_3d,
	cv::Mat &feature_descriptors,
	const cv::Mat &imgRGB, const cv::Mat &imgDepth)
{
	cv::ORB orb_detector;
	cv::Mat mask, descriptors;
	vector<cv::KeyPoint> fpts;

	orb_detector(imgRGB, mask, fpts, descriptors);
	for (int i = 0; i < fpts.size(); i++)
	{
		if (imgDepth.at<ushort>(cvRound(fpts[i].pt.y), cvRound(fpts[i].pt.x)) == 0)
			continue;
		feature_pts.push_back(fpts[i]);
		Eigen::Vector3f pt = ConvertPointTo3D(fpts[i].pt.x, fpts[i].pt.y, imgDepth);
		feature_pts_3d.push_back(pt);
		feature_descriptors.push_back(descriptors.row(i));
	}
}
开发者ID:weeks-yu,项目名称:WReg,代码行数:20,代码来源:Feature.cpp

示例15: readLabelsMat

void SketchRecognizer::readLabelsMat(const std::string &labels, cv::Mat &labelsMat)
{
    std::ifstream labels_in(labels.c_str());
    uint labels_size = 0;
    labels_in >> labels_size;
    uint class_num = 0;
    labels_in >> class_num;

    _labels.clear();
    char line[1024] = {0};
    labels_in.getline(line, sizeof(line)); //get '\n'

    for(uint i = 0; i < labels_size; i++) {
        labels_in.getline(line, sizeof(line));
        _labels.push_back(line);
        cv::Mat temp = cv::Mat::ones(class_num, 1, CV_32FC1) * i;
        labelsMat.push_back(temp);
    }

    labels_in.close();
}
开发者ID:1024kb1,项目名称:opensse,代码行数:21,代码来源:sketchrecognizer.cpp


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