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


C++ IpVec类代码示例

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


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

示例1: EstimateQueue

//生成有序的相对距离的deque
void CGVM::EstimateQueue(const vector<vector<float> >& table, int idx, IpVec& FeaVec, vector<DistanceRelation>& OQ)
{
    Ipoint Fea=FeaVec[idx];
    OQ.reserve(FeaVec.size());
    for(int i=0;i<FeaVec.size();i++)
    {
        if(i!=idx)
        {
            DistanceRelation tmpDR;
            tmpDR.dis=table[Fea.clusterIndex][FeaVec[i].clusterIndex];
            tmpDR.idx=i;
            if(!OQ.size()) OQ.push_back(tmpDR);
            else
            {
                if(tmpDR.dis<=OQ.front().dis)
                    OQ.insert(OQ.begin(),tmpDR);
                else if(tmpDR.dis>=OQ.back().dis)
                    OQ.push_back(tmpDR);
                else
                {
                    for(vector<DistanceRelation>::iterator it=OQ.begin()+1;it!=OQ.end();++it)
                    {
                        if(tmpDR.dis>=(it-1)->dis&&tmpDR.dis<=it->dis)
                        {
                            OQ.insert(it,tmpDR);
                            break;
                        }
                    }
                }
            }
        }
    }
}
开发者ID:Mizutome,项目名称:Cpp-SIFTICGM,代码行数:34,代码来源:CGVM.cpp

示例2: copySURFPts

void copySURFPts(ImageFeatures &dst, const IpVec src, const int length)
{
	int i, j, size;
	Ipoint temp;
	size = src.size();
	//Check if the object has been allocated
	//Deallocate it first
	if(dst.checkAlloc())
			dst.dealloc();
	// Allocated with the correct values
	dst.alloc(length, size);
	for(i = 0; i < size; i++)
	{
		temp = src.at(i);
		float mag = 0;
		//for(j = 0; j < length; j++)
        //    mag += temp.descriptor[j]*temp.descriptor[j];
        //mag = sqrt(mag);
        //for(j = 0; j < length; j++)
        //    temp.descriptor[j] *= mag;
		// Copy each descriptor into the ImageFeature
		dst.copyDescriptorAt(temp.descriptor, i);

	}
}
开发者ID:leblancdavid,项目名称:CraterDetection,代码行数:25,代码来源:bagoffeatures.cpp

示例3: DoExtractKeypointsDescriptor

bool OpenSURFdetector::DoExtractKeypointsDescriptor(IplImage* grayImage)
{
	if(grayImage == NULL)
		return false;
	if(grayImage->nChannels != 1)
		return false;

	this->keypoints.clear();

	IpVec ipts;
	surfDetDes(grayImage, ipts, false, 5, 4, 2, this->threshold);

	Ipoint *ipt;
	windage::OpenSURFpoint point;
	for(unsigned int i = 0; i < ipts.size(); i++) 
	{
		ipt = &ipts.at(i);

		point.SetPoint(windage::Vector3(ipt->x, ipt->y, 1.0));
		point.SetSize(2.5f * ipt->scale);
		point.SetDir(-ipt->orientation);
		
		for(int j=0; j<point.DESCRIPTOR_DIMENSION; j++)
		{
			point.descriptor[j] = ipt->descriptor[j];
		}

		this->keypoints.push_back(point);
	}

	return true;
}
开发者ID:Barbakas,项目名称:windage,代码行数:32,代码来源:OpenSURFdetector.cpp

示例4: extract_surf_dense

void extract_surf_dense(const char* filename, double scale, int xmin, int xmax, int ymin, int ymax, bool upright, double* descriptors) {
	int width  = xmax-xmin + 1;
	int height = ymax-ymin + 1;
	
	NDArray::CArray<double> _descriptors(descriptors,width,height,64);
	IpVec ipts;
	IplImage *img=cvLoadImage(filename);
	Ipoint ipoint;

	for (int i =xmin; i<=xmax; i++){
		for (int j=ymin; j<=ymax; j++){
			ipoint.x = i;
			ipoint.y = j;
			ipoint.orientation = 0.;
			ipoint.scale = scale;
			ipts.push_back(ipoint);
		}
	}	
	surfDes(img,ipts,upright);
	for (int i =0; i<width; i++) {
		for (int j=0; j<height; j++){
			for (int k = 0; k<64 ; k++) _descriptors(i,j,k) = ipts[i].descriptor[j];
		}
	}
	cvReleaseImage(&img);
}
开发者ID:CloPeMa,项目名称:visual_feedback,代码行数:26,代码来源:surf.cpp

示例5: mainKmeans

int mainKmeans(void)
{
  IplImage *img = cvLoadImage("../imgs/img1.jpg");
  IpVec ipts;
  Kmeans km;
  
  // Get Ipoints
  surfDetDes(img,ipts,true,3,4,2,0.0006f);

  for (int repeat = 0; repeat < 10; ++repeat)
  {

    IplImage *img = cvLoadImage("../imgs/img1.jpg");
    km.Run(&ipts, 5, true);
    drawPoints(img, km.clusters);

    for (unsigned int i = 0; i < ipts.size(); ++i)
    {
      cvLine(img, cvPoint(ipts[i].x,ipts[i].y), cvPoint(km.clusters[ipts[i].clusterIndex].x ,km.clusters[ipts[i].clusterIndex].y),cvScalar(255,255,255));
    }

    showImage(img);
  }

  return 0;
}
开发者ID:RandomWalkEagle,项目名称:surfDetect,代码行数:26,代码来源:main.cpp

示例6: mainImage

int mainImage(void)
{
  // Declare Ipoints and other stuff
  IpVec ipts;
  // Make image as a Mat; convert to IplImage for OpenSURF library actions
  cv::Mat mimg=cv::imread("OpenSURF/imgs/sf.jpg", CV_LOAD_IMAGE_COLOR);
  IplImage iimg=mimg;
  IplImage* img=&iimg;

  // Detect and describe interest points in the image
  clock_t start = clock();
  surfDetDes(img, ipts, false, 5, 4, 2, 0.0004f); 
  clock_t end = clock();

  std::cout<< "OpenSURF found: " << ipts.size() << " interest points" << std::endl;
  std::cout<< "OpenSURF took: " << float(end - start) / CLOCKS_PER_SEC  << " seconds" << std::endl;

  // Draw the detected points
  drawIpoints(img, ipts);
  
  // Display the result
  showImage(img);

  return 0;
}
开发者ID:izewiske,项目名称:3Hat,代码行数:25,代码来源:ContourSURF.cpp

示例7: getMatches

//! Populate IpPairVec with matched ipts 
void getMatches(IpVec &ipts1, IpVec &ipts2, IpPairVec &matches) {
	float dist, d1, d2;
	Ipoint *match;

	matches.clear();

	for (unsigned int i = 0; i < ipts1.size(); i++) {
		d1 = d2 = 1000;

		for (unsigned int j = 0; j < ipts2.size(); j++) {
			dist = ipts1[i] - ipts2[j];

			if (dist < d1) // if this feature matches better than current best
			{
				d2 = d1;
				d1 = dist;
				match = &ipts2[j];
			} else if (dist < d2) // this feature matches better than second best
			{
				d2 = dist;
			}
		}

		// If match has a d1:d2 ratio < 0.65 ipoints are a match
		if (d1 / d2 < 0.65) {
			// Store the change in position
			ipts1[i].dx = match->x - ipts1[i].x;
			ipts1[i].dy = match->y - ipts1[i].y;
			match->dx =  ipts1[i].x -match->x;
			match->dy =  ipts1[i].y -match->y;

			matches.push_back(std::make_pair(ipts1[i], *match));
		}
	}
}
开发者ID:adepondra,项目名称:androidobjectrecognition,代码行数:36,代码来源:ipoint.cpp

示例8: linearizeDescriptors

void
linearizeDescriptors(float *dst, const IpVec &ipts)
{
	for (size_t i = 0; i < ipts.size(); i++)
	{
		const Ipoint &p = ipts[i];
		std::memcpy(dst + i * 64, p.descriptor, 64 * sizeof(float));
	}
}
开发者ID:withniu,项目名称:GPU-SURF-,代码行数:9,代码来源:getMatchesGPU.cpp

示例9: disTable

//通过clusterIndex进行索引的特征点相对距离矩阵
void CGVM::disTable(vector<vector<float> >& table, IpVec& Fea, double* ave)
{
    double num=0;
    *ave=0;
    table.resize(Fea.size());
    for(int i=0;i<table.size();i++) table[i].resize(Fea.size());
    for(int i=0;i<Fea.size()-1;i++)
    {
        for(int j=i+1;j<Fea.size();j++)
        {
            double d;
            d=sqrt(pow((Fea[i].x-Fea[j].x),2)+pow((Fea[i].y-Fea[j].y),2));
            table[i][j]=d;
            table[j][i]=d;
            *ave+=d;
            num++;
        }
    }
    *ave/=num;
}
开发者ID:Mizutome,项目名称:Cpp-SIFTICGM,代码行数:21,代码来源:CGVM.cpp

示例10: mainImage

int mainImage(IplImage *img)
{
  // Declare Ipoints and other stuff
  IpVec ipts;

  // Detect and describe interest points in the image
  clock_t start = clock();
  surfDetDes(img, ipts, true, 5, 4, 2, 0.01f); 
  clock_t end = clock();

  std::cout<< "OpenSURF found: " << ipts.size() << " interest points" << std::endl;
  std::cout<< "OpenSURF took: " << float(end - start) / CLOCKS_PER_SEC  << " seconds" << std::endl;

  // Draw the detected points
  drawIpoints(img, ipts);
  
  // Display the result
  showImage(img);

  return 0;
}
开发者ID:RandomWalkEagle,项目名称:surfDetect,代码行数:21,代码来源:main.cpp

示例11: extract_surf

double* extract_surf(const char* filename, bool upright, int octaves, int intervals, int init_samples, double thres, int& nkeypoints){
	IpVec ipts;
	IplImage *img=cvLoadImage(filename);

	surfDetDes(img, ipts, upright, octaves, intervals, init_samples, thres);
	nkeypoints = ipts.size();
	double *result = static_cast<double*>(malloc(sizeof(double) * (nkeypoints*(4+64)) ));
	double *keypoints = &result[0];
	double *descriptors = &result[4*nkeypoints];
	
	for (int i =0; i<(int)ipts.size(); i++) {
		keypoints[i*4]   = ipts[i].x;
		keypoints[i*4+1] = ipts[i].y;
		keypoints[i*4+2] = ipts[i].orientation;
		keypoints[i*4+3] = ipts[i].scale;
		
		for (int j=0;j<64;j++){
			descriptors[i*64+j] = ipts[i].descriptor[j];
		}
	}
	cvReleaseImage(&img);
	return result;
}
开发者ID:CloPeMa,项目名称:visual_feedback,代码行数:23,代码来源:surf.cpp

示例12: extract_surf_samples

void extract_surf_samples(const char* filename, int npoints, double* points, bool upright, double* descriptors){
	NDArray::CArray<double> _points(points,npoints,4);
	NDArray::CArray<double> _descriptors(descriptors,npoints,64);
	IpVec ipts;
	IplImage *img=cvLoadImage(filename);
	Ipoint ipoint;

	for (int i =0; i<npoints; i++){
		ipoint.x = _points(i,0);
		ipoint.y = _points(i,1);
		ipoint.orientation = _points(i,2);
		ipoint.scale = _points(i,3);
		ipts.push_back(ipoint);
	}	
	surfDes(img,ipts,upright);
	for (int i =0; i<npoints; i++) {
		for (int j = 0; j<64 ; j++) _descriptors(i,j) = ipts[i].descriptor[j];
		_points(i,0) = ipts[i].x;
		_points(i,1) = ipts[i].y;
		_points(i,2) = ipts[i].orientation;
		_points(i,3) = ipts[i].scale;
	}
	cvReleaseImage(&img);
}
开发者ID:CloPeMa,项目名称:visual_feedback,代码行数:24,代码来源:surf.cpp

示例13: mainImage

int mainImage(void)
{
    // Declare Ipoints and other stuff
    IpVec ipts;
    IplImage *img=cvLoadImage("Images/img1.jpg");

    // Detect and describe interest points in the image
    {
        surfDetDes(img, ipts, false, 3, 4, 2, 0.0004f);
    }

    std::cout<< "OpenSURF found: " << ipts.size() << " interest points" << std::endl;
    //std::cout<< "OpenSURF took: min/avg/max/stddev " << time_min << "/" << time_avg << "/" << time_max << "/" << stddev
    //		<< std::endl;

    // Draw the detected points
    drawIpoints(img, ipts);

    // Display the result
    //showImage(img);
    cvSaveImage("result.jpg",img);

    return 0;
}
开发者ID:withniu,项目名称:surf_kinect,代码行数:24,代码来源:main.cpp

示例14: init

void init(unsigned char *img,double *refhist,IpVec *refpts,double updt[][9],int w,int h)
{
    double obj[8]={0};
    unsigned char pix[60*80*3]={0,0};
    obj[0]=w/2;obj[1]=h/2;obj[2]=80;obj[3]=60;obj[4]=obj[5]=1;obj[6]=obj[7]=0;
    int x=obj[0],y=obj[1],wt=obj[2],ht=obj[3];
    int p=0,l=0;
    IpVec pt;
    IplImage *im;
    im=cvCreateImage(cvSize(w,h),IPL_DEPTH_8U,3);
    memcpy(im->imageData,img,im->imageSize);
    surfDetDes(im,pt,false,5,4,2,0.00004f);
    p=0;
    for(int k=0;k<pt.size();k++)
    {
        if((pt.at(k).x>=(w/2-wt/2)) && (pt.at(k).x<=(w/2+wt/2)) &&
        (pt.at(k).y>=(h/2-ht/2)) && (pt.at(k).y<=(h/2+ht/2)) )
        {
            Ipoint tmp;
            pt.at(k).x-=(w/2-wt/2);

            pt.at(k).y-=(h/2-ht/2);
            (*refpts).push_back(pt.at(k));
        }
    }
    for(int i=0;i<N;i++)
    {
        updt[i][0]=obj[0]+(rand()%60-30);
        updt[i][1]=obj[1]+(rand()%60-30);
        updt[i][2]=obj[2];
        updt[i][3]=obj[3];
        updt[i][4]=obj[4];
        updt[i][5]=obj[5];
        updt[i][6]=obj[6];
        updt[i][7]=obj[7];
        updt[i][8]=(double)1/N;
        img[3*(int)(w*updt[i][1]+updt[i][0])]=0;img[3*(int)(w*updt[i][1]+updt[i
        ][0])+1]=255;img[3*(int)(w*updt[i][1]+updt[i][0])+1]=0;
    }
}
开发者ID:smajida,项目名称:Object-Tracking-UAV,代码行数:40,代码来源:testApp.c

示例15: gettimeofday

KeyPointSet * SurfExtractor::getKeyPointSet(FrameInput * fi){

	struct timeval start, end;
	gettimeofday(&start, NULL);

	IpVec ipts;
	surfDetDes(fi->get_rgb_img(), ipts, upright, octaves, intervals, init_sample, thres);
	
	KeyPointSet * keypoints = new KeyPointSet();
	for(int i = 0; i < (int)ipts.size(); i++)
	{
		
		Ipoint p = ipts.at(i);
		int w = int(p.x+0.5f);
		int h = int(p.y+0.5f);
		int ind = h * 640 + w;
		float * desc = new float[64];
		for(int j = 0; j < 64; j++){desc[j] = p.descriptor[j];}
		SurfFeatureDescriptor64 * descriptor = new SurfFeatureDescriptor64(desc, p.laplacian);

		float r,g,b,x,y,z;
		fi->getRGB(r,g,b,w,h);
		fi->getXYZ(x,y,z,w,h);
		
		KeyPoint * kp = new KeyPoint();
		kp->stabilety = p.stab;
		kp->descriptor = descriptor;
		kp->point = new Point(x,y,z,w,h);
		kp->r = r;
		kp->g = g;
		kp->b = b;
		if(z > 0 && !isnan(z)){
			kp->valid = true;
			kp->index_number = keypoints->valid_key_points.size();
			keypoints->valid_key_points.push_back(kp);
			//cvCircle(rgb_img, cvPoint(w, h), 5, cvScalar(0, 255, 0, 0), 2, 8, 0);
		}else{
			kp->valid = false;
			kp->index_number = keypoints->invalid_key_points.size();
			keypoints->invalid_key_points.push_back(kp);
			//cvCircle(rgb_img, cvPoint(w, h), 5, cvScalar(0, 0, 255, 0), 2, 8, 0);
		}
	}
	//printf("pre sort\n");
	sort(keypoints->valid_key_points.begin(),keypoints->valid_key_points.end(),comparison_surf);
	sort(keypoints->invalid_key_points.begin(),keypoints->invalid_key_points.end(),comparison_surf);
	//cvReleaseImage( &rgb_img );

	//cvNamedWindow("surf image", CV_WINDOW_AUTOSIZE );
	//cvShowImage("surf image", rgb_img);
	//cvWaitKey(0);
	//cvReleaseImage( &rgb_img);
	
	gettimeofday(&end, NULL);
	double time = (end.tv_sec*1000000+end.tv_usec-(start.tv_sec*1000000+start.tv_usec))/1000000.0f;
	total_time += time;
	total_frames++;
	//printf("ipts.size(): %i\n",ipts.size());
	total_keypoints+=ipts.size();//keypoints->valid_key_points.size();
	//printf("avg_time: %f avg_keypoints: %f\n",total_time/double(total_frames),double(total_keypoints)/double(total_frames));	
	return keypoints;
}
开发者ID:bigjun,项目名称:aktest,代码行数:62,代码来源:SurfExtractor.cpp


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