>
首页 » 业界动态 » 世界坐标系坐标建立过程的代码以及问题

世界坐标系坐标建立过程的代码以及问题

作者:  时间:2008-11-07 10:23  来源:转贴

#define  ChessBoardSize_height 9
#define  ChessBoardSize_width  7
void InitCorners3D(CvMat *Corners3D,int NImages, float SquareSize)
{
  int CurrentImage  = 0;
  int CurrentRow    = 0; //行
  int CurrentColumn = 0; //列
  int NPoints = ChessBoardSize_height*ChessBoardSize_width;
  float temppoints[63*3]={0};

  for (CurrentImage = 0 ; CurrentImage < NImages ; CurrentImage++)//图片
  {
    for (CurrentRow = 0; CurrentRow < ChessBoardSize_height; CurrentRow++)//行
    {
      for (CurrentColumn = 0; CurrentColumn < ChessBoardSize_width; CurrentColumn++)//列
      {
           temppoints[(CurrentImage*NPoints*3)+(CurrentRow*ChessBoardSize_width + CurrentColumn)*3]=(float)CurrentRow*SquareSize;
          temppoints[(CurrentImage*NPoints*3)+(CurrentRow*ChessBoardSize_width + CurrentColumn)*3+1]=(float)CurrentColumn*SquareSize;
          temppoints[(CurrentImage*NPoints*3)+(CurrentRow*ChessBoardSize_width + CurrentColumn)*3+2]=0;
      }
    }
  }
  *Corners3D= cvMat(NImages*NPoints,3,CV_32FC1,temppoints);
  // cvSetData(Corners3D,temppoints,sizeof(CV_32FC1));
  //cvReleaseData(&temppoints);问题所在,多释放了一个内存
}


 cvReleaseData(&temppoints)问题在这里,内存管理上的问题,在opencv上,想image mat window类型开辟的空间必须释放,不然会造成内存泄露,但是对于基本的类型例如数组d点,像素。。。这些在局部调用完以后,系统会自动释放,如果你再去内存方面的处理,就会出现问题,这个问题是什么,会对内存造成什么影响呢?

相关推荐

世界坐标系坐标建立过程的代码以及问题

2008-11-07

eCos操作系统针对并行S698P-SOC的启动初始化过程

代码  程序  通信  2008-10-13

赛普拉斯的PSoC Designer™ 5.0加快了嵌入式开发与上市进程

PSoC Designer  嵌入式  C 代码  2008-07-17
在线研讨会
焦点