将图片的座标写入数组中,并把坐标值由小到大排列好

将图片的坐标写入数组中,并把坐标值由小到大排列好
int temp.x=0,temp.y=0;
for( ; contour; contour = contour->h_next )                                                           
 {
  CvRect rect=cvBoundingRect(contour,1);
  CvPoint pt1=cvPoint(rect.x,rect.y),pt2=cvPoint(rect.x+rect.width, rect.y+rect.height);
  cvRectangle(dst,pt1,pt2,CV_RGB(255,0,0),1,CV_AA,0);
  cvLine(dst,pt1,pt2,CV_RGB(0,255,0),1,CV_AA,0);
  pt1=cvPoint(rect.x,rect.y+rect.height),
  pt2=cvPoint(rect.x+rect.width,rect.y);
  cvLine(dst,pt1,pt2,CV_RGB(0,255,0),1,CV_AA,0);
 
  temp.x=rect.x+ rect.width/2;
  temp.y=rect.y+ rect.height/2;              
 } 
将temp.x    ,    temp.y写入到数组中并排好序(从小到大)
------解决方案--------------------
路过,来学习。你这好像是OpenCV吧,可能精通这方面的人看不到你的帖子,不如去OpenCV的论坛去看看。

不知道OpenCV能不能用STL,可以用vector来设计需要的数组,用排序函数来排序,很方便的。

呵呵,一起探讨,帮你顶一下。
------解决方案--------------------
就按楼上说的,vector,把point放进去,完后安装你看大小是怎么个顺序,完后排列就行了