【发布时间】:2012-04-18 13:54:24
【问题描述】:
我们在图像处理项目中使用 Blodshed Dev-C++。我们正在视频帧上实现连接组件标签。我们必须使用一个递归函数,它递归了很多次,以至于我们得到了一个stackoverflow。我们怎样才能拥有更大的堆栈大小?是否可以通过一些链接器参数或类似的东西来改变它?
void componentLabel(int i,int j,IplImage *img){
// blueFrame = img->imageData[i*3*width+j*3];
// greenFrame = img->imageData[i*3*width+j*3+1];
// redFrame = img->imageData[i*3*width+j*3+2];
if(!( img->imageData[i*3*width+j*3]==0 && img->imageData[i*3*width+j*3+1]==0 && img->imageData[i*3*width+j*3+2]==0 ) ){
//printf("iffffff aq\n");
return;
}
else{
//printf("else aq %d\n",sayac_label);
img->imageData[i*3*width+j*3]=1;
new_object.pixel_count=new_object.pixel_count+1;
new_object.total_row=new_object.total_row+i;
new_object.total_col=new_object.total_col+j;
if(j<width-1 ){
componentLabel(i,j+1,img);
}
if(j>0 ){
componentLabel(i,j-1,img);
}
if(i<height-1 ){
if(i>new_object.bottom.satir){
new_object.bottom.satir=i;
new_object.bottom.sutun=j;
}
componentLabel(i+1,j,img);
}
if(i>0 ){
if(i<new_object.top.satir){
new_object.top.satir=i;
new_object.top.sutun=j;
}
return componentLabel(i-1,j,img);
}
}
【问题讨论】:
-
请告诉我您使用的是最新版本的 DevC++,而不是 5 岁以上的版本。
-
blödschaden devcpp 多么合适
-
也许你应该考虑一个不同的算法
-
如果您可以向我们展示您的算法,人们可以建议替代方法
-
Dev C++ 使用的是非常旧的 gcc ( 3.4.2 ) 版本,它不支持 --stack 链接器选项。转移到 linux,您可以使用 setrimit() 以编程方式设置堆栈限制:)
标签: c recursion compiler-optimization dev-c++