• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ cv::vector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getMomentMatchBasedProbs

    cv::vector< double > getMomentMatchBasedProbs( const cv::vector< cv::vector< cv::Point > > &contours )
    {
        cv::vector< double > probs( contours.size() );

        for( int i = 0; i < contours.size(); i++ )
        {
            probs[i] =  1.0 - fmin( matchShapes( contours[i], matchContour_, CV_CONTOURS_MATCH_I2, 0.0 ) / matchThreshold_, 1.0 );
        }
        return( probs );
    }
开发者ID:randompeople,项目名称:ardrone_autonomy,代码行数:10,代码来源:ardrone_tracker.cpp


示例2: getSurfMatchBasedProbs

    cv::vector< double > getSurfMatchBasedProbs( const cv::vector< cv::vector< cv::Point > > &contours, cv_bridge::CvImagePtr cvPtr )
    {
        cv::vector< double > probs( contours.size() );

        for( int i = 0; i < contours.size(); i++ )
        {
            probs[i] = getSingleSurfProb( contours[i], cvPtr, i );
        }
        return( probs );
    }
开发者ID:randompeople,项目名称:ardrone_autonomy,代码行数:10,代码来源:ardrone_tracker.cpp


示例3: removeOutlier

void RemoveNoise::removeOutlier(cv::vector<cv::Point2f>& start,
                                cv::vector<cv::Point2f>& end) const
{
    float averageNorm = 0.0f;
    
    for(auto startIter=start.begin(),endIter=end.begin();
        startIter!=start.end(); startIter++,endIter++)
    {
        averageNorm += cv::norm(*startIter - *endIter);
    }
    averageNorm /= start.size();
    
    for(auto startIter=start.begin(), endIter=end.begin();
        startIter!=start.end(); /* look at the end of for */)
    {
        if(cv::norm(*startIter - *endIter) > threshNorm * averageNorm){
            startIter = start.erase(startIter);
            endIter = end.erase(endIter);
            
            continue;
        }
        
        startIter++, endIter++;
    }
}
开发者ID:nakazawa9892,项目名称:AxisOfRotation,代码行数:25,代码来源:RemoveNoise.cpp


示例4: cutFeatures

bool VisualFeatureExtraction::cutFeatures(cv::vector<cv::KeyPoint> &kpts,
		cv::Mat &features, unsigned short maxFeats) const {

	// store hash values in a map
	std::map<size_t, unsigned int> keyp_hashes;
	cv::vector<cv::KeyPoint>::iterator itKeyp;

	cv::Mat sorted_features;

	unsigned int iLine = 0;
	for (itKeyp = kpts.begin(); itKeyp < kpts.end(); itKeyp++, iLine++)
		keyp_hashes[(*itKeyp).hash()] = iLine;

	// sort values according to the response
	std::sort(kpts.begin(), kpts.end(), greater_than_response());
	// create a new descriptor matrix with the sorted keypoints
	sorted_features.create(0, features.cols, features.type());
	sorted_features.reserve(features.rows);
	for (itKeyp = kpts.begin(); itKeyp < kpts.end(); itKeyp++)
		sorted_features.push_back(features.row(keyp_hashes[(*itKeyp).hash()]));

	features = sorted_features.clone();

	// select the first maxFeats features
	if (kpts.size() > maxFeats) {
		vector<KeyPoint> cutKpts(kpts.begin(), kpts.begin() + maxFeats);
		kpts = cutKpts;

		features = features.rowRange(0, maxFeats).clone();
	}

	return 0;

}
开发者ID:greeneyesproject,项目名称:testbed-demo,代码行数:34,代码来源:VisualFeatureExtraction.cpp


示例5: setWorldPoints

void setWorldPoints(cv::vector<cv::vector<cv::Point3f> > &worldPoints, 
		    const cv::Size patternSize,
		    const int &fileNum){
  worldPoints.clear();
  worldPoints.resize(fileNum);
  for(int i = 0; i < fileNum; i++ )
    {
      for(int j = 0; j < patternSize.height; j++ )
	for(int k = 0; k < patternSize.width; k++ )
	  worldPoints[i].push_back(cv::Point3f(k*g_squareSize, j*g_squareSize, 0));
    }
}
开发者ID:yoshimasa1700,项目名称:calibDS325,代码行数:12,代码来源:calibDS325.cpp


示例6: grayToDec

int GrayCodes::grayToDec(cv::vector<bool> gray)//convert a gray code sequence to a decimal number
{
    int dec = 0;
    bool tmp = gray[0];
    if(tmp)
        dec += (int) pow((float)2, int(gray.size() - 1));
    for(int i = 1; i < gray.size(); i++){
        tmp=Utilities::XOR(tmp,gray[i]);
        if(tmp)
            dec+= (int) pow((float)2,int (gray.size() - i - 1) );
    }
    return dec;
}
开发者ID:NEU-TEAM,项目名称:Structure-Light-Reconstructor,代码行数:13,代码来源:graycodes.cpp


示例7:

cv::vector<cv::DMatch> Matching::getSymetryMatches(
        const cv::vector<cv::DMatch> &matches1, const cv::vector<cv::DMatch> &matches2){

    cv::vector<cv::DMatch> symmetryMatches;
    for(int i = 0; i < matches1.size(); i++){
        for (int j = 0; j < matches2.size(); j++){
            if(matches1[i].queryIdx == matches2[j].trainIdx && matches1[i].trainIdx == matches2[j].queryIdx ){
                symmetryMatches.push_back(cv::DMatch(matches1[i].queryIdx, matches1[i].trainIdx, matches1[i].distance));
                break;
            }
        }
    }
    return symmetryMatches;
}
开发者ID:vanthonguyen,项目名称:m2,代码行数:14,代码来源:Matching.cpp


示例8: detectPaths

void AGPathDetection::detectPaths(cv::vector<cv::vector<AGImage>> &imagesMatrix)
{
    this->testingMode = false;
//    this->testSelectedImage(imagesMatrix[1][0]);
//    this->testSelectedImage(imagesMatrix[1][0]);
    for (int x = 0; x < imagesMatrix.size(); x++) {
        for (int y = 0; y < imagesMatrix.front().size(); y++) {
            Mat skeleton;
            this->prepareForPathDetecting(imagesMatrix[x][y].image, skeleton);
            this->searchForPathsInImageUsingSkeleton(imagesMatrix[x][y], skeleton);
            this->testDetectedPathsInImage(imagesMatrix[x][y]);
        }
    }
}
开发者ID:aleksandergrzyb,项目名称:mostitch,代码行数:14,代码来源:AGPathDetection.cpp


示例9: isEnoughHalfVector

bool RemoveNoise::isEnoughHalfVector(cv::vector<cv::Point2f>& start) const
{
    int xCenter = frameSize.width / 2;
    int count = 0;
    
    for(auto startIter=start.begin(); startIter!=start.end(); startIter++){
        if((left? startIter->x <= xCenter: xCenter < startIter->x)){
            count++;
        }
    }
    
    if(count < threshNum / 2) return false;
    
    return true;
}
开发者ID:nakazawa9892,项目名称:AxisOfRotation,代码行数:15,代码来源:RemoveNoise.cpp


示例10: calcProjectionMatrix

	// 透視投影変換行列の推定
	void calcProjectionMatrix(cv::vector<cv::Point3d>& op, cv::vector<cv::Point2d>& ip, cv::Mat& dst)
	{
		cv::Mat A;
		A.create(cv::Size(12, op.size()*2), CV_64FC1);

		for (int i = 0, j = 0; i < op.size()*2; i+=2, ++j)
		{
			A.at<double>(i, 0) = 0.0;
			A.at<double>(i, 1) = 0.0;
			A.at<double>(i, 2) = 0.0;
			A.at<double>(i, 3) = 0.0;

			A.at<double>(i, 4) = -op[j].x;
			A.at<double>(i, 5) = -op[j].y;
			A.at<double>(i, 6) = -op[j].z;
			A.at<double>(i, 7) = -1.0;

			A.at<double>(i, 8) = ip[j].y*op[j].x;
			A.at<double>(i, 9) = ip[j].y*op[j].y;
			A.at<double>(i, 10) = ip[j].y*op[j].z;
			A.at<double>(i, 11) = ip[j].y;

			A.at<double>(i+1, 0) = op[j].x;
			A.at<double>(i+1, 1) = op[j].y;
			A.at<double>(i+1, 2) = op[j].z;
			A.at<double>(i+1, 3) = 1.0;

			A.at<double>(i+1, 4) = 0.0;
			A.at<double>(i+1, 5) = 0.0;
			A.at<double>(i+1, 6) = 0.0;
			A.at<double>(i+1, 7) = 0.0;

			A.at<double>(i+1, 8) = -ip[j].x*op[j].x;
			A.at<double>(i+1, 9) = -ip[j].x*op[j].y;
			A.at<double>(i+1, 10) = -ip[j].x*op[j].z;
			A.at<double>(i+1, 11) = -ip[j].x;
		}

		cv::Mat pvect;
		cv::SVD::solveZ(A, pvect);

		cv::Mat pm(3, 4, CV_64FC1);
		for (int i = 0; i < 12; i++)
		{
			pm.at<double>(i/4, i%4) = pvect.at<double>( i );
		}
		dst = pm;
	}
开发者ID:kurepasu0731,项目名称:ProjectingLight,代码行数:49,代码来源:projectorCalibration.cpp


示例11: drawDetections

void drawDetections(const cv::vector<cv::Point2f>& detections, const cv::Scalar& color, cv::Mat image)
{
    for (size_t i = 0; i < detections.size(); ++i)
    {
        circle(image, detections[i], 3, color, 1, 8, 0);
    }
}
开发者ID:grishin-sergei,项目名称:face-tracking,代码行数:7,代码来源:ForProject.cpp


示例12: errorMeasureEllipse

/**
 * Another function to validate ellipses. Based on having an error measure of
 * points of contours with respect to their respective position
 * on the fitted ellipse.
 */
bool MyEllipses::errorMeasureEllipse(cv::RotatedRect anEllipse, cv::vector<cv::Point> setOfPoints){

	/* Equation of an ellipse
 	 (x-h)^2/a^2 + (y-k)^2/b^2 = 1
	where,
	(h,k) are the coordinates of the center of the ellipse
	a is the length of the semi-major or minor axis
	b is the length of the semi-major or minor axis
	 */
	float h = anEllipse.center.x;
	float k = anEllipse.center.y;

	float a = anEllipse.size.width / 2;
	float b = anEllipse.size.height / 2;
	float diff = 0;

	int size = setOfPoints.size();

	for( int i = 0; i < size; i++){
		float xx = (float) (setOfPoints[i].x) - h;
		float yy = (float) (setOfPoints[i].y) - k;

		float common = a*b/(float) (sqrt((double) ((b*xx)*(b*xx) + (a*yy)*(a*yy))));
		float xIntersection = xx*common;
		float yIntersection = yy*common;

		//distance = sqrt((xx-x)2 + (yy-y)2)
		float currentDiff = (float) sqrt((xx-xIntersection)*(xx-xIntersection) + (yy-yIntersection)*(yy-yIntersection));
		diff = diff + currentDiff;
	}
	diff = diff/size;
	return diff < 100;
}
开发者ID:fastakal,项目名称:cvl11,代码行数:38,代码来源:MyEllipses.cpp


示例13: isEnoughAllVector

bool RemoveNoise::isEnoughAllVector(cv::vector<cv::Point2f>& start) const
{
    int count = (int) start.size();
    
    if(count < threshNum) return false;
    
    return true;
}
开发者ID:nakazawa9892,项目名称:AxisOfRotation,代码行数:8,代码来源:RemoveNoise.cpp


示例14: removePinkCandidate

//Remove pink pocket from vector that is between 2 green points.
void PointLocator::removePinkCandidate(cv::vector<cv::KeyPoint> &pinkKeyPoints, cv::KeyPoint firstPocket, cv::KeyPoint secondPocket){
	//First check that there are actually pink pocket points
	if (!pinkKeyPoints.empty()){
		float distance = -1;
		int min = 0;
		cv::KeyPoint middlePoint;
		middlePoint.pt.x = (firstPocket.pt.x + secondPocket.pt.x) / 2;
		middlePoint.pt.y = (firstPocket.pt.y + secondPocket.pt.y) / 2;
		for (int i = 0; i < pinkKeyPoints.size(); i++){
			float newDistance = distBetweenKeyPoints(pinkKeyPoints[i], middlePoint);
			if ((distance + 1) < epsilon || newDistance < distance){
				distance = newDistance;
				min = i;
			}
		}
		pinkKeyPoints.erase(pinkKeyPoints.begin() + min, pinkKeyPoints.begin() + min + 1);
	}
}
开发者ID:bstock92,项目名称:BilliardBuddy,代码行数:19,代码来源:PointLocator.cpp


示例15: lineAverage

  /* function AverageLine */
  void lineAverage(cv::vector<cv::Vec2f> lines, cv::Mat& src)
  {
	  float rho=0,theta=0;
	  for( size_t i = 0; i < lines.size(); i++ )
	  		{
	  		 rho += lines[i][0];theta += lines[i][1];
	  		}
	 rho/=lines.size();theta/=lines.size();
	 cv::Point pt1, pt2;
	 double a = cos(theta), b = sin(theta);
	 double x0 = a*rho, y0 = b*rho;
	 pt1.x = cvRound(x0 + 1000*(-b));
	 pt1.y = cvRound(y0 + 1000*(a));
	 pt2.x = cvRound(x0 - 1000*(-b));
	 pt2.y = cvRound(y0 - 1000*(a));
	 //cv::line( src, pt1, pt2, cv::Scalar(80,10,55), 3, CV_AA);
	 float rho1=0,rho2=0,theta1=0,theta2=0;
	 float i1=0,i2=0;
	 for( size_t i = 0; i < lines.size(); i++ )
		{
		 if (lines[i][1]>theta)
		 {	 rho1 += lines[i][0];theta1 += lines[i][1];i1++;}
		 else
		 {   rho2 += lines[i][0];theta2 += lines[i][1];i2++;}
		}
	 rho1/=i1;theta1/=i1;
	 a = cos(theta1), b = sin(theta1);
	 x0 = a*rho1, y0 = b*rho1;
	 pt1.x = cvRound(x0 + 1000*(-b));
	 pt1.y = cvRound(y0 + 1000*(a));
	 pt2.x = cvRound(x0 - 1000*(-b));
	 pt2.y = cvRound(y0 - 1000*(a));
	 cv::line( src, pt1, pt2, cv::Scalar(0,100,255), 3, CV_AA);
	 rho2/=i2;theta2/=i2;
	 a = cos(theta2), b = sin(theta2);
	 x0 = a*rho2, y0 = b*rho2;
	 pt1.x = cvRound(x0 + 1000*(-b));
	 pt1.y = cvRound(y0 + 1000*(a));
	 pt2.x = cvRound(x0 - 1000*(-b));
	 pt2.y = cvRound(y0 - 1000*(a));
	 cv::line( src, pt1, pt2, cv::Scalar(0,100,0), 3, CV_AA);
  }
开发者ID:MorS25,项目名称:dasl-ros-pkg,代码行数:43,代码来源:cvBoundingBox_ellipse.cpp


示例16: get_six_points

	//ランダムに6点を抽出
	void get_six_points(cv::vector<cv::Point2d>& calib_p, cv::vector<cv::Point3d>& calib_P, cv::vector<cv::Point2d>& src_p, cv::vector<cv::Point3d>& src_P)
	{
		int i=0;
		srand(time(NULL));    /* 乱数の初期化 */
		cv::Vector<int> exists;
		while(i <= 6){
			int maxValue = (int)src_p.size();
			int v = rand() % maxValue;
			bool e2=false;
			for(int s=0; s<i; s++){
				if(exists[s] == v) e2 = true; 
			}
			if(!e2){
				exists.push_back(v);
				calib_P.push_back(src_P[v]);
				calib_p.push_back(src_p[v]);
				i++;
			}
		}
	}
开发者ID:kurepasu0731,项目名称:ProjectingLight,代码行数:21,代码来源:projectorCalibration.cpp


示例17: loadImages

void loadImages(cv::vector<cv::Mat> &rgb, 
		cv::vector<cv::Mat> &depth, 
		const int &fileNum){
  rgb.clear();
  depth.clear();
  
  for(int i = 0; i < fileNum; ++i){
    stringstream rgbfilename, depthfilename;
    rgbfilename << FLAGS_folder <<"/" << FLAGS_color << i << FLAGS_type;
    depthfilename << FLAGS_folder << "/" << FLAGS_depth << i << FLAGS_type;
    
    cout << "loading : " << rgbfilename.str() << " and " << depthfilename.str() << endl;

    // load RGB image
    cv::Mat tempRGB = cv::imread(rgbfilename.str(), 0);
    rgb.push_back(tempRGB);


    // load depth image
    cv::Mat tempDepth = cv::imread(depthfilename.str(), CV_LOAD_IMAGE_ANYDEPTH);
    tempDepth.convertTo(tempDepth, CV_8U, 255.0/1000.0);
    // cv::Mat maxDist = cv::Mat::ones(tempDepth.rows, tempDepth.cols, CV_8U) * MAX_DEPTH;
    // cv::Mat minDist = cv::Mat::ones(tempDepth.rows, tempDepth.cols, CV_8U) * MIN_DEPTH;
    // cv::min(tempDepth, maxDist, tempDepth);
    // tempDepth -= minDist;
    cv::resize(tempDepth, tempDepth, cv::Size(), 2.0,2.0);
    cv::Mat roiTempDepth;

    cv::resize(tempDepth(cv::Rect(40, 43,498,498 / 4 * 3)), roiTempDepth, cv::Size(640, 480));

    depth.push_back(roiTempDepth);

    std::cout << "loaded" << std::endl;

    cv::imshow("rgb",rgb[i]);
    cv::imshow("depth",depth[i]);
    cv::waitKey(100);
  }

}
开发者ID:yoshimasa1700,项目名称:calibDS325,代码行数:40,代码来源:calibDS325.cpp


示例18: getBestEllipse

/**
 * A function that takes a list of ellipses with their respective quality and returns the best one.
 */
cv::RotatedRect MyEllipses::getBestEllipse(cv::vector<cv::RotatedRect> ellipses, cv::vector<double> qualityOfEllipses){
	int size = ellipses.size(); std::cout<<size;
	double maxQuality = 0;
	int index = 0;

	for(int i = 0; i < size; i++){
		if( qualityOfEllipses[i]>maxQuality ){
			maxQuality = qualityOfEllipses[i];
			index = i;
		}
	}
	return ellipses[index];
}
开发者ID:fastakal,项目名称:cvl11,代码行数:16,代码来源:MyEllipses.cpp


示例19: distance

/*
 * Takes the vector of detected contours from and image and determines whether the points of a contour are clustered around an endpoint making the contour invalid.
 * Any contours deemed to be invalid are not included in the returned vector containing contours deemed valid
 * 
 *@param contours - a vector containing all the detected contours
 *@param lines - a vector containing all detected straight lines
 * 
 *@return - a vector of valid contours
*/
cv::vector< cv::vector<cv::Point> > ImageProcessor::removeRedundantContours(cv::vector< cv::vector<cv::Point> > & contours, cv::vector<cv::Vec4i> lines){
	
	cv::vector< cv::vector<cv::Point> > valid_contours; //a vector to contain all contours that are determined to be valid

	for(int i = 0; i < (int)contours.size(); i++){

		float invalid_point_count = 0.0f; //count of points in a contour that are clustering around an endpoint
		cv::vector<cv::Point> contour_vec = contours[i];
		for(int k = 0; k < (int)contour_vec.size(); k++){

			//compute the distance between each point in the contour and the endpoints of each straight line
			cv::Point point = contour_vec[k];
			for(int j = 0; j < (int)lines.size(); j++){
				//distances of countour point from each endpoint
				double dist1 = distance(point, cv::Point(lines[j][0], lines[j][1]));
				double dist2 = distance(point, cv::Point(lines[j][2], lines[j][3]));
				//distance between both endpoints of line[j]
				double endpoint_dist = distance(cv::Point(lines[j][0], lines[j][1]), cv::Point(lines[j][2], lines[j][3]));
				
				double contour_inLine_dist = dist1 + dist2;

				//if the distance between the contour point and a line endpoint, then increment the number of detected invalid points
				if(dist1 < MAX_DIST || dist2 < MAX_DIST || (contour_inLine_dist - endpoint_dist) < 1.0 ){
					invalid_point_count++;
					break;
				}
			}
		}
		
		//compute the percentage of invalid points in the contour, current contour is valid and pushed onto back of valid_contour vector
		//if less than 10% of the points are found to be invalid.
		float invalid_percentage = invalid_point_count / (float) contour_vec.size();
		if(invalid_percentage < PERCENTAGE){
			valid_contours.push_back(contours[i]);
		}				
	}

	return valid_contours;
}
开发者ID:jcoady9,项目名称:Senior-Design-I,代码行数:48,代码来源:imageProcessor.cpp


示例20: getAreaBasedProbs

    cv::vector< double > getAreaBasedProbs( const cv::vector< cv::vector< cv::Point > > &contours )
    {
        int largestContour = -1;
        double maxArea = 0.0;
        cv::vector< double > probs( contours.size() );

        for( int i = 0; i < contours.size(); i++ )
        {
            probs[i] = cv::contourArea( contours[i] );
            if( maxArea < probs[i] )
            {
                maxArea = probs[i];
                largestContour = i;
            }
        }

        for( int i = 0; i < contours.size(); i++ )
        {
            probs[i] /= probs[largestContour];
        }

        return( probs );
    }
开发者ID:randompeople,项目名称:ardrone_autonomy,代码行数:23,代码来源:ardrone_tracker.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ gpu::DeviceInfo类代码示例发布时间:2022-05-31
下一篇:
C++ cv::VideoWriter类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap